fixed tests

This commit is contained in:
Finn 2021-10-10 19:51:12 +02:00
parent 23e4f0c974
commit 34a2b8cab1
Signed by: finn
GPG key ID: FF4B468FA3E365D7
7 changed files with 43 additions and 14 deletions

18
test.sh Executable file
View file

@ -0,0 +1,18 @@
#!/bin/bash
set -xeuo pipefail
IFS=$'\n\t'
DIR="$(realpath ${0%/*})"
RUNTIME_IS_PODMAN="false"
if [[ -x "$(which podman)" ]]; then
CONTAINER_RUNTIME="$(which podman 2> /dev/null)"
RUNTIME_IS_PODMAN="true"
elif [[ -x "$(which docker)" ]]; then
CONTAINER_RUNTIME="$(which docker 2> /dev/null)"
else
echo "Container runtime (docker/podman) not found!"
exit 1
fi
$CONTAINER_RUNTIME exec --user 33 nextcloud bash -c 'cd /var/www/html/custom_apps/upschooling && make test'

View file

@ -9,7 +9,6 @@ use OCP\AppFramework\App;
use OCP\IRequest;
use PHPUnit\Framework\TestCase;
class MatrixTicketIntegrationTest extends TestCase {
private $controller;
private $mapper;

View file

@ -8,7 +8,6 @@ use OCP\AppFramework\App;
use OCP\IRequest;
use PHPUnit\Framework\TestCase;
class MatrixUserIntegrationTest extends TestCase {
private $mapper;
private $userId = 'john';

View file

@ -1,7 +1,8 @@
<?php
namespace OCA\UPschooling\Controller;
namespace OCA\UPschooling\Tests\Unit\Controller;
use OCA\UPschooling\Controller\PageController;
use OCP\AppFramework\Http\TemplateResponse;
use PHPUnit\Framework\TestCase;

View file

@ -3,13 +3,12 @@
namespace OCA\UPschooling\Tests\Unit\Controller;
use OCA\UPschooling\Controller\TicketApiController;
use OCA\UPschooling\Service\NoteNotFound;
use OCA\UPschooling\Service\TicketService;
use OCP\AppFramework\Http;
use OCP\IRequest;
use PHPUnit\Framework\TestCase;
class NoteApiControllerTest extends TestCase
class TicketApiControllerTest extends TestCase
{
protected $controller;
protected $service;
@ -41,7 +40,7 @@ class NoteApiControllerTest extends TestCase
$this->assertEquals($note, $result->getData());
}
/*
public function testUpdateNotFound()
{
// test the correct status code if no note is found
@ -52,5 +51,5 @@ class NoteApiControllerTest extends TestCase
$result = $this->controller->update(3, 'title', 'content');
$this->assertEquals(Http::STATUS_NOT_FOUND, $result->getStatus());
}
}*/
}

View file

@ -1,6 +1,6 @@
<?php
namespace Unit\Service;
namespace OCA\UPschooling\Tests\Unit\Service;
use OCA\UPschooling\Db\MatrixTicket;
use OCA\UPschooling\Db\TicketMapper;
@ -11,7 +11,7 @@ use OCP\AppFramework\Db\DoesNotExistException;
use PHPUnit\Framework\TestCase;
use Psr\Log\NullLogger;
class NoteServiceTest extends TestCase {
class TicketServiceTest extends TestCase {
/** @var TicketService */
private $service;
@ -43,8 +43,6 @@ class NoteServiceTest extends TestCase {
// the existing note
$note = MatrixTicket::fromRow([
'id' => 3,
'title' => 'yo',
'content' => 'nope'
]);
$this->ticketMapper->expects($this->once())
->method('find')
@ -53,8 +51,6 @@ class NoteServiceTest extends TestCase {
// the note when updated
$updatedNote = MatrixTicket::fromRow(['id' => 3]);
$updatedNote->setTitle('title');
$updatedNote->setContent('content');
$this->ticketMapper->expects($this->once())
->method('update')
->with($this->equalTo($updatedNote))

View file

@ -1,3 +1,20 @@
<?php
require_once __DIR__ . '/../tests/bootstrap.php';
define('PHPUNIT_RUN', 1);
$configDir = getenv('CONFIG_DIR');
if ($configDir) {
define('PHPUNIT_CONFIG_DIR', $configDir);
}
require_once __DIR__ . '/../../../lib/base.php';
\OC::$composerAutoloader->addPsr4('Test\\', OC::$SERVERROOT . '/tests/lib/', true);
\OC::$composerAutoloader->addPsr4('Tests\\', OC::$SERVERROOT . '/tests/', true);
// load all enabled apps
\OC_App::loadApps();
OC_Hook::clear();
set_include_path(get_include_path() . PATH_SEPARATOR . '/usr/share/php');