From 2eac7ad13b829a135088479bff741411f4ecc95f Mon Sep 17 00:00:00 2001 From: Matt Smith Date: Mon, 23 Sep 2024 12:28:54 +0100 Subject: [PATCH 1/2] name repository variable with entity prefix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use lower case first version of entity name to name repository variable in the test class e.g. if entity named “Product” then repository variable will be “productRepository” rather than just “repository” this makes copy-paste of setup code from other test classes simpler, when a related entity needs to be created for test cases --- .../skeleton/crud/test/Test.EntityManager.tpl.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Resources/skeleton/crud/test/Test.EntityManager.tpl.php b/src/Resources/skeleton/crud/test/Test.EntityManager.tpl.php index 36003d7e4..35d8cabdd 100644 --- a/src/Resources/skeleton/crud/test/Test.EntityManager.tpl.php +++ b/src/Resources/skeleton/crud/test/Test.EntityManager.tpl.php @@ -9,16 +9,16 @@ { private KernelBrowser $client; private EntityManagerInterface $manager; - private EntityRepository $repository; + private EntityRepository $Repository; private string $path = '/'; protected function setUp(): void { $this->client = static::createClient(); $this->manager = static::getContainer()->get('doctrine')->getManager(); - $this->repository = $this->manager->getRepository(::class); + $this->Repository = $this->manager->getRepository(::class); - foreach ($this->repository->findAll() as $object) { + foreach ($this->Repository>findAll() as $object) { $this->manager->remove($object); } @@ -52,7 +52,7 @@ public function testNew(): void self::assertResponseRedirects($this->path); - self::assertSame(1, $this->repository->count([])); + self::assertSame(1, $this->Repository>count([])); } public function testShow(): void @@ -95,7 +95,7 @@ public function testEdit(): void self::assertResponseRedirects('/'); - $fixture = $this->repository->findAll(); + $fixture = $this->Repository>findAll(); $typeOptions): ?> self::assertSame('Something New', $fixture[0]->get()); @@ -117,6 +117,6 @@ public function testRemove(): void $this->client->submitForm('Delete'); self::assertResponseRedirects('/'); - self::assertSame(0, $this->repository->count([])); + self::assertSame(0, $this->Repository>count([])); } } From 8e695dcc91c5e6a99e4d2749d1c6067c535982bc Mon Sep 17 00:00:00 2001 From: Jesse Rushlow Date: Fri, 27 Sep 2024 02:38:24 -0400 Subject: [PATCH 2/2] fix typo - missing '-' --- .../skeleton/crud/test/Test.EntityManager.tpl.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Resources/skeleton/crud/test/Test.EntityManager.tpl.php b/src/Resources/skeleton/crud/test/Test.EntityManager.tpl.php index 35d8cabdd..031a8cb6e 100644 --- a/src/Resources/skeleton/crud/test/Test.EntityManager.tpl.php +++ b/src/Resources/skeleton/crud/test/Test.EntityManager.tpl.php @@ -18,7 +18,7 @@ protected function setUp(): void $this->manager = static::getContainer()->get('doctrine')->getManager(); $this->Repository = $this->manager->getRepository(::class); - foreach ($this->Repository>findAll() as $object) { + foreach ($this->Repository->findAll() as $object) { $this->manager->remove($object); } @@ -52,7 +52,7 @@ public function testNew(): void self::assertResponseRedirects($this->path); - self::assertSame(1, $this->Repository>count([])); + self::assertSame(1, $this->Repository->count([])); } public function testShow(): void @@ -95,7 +95,7 @@ public function testEdit(): void self::assertResponseRedirects('/'); - $fixture = $this->Repository>findAll(); + $fixture = $this->Repository->findAll(); $typeOptions): ?> self::assertSame('Something New', $fixture[0]->get()); @@ -117,6 +117,6 @@ public function testRemove(): void $this->client->submitForm('Delete'); self::assertResponseRedirects('/'); - self::assertSame(0, $this->Repository>count([])); + self::assertSame(0, $this->Repository->count([])); } }