infinito/application/symfony/tests/Unit/Domain/SourceManagement/SourceMetaInformationTest.php

83 lines
2.6 KiB
PHP
Raw Normal View History

2018-11-23 13:22:45 +01:00
<?php
namespace Tests\Unit\Domain\SourceManagement;
use PHPUnit\Framework\TestCase;
use App\Entity\Source\Complex\UserSource;
use App\Entity\Source\Complex\UserSourceInterface;
use App\Entity\Source\SourceInterface;
use App\Domain\SourceManagement\SourceMetaInformation;
use App\Domain\SourceManagement\SourceMetaInformationInterface;
use App\Domain\TemplateManagement\TemplatePathFormAndViewInterface;
use App\Domain\FormManagement\FormMetaInformationInterface;
2018-11-23 13:22:45 +01:00
class SourceMetaInformationTest extends TestCase
2018-11-23 13:22:45 +01:00
{
/**
* @var SourceMetaInformationInterface
2018-11-23 13:22:45 +01:00
*/
protected $sourceMetaInformation;
2018-11-23 13:22:45 +01:00
/**
* @var SourceInterface
*/
protected $source;
public function setUp(): void
{
$this->source = new UserSource();
$this->sourceMetaInformation = new SourceMetaInformation($this->source);
2018-11-23 13:22:45 +01:00
}
public function testBasicName(): void
{
$this->assertEquals('user', $this->sourceMetaInformation->getPureName());
$this->assertNotEquals('user2', $this->sourceMetaInformation->getPureName());
2018-11-23 13:22:45 +01:00
}
public function testBasicPath(): void
{
2018-11-23 15:23:43 +01:00
$subset = ['source', 'complex'];
2018-11-23 13:22:45 +01:00
$amount = count($subset);
$basicPathArray = $this->sourceMetaInformation->getBasicPathArray();
2018-11-23 13:22:45 +01:00
for ($index = 0; $index < $amount; ++$index) {
$this->assertEquals($subset[$index], $basicPathArray[$index]);
}
$this->assertArraySubset($subset, $basicPathArray);
$this->assertEquals($amount, count($basicPathArray));
}
public function testInterfaceReflection(): void
{
/**
* @var \ReflectionClass
*/
$interfaceReflection = $this->sourceMetaInformation->getInterfaceReflection();
2018-11-23 13:22:45 +01:00
$this->assertEquals(UserSourceInterface::class, $interfaceReflection->getName());
}
public function testSourceReflection(): void
{
/**
* @var \ReflectionClass
*/
$sourceReflection = $this->sourceMetaInformation->getEntityReflection();
2018-11-23 13:22:45 +01:00
$this->assertEquals(UserSource::class, $sourceReflection->getName());
}
public function testTemplateMeta(): void
{
$this->assertInstanceOf(TemplatePathFormAndViewInterface::class, $this->sourceMetaInformation->getTemplatePathFormAndView());
2018-11-23 13:22:45 +01:00
}
public function testSource(): void
{
$this->assertEquals($this->source, $this->sourceMetaInformation->getEntity());
2018-11-23 13:22:45 +01:00
}
2018-11-23 16:50:37 +01:00
public function testFormMeta(): void
{
$this->assertInstanceOf(FormMetaInformationInterface::class, $this->sourceMetaInformation->getFormMetaInformation());
2018-11-23 16:50:37 +01:00
}
2018-11-23 13:22:45 +01:00
}