mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-09 22:17:26 +01:00
Implemented source data fixtures for guest user
This commit is contained in:
parent
8c082bb0a4
commit
8a5845daa9
@ -13,7 +13,10 @@ final class SystemSlugType extends AbstractEnumType
|
||||
{
|
||||
public const IMPRINT = 'IMPRINT';
|
||||
|
||||
public const GUEST_USER = 'GUEST_USER';
|
||||
|
||||
protected static $choices = [
|
||||
self::IMPRINT => 'imprint',
|
||||
self::GUEST_USER => 'guest user',
|
||||
];
|
||||
}
|
||||
|
@ -7,15 +7,21 @@ use Doctrine\Common\Persistence\ObjectManager;
|
||||
use App\Entity\Source\Primitive\Text\TextSource;
|
||||
use App\Entity\Source\Primitive\Text\TextSourceInterface;
|
||||
use App\DBAL\Types\SystemSlugType;
|
||||
use App\Entity\Source\Complex\UserSource;
|
||||
use App\Entity\Source\Complex\UserSourceInterface;
|
||||
|
||||
class SourceFixtures extends Fixture
|
||||
{
|
||||
public function load(ObjectManager $manager)
|
||||
{
|
||||
$manager->persist($this->getImpressum());
|
||||
$manager->persist($this->getGuestUser());
|
||||
$manager->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TextSourceInterface The example source for the impressum
|
||||
*/
|
||||
private function getImpressum(): TextSourceInterface
|
||||
{
|
||||
$source = new TextSource();
|
||||
@ -24,4 +30,15 @@ class SourceFixtures extends Fixture
|
||||
|
||||
return $source;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UserSourceInterface The UserSource which should be used for the anonymous user
|
||||
*/
|
||||
private function getGuestUser(): UserSourceInterface
|
||||
{
|
||||
$source = new UserSource();
|
||||
$source->setSlug(SystemSlugType::GUEST_USER);
|
||||
|
||||
return $source;
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Integration;
|
||||
namespace Tests\Integration\DataFixtures;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use App\Entity\Source\AbstractSource;
|
||||
use App\DBAL\Types\SystemSlugType;
|
||||
use App\Entity\Source\Primitive\Text\TextSourceInterface;
|
||||
use App\Entity\Source\Complex\UserSourceInterface;
|
||||
|
||||
class FixturesIntegrationTest extends KernelTestCase
|
||||
class SourceFixturesIntegrationTest extends KernelTestCase
|
||||
{
|
||||
/**
|
||||
* @var EntityManager
|
||||
@ -21,13 +21,17 @@ class FixturesIntegrationTest extends KernelTestCase
|
||||
$this->entityManager = static::$kernel->getContainer()->get('doctrine')->getManager();
|
||||
}
|
||||
|
||||
public function testImpressum(): void
|
||||
public function testImpressumSource(): void
|
||||
{
|
||||
$sourceRepository = $this->entityManager->getRepository(AbstractSource::class);
|
||||
/**
|
||||
* @var TextSourceInterface
|
||||
*/
|
||||
$imprint = $sourceRepository->findOneBy(['slug' => SystemSlugType::IMPRINT]);
|
||||
$this->assertInternalType('string', $imprint->getText());
|
||||
}
|
||||
|
||||
public function testGuestUserSource(): void
|
||||
{
|
||||
$sourceRepository = $this->entityManager->getRepository(AbstractSource::class);
|
||||
$userSource = $sourceRepository->findOneBy(['slug' => SystemSlugType::GUEST_USER]);
|
||||
$this->assertInstanceOf(UserSourceInterface::class, $userSource);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user