From 6229905e9955ba95f25db78503b6fe0606fdbd1d Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Thu, 8 Oct 2020 15:12:24 +0200 Subject: [PATCH] fix tests and replace file_exists --- tests/Controller/ApiControllerTest.php | 23 ++++++++++++++++++ tests/Models/EditorDocTest.php | 32 ++++++++++++++++++++++++++ tests/Models/NullEditorDocTest.php | 8 +++++++ 3 files changed, 63 insertions(+) diff --git a/tests/Controller/ApiControllerTest.php b/tests/Controller/ApiControllerTest.php index 90ff203..5ee0c30 100755 --- a/tests/Controller/ApiControllerTest.php +++ b/tests/Controller/ApiControllerTest.php @@ -44,6 +44,9 @@ class ApiControllerTest extends \PHPUnit\Framework\TestCase { protected ApplicationAbstract $app; + /** + * @var \Modules\Editor\Controller\ApiController + */ protected ApiController $module; protected function setUp() : void @@ -106,6 +109,10 @@ class ApiControllerTest extends \PHPUnit\Framework\TestCase self::assertGreaterThan(0, $response->get('')['response']->getId()); } + /** + * @covers Modules\Editor\Controller\ApiController + * @group module + */ public function testCreateEditorDocWithExistingTag() : void { $tag = new Tag(); @@ -126,6 +133,10 @@ class ApiControllerTest extends \PHPUnit\Framework\TestCase self::assertGreaterThan(0, $response->get('')['response']->getId()); } + /** + * @covers Modules\Editor\Controller\ApiController + * @group module + */ public function testInvalidEditorDocCreateRequest() : void { $response = new HttpResponse(); @@ -139,6 +150,10 @@ class ApiControllerTest extends \PHPUnit\Framework\TestCase self::assertEquals(RequestStatusCode::R_400, $response->getHeader()->getStatusCode()); } + /** + * @covers Modules\Editor\Controller\ApiController + * @group module + */ public function testUpdateEditorDoc() : void { $response = new HttpResponse(); @@ -155,6 +170,10 @@ class ApiControllerTest extends \PHPUnit\Framework\TestCase self::assertEquals(1, $response->get('')['response']->getId()); } + /** + * @covers Modules\Editor\Controller\ApiController + * @group module + */ public function testGetEditorDoc() : void { $response = new HttpResponse(); @@ -168,6 +187,10 @@ class ApiControllerTest extends \PHPUnit\Framework\TestCase self::assertEquals('Changed Title', $response->get('')['response']->getTitle()); } + /** + * @covers Modules\Editor\Controller\ApiController + * @group module + */ public function testDeleteEditorDoc() : void { $doc = new EditorDoc(); diff --git a/tests/Models/EditorDocTest.php b/tests/Models/EditorDocTest.php index 38dabf4..067900b 100755 --- a/tests/Models/EditorDocTest.php +++ b/tests/Models/EditorDocTest.php @@ -30,6 +30,10 @@ class EditorDocTest extends \PHPUnit\Framework\TestCase $this->doc = new EditorDoc(); } + /** + * @covers Modules\Editor\Models\EditorDoc + * @group module + */ public function testDefault() : void { self::assertEquals(0, $this->doc->getId()); @@ -41,36 +45,60 @@ class EditorDocTest extends \PHPUnit\Framework\TestCase self::assertEquals((new \DateTime('now'))->format('Y-m-d'), $this->doc->getCreatedAt()->format('Y-m-d')); } + /** + * @covers Modules\Editor\Models\EditorDoc + * @group module + */ public function testCreatedByInputOutput() : void { $this->doc->setCreatedBy(new NullAccount(1)); self::assertEquals(1, $this->doc->getCreatedBy()->getId()); } + /** + * @covers Modules\Editor\Models\EditorDoc + * @group module + */ public function testTitleInputOutput() : void { $this->doc->setTitle('Title'); self::assertEquals('Title', $this->doc->getTitle()); } + /** + * @covers Modules\Editor\Models\EditorDoc + * @group module + */ public function testContentInputOutput() : void { $this->doc->setContent('Content'); self::assertEquals('Content', $this->doc->getContent()); } + /** + * @covers Modules\Editor\Models\EditorDoc + * @group module + */ public function testPlainInputOutput() : void { $this->doc->setPlain('Plain'); self::assertEquals('Plain', $this->doc->getPlain()); } + /** + * @covers Modules\Editor\Models\EditorDoc + * @group module + */ public function testPathInputOutput() : void { $this->doc->setPath('/some/test/path'); self::assertEquals('/some/test/path', $this->doc->getPath()); } + /** + * @covers Modules\Editor\Models\EditorDoc + * @group module + */ public function testTagInputOutput() : void { $tag = new Tag(); @@ -80,6 +108,10 @@ class EditorDocTest extends \PHPUnit\Framework\TestCase self::assertCount(1, $this->doc->getTags()); } + /** + * @covers Modules\Editor\Models\EditorDoc + * @group module + */ public function testSerialization() : void { $this->doc->setCreatedBy(new NullAccount(1)); diff --git a/tests/Models/NullEditorDocTest.php b/tests/Models/NullEditorDocTest.php index e179601..3303b67 100644 --- a/tests/Models/NullEditorDocTest.php +++ b/tests/Models/NullEditorDocTest.php @@ -21,11 +21,19 @@ use Modules\Editor\Models\NullEditorDoc; */ final class NullEditorDocTest extends \PHPUnit\Framework\TestCase { + /** + * @covers Modules\Editor\Models\NullEditorDoc + * @group module + */ public function testNull() : void { self::assertInstanceOf('\Modules\Editor\Models\EditorDoc', new NullEditorDoc()); } + /** + * @covers Modules\Editor\Models\NullEditorDoc + * @group module + */ public function testId() : void { $null = new NullEditorDoc(2);