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');