fix tests and replace file_exists

This commit is contained in:
Dennis Eichhorn 2020-10-08 15:12:24 +02:00
parent b48502a604
commit 6229905e99
3 changed files with 63 additions and 0 deletions

View File

@ -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();

View File

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

View File

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