diff --git a/core/Test/HistoryControllerTest.php b/core/Test/HistoryControllerTest.php new file mode 100755 index 0000000000000000000000000000000000000000..5037ea3979d53763da9a8602e8c50ba24a586028 --- /dev/null +++ b/core/Test/HistoryControllerTest.php @@ -0,0 +1,55 @@ +<?php + +/** +* Copyright Maarch since 2008 under licence GPLv3. +* See LICENCE.txt file at the root folder for more details. +* This file is part of Maarch software. +* +*/ + +use PHPUnit\Framework\TestCase; + +class HistoryControllerTest extends TestCase +{ + public function testGetHistoryByUserId() + { + $environment = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'GET']); + $request = \Slim\Http\Request::createFromEnvironment($environment); + $history = new \History\controllers\HistoryController(); + + $response = $history->getByUserId($request, new \Slim\Http\Response(), ['userSerialId' => 1]); + + $responseBody = json_decode((string)$response->getBody()); + + $this->assertNotNull($responseBody->histories); + } + + public function testGetHistory() + { + $environment = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'GET']); + $request = \Slim\Http\Request::createFromEnvironment($environment); + $history = new \History\controllers\HistoryController(); + + $response = $history->get($request, new \Slim\Http\Response(), ['date' => '2018-01-02']); + + $responseBody = json_decode((string)$response->getBody()); + + $this->assertNotNull($responseBody->filters->users); + $this->assertNotNull($responseBody->filters->eventType); + $this->assertNotNull($responseBody->historyList); + } + + public function testGetHistoryBatch() + { + $environment = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'GET']); + $request = \Slim\Http\Request::createFromEnvironment($environment); + $historyBatch = new \History\controllers\HistoryBatchController(); + + $response = $historyBatch->get($request, new \Slim\Http\Response(), ['date' => '2018-01-02']); + + $responseBody = json_decode((string)$response->getBody()); + + $this->assertNotNull($responseBody->filters->modules); + $this->assertNotNull($responseBody->historyList); + } +} diff --git a/phpunit.xml b/phpunit.xml index a3540525d8e35f67a30cd58f174bafd5290d0565..c008de4e66c1813d24b45002ac148351fac02f26 100755 --- a/phpunit.xml +++ b/phpunit.xml @@ -6,9 +6,9 @@ <file>core/Test/ActionControllerTest.php</file> <file>core/Test/BasketControllerTest.php</file> <file>core/Test/ContactControllerTest.php</file> + <file>core/Test/DoctypeControllerTest.php</file> <file>core/Test/EntityControllerTest.php</file> <file>core/Test/ListTemplateControllerTest.php</file> - <file>core/Test/DoctypeControllerTest.php</file> <file>core/Test/NotificationControllerTest.php</file> <file>core/Test/NotificationScheduleControllerTest.php</file> <file>core/Test/ParameterControllerTest.php</file> @@ -21,6 +21,8 @@ <file>modules/convert/Test/ProcessFulltextTest.php</file> <file>modules/convert/Test/ProcessManageConvertTest.php</file> <file>modules/convert/Test/ProcessThumbnailsTest.php</file> + <!-- The last one should be history --> + <file>core/Test/HistoryControllerTest.php</file> </testsuite> </testsuites> <filter> diff --git a/src/app/history/controllers/HistoryBatchController.php b/src/app/history/controllers/HistoryBatchController.php index 7c1e488da48964770908e52daf491ff1a2fb307a..5e37cc736be7c6e51fad56d681c359432bf02f5e 100644 --- a/src/app/history/controllers/HistoryBatchController.php +++ b/src/app/history/controllers/HistoryBatchController.php @@ -14,7 +14,7 @@ namespace History\controllers; -use Core\Models\ServiceModel; +use Group\models\ServiceModel; use History\models\HistoryBatchModel; use Slim\Http\Request; use Slim\Http\Response;