mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2024-12-04 23:17:19 +01:00
Optimized FixtureSources and menu
This commit is contained in:
parent
4280489499
commit
db2e4dac01
@ -21,7 +21,7 @@ final class DefaultController extends AbstractController
|
||||
public function homepage(): Response
|
||||
{
|
||||
return $this->redirectToRoute('infinito_api_rest_layer_read', [
|
||||
'identity' => HomepageFixtureSource::SLUG,
|
||||
'identity' => HomepageFixtureSource::getSlug(),
|
||||
'layer' => LayerType::SOURCE,
|
||||
'_format' => RESTResponseType::HTML,
|
||||
]);
|
||||
|
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Domain\FixtureManagement;
|
||||
|
||||
use Infinito\Entity\Meta\Right;
|
||||
use Infinito\DBAL\Types\Meta\Right\LayerType;
|
||||
use Infinito\DBAL\Types\ActionType;
|
||||
use Infinito\Entity\Source\SourceInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class EntityTemplateFactory extends Right
|
||||
{
|
||||
/**
|
||||
* @param SourceInterface $source
|
||||
*/
|
||||
public static function createStandartPublicRight(SourceInterface $source): Right
|
||||
{
|
||||
$right = new Right();
|
||||
$law = $source->getLaw();
|
||||
$right->setLaw($law);
|
||||
$law->getRights()->add($right);
|
||||
$right->setSource($source);
|
||||
$right->setLayer(LayerType::SOURCE);
|
||||
$right->setActionType(ActionType::READ);
|
||||
|
||||
return $right;
|
||||
}
|
||||
}
|
@ -9,4 +9,17 @@ namespace Infinito\Domain\FixtureManagement\FixtureSource;
|
||||
*/
|
||||
abstract class AbstractFixtureSource implements FixtureSourceInterface
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getSlug(): string
|
||||
{
|
||||
$className = get_called_class();
|
||||
$exploded = explode('\\', $className);
|
||||
$shortname = $exploded[count($exploded) - 1];
|
||||
$key = str_replace('FixtureSource', '', $shortname);
|
||||
$lower = strtolower($key);
|
||||
|
||||
return $lower;
|
||||
}
|
||||
}
|
||||
|
@ -23,4 +23,11 @@ interface FixtureSourceInterface
|
||||
* @return SlugAttributInterface
|
||||
*/
|
||||
public static function getSlug(): string;
|
||||
|
||||
/**
|
||||
* @see https://fontawesome.com
|
||||
*
|
||||
* @return string|null a fontawesome css class
|
||||
*/
|
||||
public static function getIcon(): string;
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ namespace Infinito\Domain\FixtureManagement\FixtureSource;
|
||||
|
||||
use Infinito\Entity\Source\SourceInterface;
|
||||
use Infinito\Entity\Source\Complex\UserSource;
|
||||
use Infinito\Domain\FixtureManagement\EntityTemplateFactory;
|
||||
|
||||
/**
|
||||
* This class containes the guest user.
|
||||
@ -12,8 +13,6 @@ use Infinito\Entity\Source\Complex\UserSource;
|
||||
*/
|
||||
final class GuestUserFixtureSource extends AbstractFixtureSource
|
||||
{
|
||||
const SLUG = 'GUEST_USER';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
@ -22,7 +21,8 @@ final class GuestUserFixtureSource extends AbstractFixtureSource
|
||||
public function getORMReadyObject(): SourceInterface
|
||||
{
|
||||
$userSource = new UserSource();
|
||||
$userSource->setSlug(self::SLUG);
|
||||
$userSource->setSlug(self::getSlug());
|
||||
EntityTemplateFactory::createStandartPublicRight($userSource);
|
||||
|
||||
return $userSource;
|
||||
}
|
||||
@ -30,8 +30,8 @@ final class GuestUserFixtureSource extends AbstractFixtureSource
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getSlug(): string
|
||||
public static function getIcon(): string
|
||||
{
|
||||
return self::SLUG;
|
||||
return 'fas fa-user';
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Domain\FixtureManagement\FixtureSource;
|
||||
|
||||
use Infinito\Entity\Source\SourceInterface;
|
||||
use Infinito\Entity\Source\Primitive\Text\TextSource;
|
||||
use Infinito\Domain\FixtureManagement\EntityTemplateFactory;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class HelpFixtureSource extends AbstractFixtureSource
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \Infinito\Domain\FixtureManagement\FixtureSource\FixtureSourceInterface::getORMReadyObject()
|
||||
*/
|
||||
public function getORMReadyObject(): SourceInterface
|
||||
{
|
||||
$helpSource = new TextSource();
|
||||
$helpSource->setText('See https://github.com/KevinFrantz/infinito/issues.');
|
||||
$helpSource->setSlug(self::getSlug());
|
||||
EntityTemplateFactory::createStandartPublicRight($helpSource);
|
||||
|
||||
return $helpSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getIcon(): string
|
||||
{
|
||||
return 'fas fa-question';
|
||||
}
|
||||
}
|
@ -4,20 +4,13 @@ namespace Infinito\Domain\FixtureManagement\FixtureSource;
|
||||
|
||||
use Infinito\Entity\Source\SourceInterface;
|
||||
use Infinito\Entity\Source\Primitive\Text\TextSource;
|
||||
use Infinito\Entity\Meta\Right;
|
||||
use Infinito\DBAL\Types\Meta\Right\LayerType;
|
||||
use Infinito\DBAL\Types\ActionType;
|
||||
use Infinito\Domain\FixtureManagement\EntityTemplateFactory;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class HomepageFixtureSource extends AbstractFixtureSource
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
const SLUG = 'HOMEPAGE';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
@ -25,24 +18,16 @@ final class HomepageFixtureSource extends AbstractFixtureSource
|
||||
*/
|
||||
public function getORMReadyObject(): SourceInterface
|
||||
{
|
||||
$impressumSource = new TextSource();
|
||||
$impressumSource->setText('Welcome to infinito!');
|
||||
$impressumSource->setSlug(self::SLUG);
|
||||
$right = new Right();
|
||||
$right->setSource($impressumSource);
|
||||
$right->setLayer(LayerType::SOURCE);
|
||||
$right->setActionType(ActionType::READ);
|
||||
$right->setLaw($impressumSource->getLaw());
|
||||
$impressumSource->getLaw()->getRights()->add($right);
|
||||
$homepage = new TextSource();
|
||||
$homepage->setText('Welcome to infinito!');
|
||||
$homepage->setSlug(self::getSlug());
|
||||
EntityTemplateFactory::createStandartPublicRight($homepage);
|
||||
|
||||
return $impressumSource;
|
||||
return $homepage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getSlug(): string
|
||||
public static function getIcon(): string
|
||||
{
|
||||
return self::SLUG;
|
||||
return 'fas fa-home';
|
||||
}
|
||||
}
|
||||
|
@ -4,17 +4,13 @@ namespace Infinito\Domain\FixtureManagement\FixtureSource;
|
||||
|
||||
use Infinito\Entity\Source\SourceInterface;
|
||||
use Infinito\Entity\Source\Primitive\Text\TextSource;
|
||||
use Infinito\Entity\Meta\Right;
|
||||
use Infinito\DBAL\Types\Meta\Right\LayerType;
|
||||
use Infinito\DBAL\Types\ActionType;
|
||||
use Infinito\Domain\FixtureManagement\EntityTemplateFactory;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class ImpressumFixtureSource extends AbstractFixtureSource
|
||||
{
|
||||
const SLUG = 'IMPRINT';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
@ -24,13 +20,8 @@ final class ImpressumFixtureSource extends AbstractFixtureSource
|
||||
{
|
||||
$impressumSource = new TextSource();
|
||||
$impressumSource->setText('Example Impressum');
|
||||
$impressumSource->setSlug(self::SLUG);
|
||||
$right = new Right();
|
||||
$right->setSource($impressumSource);
|
||||
$right->setLayer(LayerType::SOURCE);
|
||||
$right->setActionType(ActionType::READ);
|
||||
$right->setLaw($impressumSource->getLaw());
|
||||
$impressumSource->getLaw()->getRights()->add($right);
|
||||
$impressumSource->setSlug(self::getSlug());
|
||||
EntityTemplateFactory::createStandartPublicRight($impressumSource);
|
||||
|
||||
return $impressumSource;
|
||||
}
|
||||
@ -38,8 +29,8 @@ final class ImpressumFixtureSource extends AbstractFixtureSource
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getSlug(): string
|
||||
public static function getIcon(): string
|
||||
{
|
||||
return self::SLUG;
|
||||
return 'fas fa-address-card';
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Domain\FixtureManagement\FixtureSource;
|
||||
|
||||
use Infinito\Entity\Source\SourceInterface;
|
||||
use Infinito\Entity\Source\Primitive\Text\TextSource;
|
||||
use Infinito\Domain\FixtureManagement\EntityTemplateFactory;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class InformationFixtureSource extends AbstractFixtureSource
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \Infinito\Domain\FixtureManagement\FixtureSource\FixtureSourceInterface::getORMReadyObject()
|
||||
*/
|
||||
public function getORMReadyObject(): SourceInterface
|
||||
{
|
||||
$informationSource = new TextSource();
|
||||
$informationSource->setText('See https://github.com/KevinFrantz/infinito/issues.');
|
||||
$informationSource->setSlug(self::getSlug());
|
||||
EntityTemplateFactory::createStandartPublicRight($informationSource);
|
||||
|
||||
return $informationSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getIcon(): string
|
||||
{
|
||||
return 'fas fa-info';
|
||||
}
|
||||
}
|
@ -8,13 +8,12 @@ use Symfony\Component\Translation\TranslatorInterface;
|
||||
use Knp\Menu\ItemInterface;
|
||||
use Infinito\Event\Menu\MenuEvent;
|
||||
use Infinito\DBAL\Types\MenuEventType;
|
||||
use Infinito\Domain\FixtureManagement\FixtureSource\ImpressumFixtureSource;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
use Infinito\DBAL\Types\RESTResponseType;
|
||||
use Infinito\DBAL\Types\Meta\Right\LayerType;
|
||||
use Infinito\Controller\API\Rest\LayerController;
|
||||
use Infinito\Domain\FixtureManagement\FixtureSource\HomepageFixtureSource;
|
||||
use Infinito\Domain\FixtureManagement\FixtureSourceFactory;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@ -52,29 +51,22 @@ class UserMenuSubscriber extends AbstractEntityMenuSubscriber implements EventSu
|
||||
public function onUserMenuConfigure(MenuEvent $event): void
|
||||
{
|
||||
$menu = $event->getItem();
|
||||
$menu->addChild($this->trans('home'), [
|
||||
'route' => self::LAYER_GET_ROUTE,
|
||||
'routeParameters' => [
|
||||
'identity' => HomepageFixtureSource::getSlug(),
|
||||
'_format' => RESTResponseType::HTML,
|
||||
'layer' => LayerType::SOURCE,
|
||||
],
|
||||
'attributes' => [
|
||||
'icon' => 'fas fa-home',
|
||||
],
|
||||
]);
|
||||
|
||||
$menu->addChild($this->trans('imprint'), [
|
||||
'route' => self::LAYER_GET_ROUTE,
|
||||
'routeParameters' => [
|
||||
'identity' => ImpressumFixtureSource::getSlug(),
|
||||
'_format' => RESTResponseType::HTML,
|
||||
'layer' => LayerType::SOURCE,
|
||||
],
|
||||
'attributes' => [
|
||||
'icon' => 'fas fa-address-card',
|
||||
],
|
||||
]);
|
||||
$fixtureSources = FixtureSourceFactory::getAllFixtureSources();
|
||||
foreach ($fixtureSources as $fixtureSource) {
|
||||
$slug = $fixtureSource::getSlug();
|
||||
$icon = $fixtureSource::getIcon();
|
||||
$menu->addChild($this->trans($slug), [
|
||||
'route' => self::LAYER_GET_ROUTE,
|
||||
'routeParameters' => [
|
||||
'identity' => $slug,
|
||||
'_format' => RESTResponseType::HTML,
|
||||
'layer' => LayerType::SOURCE,
|
||||
],
|
||||
'attributes' => [
|
||||
'icon' => $icon,
|
||||
],
|
||||
]);
|
||||
}
|
||||
if ($this->shouldShowFormatSelection($event)) {
|
||||
$this->generateShowDropdown($menu, $event, self::LAYER_GET_ROUTE);
|
||||
}
|
||||
@ -169,7 +161,10 @@ class UserMenuSubscriber extends AbstractEntityMenuSubscriber implements EventSu
|
||||
*/
|
||||
private function shouldShowFormatSelection(Event $event): bool
|
||||
{
|
||||
foreach ([LayerController::IDENTITY_PARAMETER_KEY, LayerController::LAYER_PARAMETER_KEY] as $key) {
|
||||
foreach ([
|
||||
LayerController::IDENTITY_PARAMETER_KEY,
|
||||
LayerController::LAYER_PARAMETER_KEY,
|
||||
] as $key) {
|
||||
$attributs = $this->getRequestAttributs($event);
|
||||
if (!key_exists($key, $attributs) || '' === $attributs[$key]) {
|
||||
return false;
|
||||
|
@ -5,6 +5,7 @@ namespace Tests\Functional;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\Client;
|
||||
use Infinito\Domain\FixtureManagement\FixtureSource\HomepageFixtureSource;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@ -16,14 +17,25 @@ class FormatFunctionTest extends WebTestCase
|
||||
*/
|
||||
private $client;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $identity;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \PHPUnit\Framework\TestCase::setUp()
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->client = static::createClient();
|
||||
$this->identity = HomepageFixtureSource::getSlug();
|
||||
}
|
||||
|
||||
public function testHomepage(): void
|
||||
{
|
||||
$this->client->request(Request::METHOD_GET, 'api/rest/source/HOMEPAGE');
|
||||
$this->client->request(Request::METHOD_GET, 'api/rest/source/'.$this->identity);
|
||||
$this->assertEquals(200, $this->client->getResponse()
|
||||
->getStatusCode());
|
||||
$this->assertJson($this->client->getResponse()
|
||||
@ -32,7 +44,7 @@ class FormatFunctionTest extends WebTestCase
|
||||
|
||||
public function testHomepageWithHTML(): void
|
||||
{
|
||||
$this->client->request(Request::METHOD_GET, 'api/rest/source/HOMEPAGE.html');
|
||||
$this->client->request(Request::METHOD_GET, 'api/rest/source/'.$this->identity.'.html');
|
||||
$this->assertEquals(200, $this->client->getResponse()
|
||||
->getStatusCode());
|
||||
$this->assertContains('<html', $this->client->getResponse()
|
||||
@ -41,7 +53,7 @@ class FormatFunctionTest extends WebTestCase
|
||||
|
||||
public function testHomepageWithJSON(): void
|
||||
{
|
||||
$this->client->request(Request::METHOD_GET, 'api/rest/source/HOMEPAGE.json');
|
||||
$this->client->request(Request::METHOD_GET, 'api/rest/source/'.$this->identity.'.json');
|
||||
$this->assertEquals(200, $this->client->getResponse()
|
||||
->getStatusCode());
|
||||
$this->assertJson($this->client->getResponse()
|
||||
@ -50,7 +62,7 @@ class FormatFunctionTest extends WebTestCase
|
||||
|
||||
public function testHomepageWithXML(): void
|
||||
{
|
||||
$this->client->request(Request::METHOD_GET, 'api/rest/source/HOMEPAGE.xml');
|
||||
$this->client->request(Request::METHOD_GET, 'api/rest/source/'.$this->identity.'.xml');
|
||||
$this->assertEquals(200, $this->client->getResponse()
|
||||
->getStatusCode());
|
||||
$content = $this->client->getResponse()->getContent();
|
||||
|
@ -30,14 +30,14 @@ class SourceFixturesIntegrationTest extends KernelTestCase
|
||||
public function testImpressumSource(): void
|
||||
{
|
||||
$sourceRepository = $this->entityManager->getRepository(AbstractSource::class);
|
||||
$imprint = $sourceRepository->findOneBySlug(ImpressumFixtureSource::SLUG);
|
||||
$imprint = $sourceRepository->findOneBySlug(ImpressumFixtureSource::getSlug());
|
||||
$this->assertInternalType('string', $imprint->getText());
|
||||
}
|
||||
|
||||
public function testGuestUserSource(): void
|
||||
{
|
||||
$sourceRepository = $this->entityManager->getRepository(AbstractSource::class);
|
||||
$userSource = $sourceRepository->findOneBySlug(GuestUserFixtureSource::SLUG);
|
||||
$userSource = $sourceRepository->findOneBySlug(GuestUserFixtureSource::getSlug());
|
||||
$this->assertInstanceOf(UserSourceInterface::class, $userSource);
|
||||
}
|
||||
}
|
||||
|
@ -37,9 +37,9 @@ class ActionHandlerServiceIntegrationTest extends KernelTestCase
|
||||
$this->requestedActionService = self::$container->get(RequestedActionServiceInterface::class);
|
||||
}
|
||||
|
||||
public function testEnityManager(): void
|
||||
public function testEntityManager(): void
|
||||
{
|
||||
$this->requestedActionService->getRequestedEntity()->setSlug(ImpressumFixtureSource::SLUG);
|
||||
$this->requestedActionService->getRequestedEntity()->setSlug(ImpressumFixtureSource::getSlug());
|
||||
$this->requestedActionService->setActionType(ActionType::READ);
|
||||
$this->requestedActionService->setLayer(LayerType::SOURCE);
|
||||
$this->assertInstanceOf(SourceInterface::class, $this->actionHandlerService->handle());
|
||||
|
@ -4,6 +4,7 @@ namespace tests\Integration\Domain\FixtureManagement;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Infinito\Domain\FixtureManagement\FixtureSource\ImpressumFixtureSource;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@ -23,7 +24,7 @@ class ImprintFixtureSourceTest extends KernelTestCase
|
||||
public function testImprintSourceReachable(): void
|
||||
{
|
||||
$request = new Request([], [], [], [], [], [
|
||||
'REQUEST_URI' => 'api/rest/source/imprint.html',
|
||||
'REQUEST_URI' => 'api/rest/source/'.ImpressumFixtureSource::getSlug().'.html',
|
||||
]);
|
||||
$request->setMethod(Request::METHOD_GET);
|
||||
$response = static::$kernel->handle($request);
|
||||
|
@ -5,6 +5,7 @@ namespace Infinito\Tests\Unit\Controller;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
use Infinito\Controller\DefaultController;
|
||||
use Infinito\DBAL\Types\RESTResponseType;
|
||||
use Infinito\Domain\FixtureManagement\FixtureSource\ImpressumFixtureSource;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@ -34,7 +35,7 @@ class DefaultControllerTest extends WebTestCase
|
||||
$client = static::createClient();
|
||||
foreach (RESTResponseType::getValues() as $format) {
|
||||
$format = 'html';
|
||||
$url = '/api/rest/source/imprint.'.$format;
|
||||
$url = '/api/rest/source/'.ImpressumFixtureSource::getSlug().'.'.$format;
|
||||
$client->request('GET', $url);
|
||||
$this->assertEquals(200, $client->getResponse()
|
||||
->getStatusCode(), "Route $url is not reachable.");
|
||||
|
@ -1,13 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace tests\Unit\Domain\RequestManagement\Entity;
|
||||
namespace tests\Unit\Domain\RequestManagement\Right;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Infinito\Domain\RequestManagement\Right\RequestedRightInterface;
|
||||
use Infinito\Domain\RequestManagement\Right\RequestedRight;
|
||||
use Infinito\DBAL\Types\Meta\Right\LayerType;
|
||||
use Infinito\Domain\RequestManagement\Entity\RequestedEntity;
|
||||
use Infinito\DBAL\Types\SystemSlugType;
|
||||
use Infinito\Domain\RequestManagement\Entity\RequestedEntityInterface;
|
||||
use Infinito\Exception\PreconditionFailedException;
|
||||
use Infinito\Entity\Source\PureSource;
|
||||
@ -18,6 +17,7 @@ use Infinito\Entity\Meta\Law;
|
||||
use Infinito\Entity\Source\SourceInterface;
|
||||
use Infinito\DBAL\Types\ActionType;
|
||||
use Infinito\Exception\AllreadySetException;
|
||||
use Infinito\Domain\FixtureManagement\FixtureSource\ImpressumFixtureSource;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@ -66,7 +66,7 @@ class RequestedRightTest extends KernelTestCase
|
||||
public function testKnownSource(): void
|
||||
{
|
||||
$requestedEntity = new RequestedEntity($this->layerRepositoryFactoryService);
|
||||
$requestedEntity->setSlug(SystemSlugType::IMPRINT);
|
||||
$requestedEntity->setSlug(ImpressumFixtureSource::getSlug());
|
||||
$this->requestedRight->setRequestedEntity($requestedEntity);
|
||||
$this->requestedRight->setLayer(LayerType::SOURCE);
|
||||
$sourceResponse1 = $this->requestedRight->getSource();
|
||||
@ -78,7 +78,7 @@ class RequestedRightTest extends KernelTestCase
|
||||
|
||||
public function testEqualsSlug(): void
|
||||
{
|
||||
$slug = SystemSlugType::IMPRINT;
|
||||
$slug = ImpressumFixtureSource::getSlug();
|
||||
$requestedEntityEntity = new PureSource();
|
||||
$requestedEntity = $this->createMock(RequestedEntityInterface::class);
|
||||
$requestedEntity->method('getSlug')->willReturn($slug);
|
||||
|
@ -3,11 +3,11 @@
|
||||
namespace Tests\Unit\Domain\UserManagement;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Infinito\DBAL\Types\SystemSlugType;
|
||||
use Infinito\Entity\User;
|
||||
use Infinito\Domain\UserManagement\UserSourceDirector;
|
||||
use Infinito\Repository\Source\SourceRepository;
|
||||
use Infinito\Entity\Source\AbstractSource;
|
||||
use Infinito\Domain\FixtureManagement\FixtureSource\GuestUserFixtureSource;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@ -30,7 +30,7 @@ class UserSourceDirectorTest extends KernelTestCase
|
||||
$origineUser = null;
|
||||
$userIdentityManager = new UserSourceDirector($this->sourceRepository, $origineUser);
|
||||
$expectedUser = $userIdentityManager->getUser();
|
||||
$this->assertEquals(SystemSlugType::GUEST_USER, $expectedUser->getSource()->getSlug());
|
||||
$this->assertEquals(GuestUserFixtureSource::getSlug(), $expectedUser->getSource()->getSlug());
|
||||
}
|
||||
|
||||
public function testUser(): void
|
||||
|
@ -6,8 +6,8 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Infinito\Repository\Source\SourceRepositoryInterface;
|
||||
use Infinito\Entity\Source\AbstractSource;
|
||||
use Infinito\Domain\RequestManagement\Entity\RequestedEntityInterface;
|
||||
use Infinito\DBAL\Types\SystemSlugType;
|
||||
use Infinito\Entity\Source\SourceInterface;
|
||||
use Infinito\Domain\FixtureManagement\FixtureSource\ImpressumFixtureSource;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@ -32,7 +32,7 @@ class SourceRepositoryTest extends KernelTestCase
|
||||
{
|
||||
$requestedSource = $this->createMock(RequestedEntityInterface::class);
|
||||
$requestedSource->method('hasSlug')->willReturn(true);
|
||||
$requestedSource->method('getSlug')->willReturn(SystemSlugType::IMPRINT);
|
||||
$requestedSource->method('getSlug')->willReturn(ImpressumFixtureSource::getSlug());
|
||||
$imprint = $this->sourceRepository->findOneByIdOrSlug($requestedSource);
|
||||
$this->assertInstanceOf(SourceInterface::class, $imprint);
|
||||
$requestedSource2 = $this->createMock(RequestedEntityInterface::class);
|
||||
@ -44,7 +44,7 @@ class SourceRepositoryTest extends KernelTestCase
|
||||
|
||||
public function testLoadBySlug(): void
|
||||
{
|
||||
$imprint = $this->sourceRepository->findOneBySlug(SystemSlugType::IMPRINT);
|
||||
$imprint = $this->sourceRepository->findOneBySlug(ImpressumFixtureSource::getSlug());
|
||||
$this->assertInstanceOf(SourceInterface::class, $imprint);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user