mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 13:57:10 +02:00
Renamed domain FixtureManagement to Fixture
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace tests\Integration\Domain\Fixture;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Infinito\Entity\Source\AbstractSource;
|
||||
use Infinito\Domain\Fixture\EntityTemplateFactory;
|
||||
use Infinito\Entity\Source\Complex\UserSource;
|
||||
use Infinito\Entity\Meta\Right;
|
||||
use Infinito\DBAL\Types\Meta\Right\LayerType;
|
||||
use Infinito\DBAL\Types\ActionType;
|
||||
use Infinito\Domain\LawManagement\LawPermissionChecker;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class EntityTemplateFactoryIntegrationTest extends TestCase
|
||||
{
|
||||
public function testStandartPublicRights(): void
|
||||
{
|
||||
$allowedActions = [ActionType::READ, ActionType::EXECUTE];
|
||||
$allowedLayers = [LayerType::SOURCE];
|
||||
$source = new class() extends AbstractSource {
|
||||
};
|
||||
$law = $source->getLaw();
|
||||
$anonymUserSource = new UserSource();
|
||||
EntityTemplateFactory::createStandartPublicRights($source);
|
||||
$requestedRight = new Right();
|
||||
$requestedRight->setReciever($anonymUserSource);
|
||||
$lawPermissionChecker = new LawPermissionChecker($law);
|
||||
foreach (LayerType::getValues() as $layerType) {
|
||||
foreach (ActionType::getValues() as $actionType) {
|
||||
$requestedRight->setActionType($actionType);
|
||||
$requestedRight->setLayer($layerType);
|
||||
$checkResult = $lawPermissionChecker->hasPermission($requestedRight);
|
||||
if (in_array($actionType, $allowedActions) && in_array($layerType, $allowedLayers)) {
|
||||
$this->assertTrue($checkResult);
|
||||
} else {
|
||||
$this->assertFalse($checkResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace tests\Integration\Domain\Fixture;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Infinito\Domain\Fixture\FixtureSourceFactory;
|
||||
use Infinito\Domain\Fixture\FixtureSource\FixtureSourceInterface;
|
||||
use Infinito\Entity\Source\SourceInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class FixtureSourceFactoryIntegrationTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var array|FixtureSourceInterface[]
|
||||
*/
|
||||
protected $fixtureSources;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \PHPUnit\Framework\TestCase::setUp()
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->fixtureSources = FixtureSourceFactory::getAllFixtureSources();
|
||||
}
|
||||
|
||||
public function testFixtureSourcesSlugs(): void
|
||||
{
|
||||
$slugs = [];
|
||||
foreach ($this->fixtureSources as $fixtureSource) {
|
||||
$this->assertInstanceOf(FixtureSourceInterface::class, $fixtureSource);
|
||||
$slug = $fixtureSource->getSlug();
|
||||
$this->assertIsString($slug);
|
||||
$this->assertFalse(in_array($slug, $slugs), 'A slug has to be unique');
|
||||
$slugs[] = $slug;
|
||||
}
|
||||
}
|
||||
|
||||
public function testFixtureSourcesIcons(): void
|
||||
{
|
||||
$icons = [];
|
||||
foreach ($this->fixtureSources as $fixtureSource) {
|
||||
$this->assertInstanceOf(FixtureSourceInterface::class, $fixtureSource);
|
||||
$icon = $fixtureSource->getIcon();
|
||||
$this->assertIsString($icon);
|
||||
$this->assertFalse(in_array($icon, $icons), 'An icon has to be unique');
|
||||
$icons[] = $icon;
|
||||
}
|
||||
}
|
||||
|
||||
public function testFixtureSourceNames(): void
|
||||
{
|
||||
$names = [];
|
||||
foreach ($this->fixtureSources as $fixtureSource) {
|
||||
$this->assertInstanceOf(FixtureSourceInterface::class, $fixtureSource);
|
||||
$name = $fixtureSource->getName();
|
||||
$this->assertIsString($name);
|
||||
$this->assertFalse(in_array($name, $names), 'An name has to be unique');
|
||||
$names[] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The following test is redundant.
|
||||
*/
|
||||
public function testFixtureSourcesObjects(): void
|
||||
{
|
||||
$objects = [];
|
||||
foreach ($this->fixtureSources as $fixtureSource) {
|
||||
$this->assertInstanceOf(SourceInterface::class, $fixtureSource->getORMReadyObject());
|
||||
$this->assertFalse(in_array($fixtureSource, $objects), 'A object has to be unique');
|
||||
$objects[] = $fixtureSource;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace tests\Integration\Domain\Fixture;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Infinito\Domain\Fixture\FixtureSource\ImpressumFixtureSource;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class ImprintFixtureSourceIntegrationTest extends KernelTestCase
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \PHPUnit\Framework\TestCase::setUp()
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
self::bootKernel();
|
||||
}
|
||||
|
||||
public function testImprintSourceReachable(): void
|
||||
{
|
||||
$request = new Request([], [], [], [], [], [
|
||||
'REQUEST_URI' => 'api/rest/source/'.ImpressumFixtureSource::getSlug().'.html',
|
||||
]);
|
||||
$request->setMethod(Request::METHOD_GET);
|
||||
$response = static::$kernel->handle($request);
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user