mirror of
				https://github.com/kevinveenbirkenbach/infinito.git
				synced 2025-11-03 18:58:01 +00:00 
			
		
		
		
	Optimized FixtureSources and menu
This commit is contained in:
		@@ -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);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user