diff --git a/application/src/DBAL/Types/SystemSlugType.php b/application/src/DBAL/Types/SystemSlugType.php new file mode 100644 index 0000000..d7fc1f1 --- /dev/null +++ b/application/src/DBAL/Types/SystemSlugType.php @@ -0,0 +1,19 @@ + 'imprint', + ]; +} diff --git a/application/src/DataFixtures/DummyFixtures.php b/application/src/DataFixtures/DummyFixtures.php index 47b4f66..6ba3e04 100644 --- a/application/src/DataFixtures/DummyFixtures.php +++ b/application/src/DataFixtures/DummyFixtures.php @@ -6,21 +6,31 @@ use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Common\Persistence\ObjectManager; use App\Entity\User; use FOS\UserBundle\Doctrine\UserManager; +use App\Entity\UserInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\DependencyInjection\ContainerAwareInterface; /** * Never execute this fixture on a livesystem! * * @author kevinfrantz */ -class DummyFixtures extends Fixture +class DummyFixtures extends Fixture implements ContainerAwareInterface { + private $container; + + public function setContainer(ContainerInterface $container = null) + { + $this->container = $container; + } + public function load(ObjectManager $manager) { - $this->addTestUser(); + $manager->persist($this->getTestUser()); $manager->flush(); } - protected function addTestUser(): void + protected function getTestUser(): UserInterface { /** * @var UserManager @@ -35,5 +45,7 @@ class DummyFixtures extends Fixture $testUser->setPlainPassword('test'); $testUser->setEnabled(true); $userManager->updateUser($testUser); + + return $testUser; } } diff --git a/application/src/DataFixtures/SourceFixtures.php b/application/src/DataFixtures/SourceFixtures.php new file mode 100644 index 0000000..86be2c9 --- /dev/null +++ b/application/src/DataFixtures/SourceFixtures.php @@ -0,0 +1,27 @@ +persist($this->getImpressum()); + $manager->flush(); + } + + private function getImpressum(): TextSourceInterface + { + $source = new TextSource(); + $source->setText('Example Impressum'); + $source->setSlug(SystemSlugType::IMPRINT); + + return $source; + } +} diff --git a/application/tests/Integration/FixturesIntegrationTest.php b/application/tests/Integration/FixturesIntegrationTest.php new file mode 100644 index 0000000..da258de --- /dev/null +++ b/application/tests/Integration/FixturesIntegrationTest.php @@ -0,0 +1,33 @@ +entityManager = static::$kernel->getContainer()->get('doctrine')->getManager(); + } + + public function testImpressum(): void + { + $sourceRepository = $this->entityManager->getRepository(AbstractSource::class); + /** + * @var TextSourceInterface + */ + $imprint = $sourceRepository->findOneBy(['slug' => SystemSlugType::IMPRINT]); + $this->assertInternalType('string', $imprint->getText()); + } +}