From 432200f8c275e53082533aad7b18feb1078d797b Mon Sep 17 00:00:00 2001 From: jkindly Date: Thu, 1 Aug 2024 09:23:51 +0200 Subject: [PATCH] OP-461: PHPUnit repo test --- .../test_it_finds_template_by_name.yml | 10 ++++ .../Repository/TemplateRepositoryTest.php | 46 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 tests/Integration/DataFixtures/ORM/TemplateRepositoryTest/test_it_finds_template_by_name.yml create mode 100644 tests/Integration/Repository/TemplateRepositoryTest.php diff --git a/tests/Integration/DataFixtures/ORM/TemplateRepositoryTest/test_it_finds_template_by_name.yml b/tests/Integration/DataFixtures/ORM/TemplateRepositoryTest/test_it_finds_template_by_name.yml new file mode 100644 index 00000000..184c5df1 --- /dev/null +++ b/tests/Integration/DataFixtures/ORM/TemplateRepositoryTest/test_it_finds_template_by_name.yml @@ -0,0 +1,10 @@ +BitBag\SyliusCmsPlugin\Entity\Template: + template1: + name: 'template1-name' + type: 'page' + template2: + name: 'template2-name' + type: 'page' + template3: + name: 'template3-name' + type: 'page' diff --git a/tests/Integration/Repository/TemplateRepositoryTest.php b/tests/Integration/Repository/TemplateRepositoryTest.php new file mode 100644 index 00000000..5fc81abd --- /dev/null +++ b/tests/Integration/Repository/TemplateRepositoryTest.php @@ -0,0 +1,46 @@ +loadFixturesFromFile('TemplateRepositoryTest/test_it_finds_template_by_name.yml'); + + $repository = $this->getRepository(); + + $phrase = 'template'; + $type = 'page'; + $template = $repository->findTemplatesByNamePart($phrase, $type); + + self::assertIsArray($template); + self::assertCount(3, $template); + } + + private function getRepository(): TemplateRepositoryInterface + { + /** @var TemplateRepositoryInterface $repository */ + $repository = $this->getEntityManager()->getRepository(TemplateInterface::class); + + return $repository; + } +}