From 34a2b8cab17618646067845912e7e730249cf0c2 Mon Sep 17 00:00:00 2001 From: Finn Date: Sun, 10 Oct 2021 19:51:12 +0200 Subject: [PATCH] fixed tests --- test.sh | 18 ++++++++++++++++++ .../MatrixTicketIntegrationTest.php | 1 - .../MatrixUserIntegrationTest.php | 1 - tests/Unit/Controller/PageControllerTest.php | 3 ++- ...erTest.php => TicketApiControllerTest.php} | 7 +++---- ...eServiceTest.php => TicketServiceTest.php} | 8 ++------ tests/bootstrap.php | 19 ++++++++++++++++++- 7 files changed, 43 insertions(+), 14 deletions(-) create mode 100755 test.sh rename tests/Integration/{ => Controller}/MatrixTicketIntegrationTest.php (99%) rename tests/Integration/{ => Controller}/MatrixUserIntegrationTest.php (99%) rename tests/Unit/Controller/{NoteApiControllerTest.php => TicketApiControllerTest.php} (94%) rename tests/Unit/Service/{NoteServiceTest.php => TicketServiceTest.php} (91%) diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..00a8055 --- /dev/null +++ b/test.sh @@ -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' \ No newline at end of file diff --git a/tests/Integration/MatrixTicketIntegrationTest.php b/tests/Integration/Controller/MatrixTicketIntegrationTest.php similarity index 99% rename from tests/Integration/MatrixTicketIntegrationTest.php rename to tests/Integration/Controller/MatrixTicketIntegrationTest.php index 90a19ea..d711b48 100644 --- a/tests/Integration/MatrixTicketIntegrationTest.php +++ b/tests/Integration/Controller/MatrixTicketIntegrationTest.php @@ -9,7 +9,6 @@ use OCP\AppFramework\App; use OCP\IRequest; use PHPUnit\Framework\TestCase; - class MatrixTicketIntegrationTest extends TestCase { private $controller; private $mapper; diff --git a/tests/Integration/MatrixUserIntegrationTest.php b/tests/Integration/Controller/MatrixUserIntegrationTest.php similarity index 99% rename from tests/Integration/MatrixUserIntegrationTest.php rename to tests/Integration/Controller/MatrixUserIntegrationTest.php index e58e71b..b9eb829 100644 --- a/tests/Integration/MatrixUserIntegrationTest.php +++ b/tests/Integration/Controller/MatrixUserIntegrationTest.php @@ -8,7 +8,6 @@ use OCP\AppFramework\App; use OCP\IRequest; use PHPUnit\Framework\TestCase; - class MatrixUserIntegrationTest extends TestCase { private $mapper; private $userId = 'john'; diff --git a/tests/Unit/Controller/PageControllerTest.php b/tests/Unit/Controller/PageControllerTest.php index c8615cb..a820e7d 100644 --- a/tests/Unit/Controller/PageControllerTest.php +++ b/tests/Unit/Controller/PageControllerTest.php @@ -1,7 +1,8 @@ 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()); - } + }*/ } diff --git a/tests/Unit/Service/NoteServiceTest.php b/tests/Unit/Service/TicketServiceTest.php similarity index 91% rename from tests/Unit/Service/NoteServiceTest.php rename to tests/Unit/Service/TicketServiceTest.php index f7ea7fb..ea5edce 100644 --- a/tests/Unit/Service/NoteServiceTest.php +++ b/tests/Unit/Service/TicketServiceTest.php @@ -1,6 +1,6 @@ 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)) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 03184e3..a5b78cf 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,3 +1,20 @@ 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');