Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[make:crud] name repository variable with entity prefix when generating tests #1597

Merged
merged 2 commits into from
Sep 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/Resources/skeleton/crud/test/Test.EntityManager.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
{
private KernelBrowser $client;
private EntityManagerInterface $manager;
private EntityRepository $repository;
private EntityRepository $<?= lcfirst($entity_var_singular); ?>Repository;
private string $path = '<?= $route_path; ?>/';

protected function setUp(): void
{
$this->client = static::createClient();
$this->manager = static::getContainer()->get('doctrine')->getManager();
$this->repository = $this->manager->getRepository(<?= $entity_class_name; ?>::class);
$this-><?= lcfirst($entity_var_singular); ?>Repository = $this->manager->getRepository(<?= $entity_class_name; ?>::class);

foreach ($this->repository->findAll() as $object) {
foreach ($this-><?= lcfirst($entity_var_singular); ?>Repository->findAll() as $object) {
$this->manager->remove($object);
}

Expand Down Expand Up @@ -52,7 +52,7 @@ public function testNew(): void

self::assertResponseRedirects($this->path);

self::assertSame(1, $this->repository->count([]));
self::assertSame(1, $this-><?= lcfirst($entity_var_singular); ?>Repository->count([]));
}

public function testShow(): void
Expand Down Expand Up @@ -95,7 +95,7 @@ public function testEdit(): void

self::assertResponseRedirects('<?= $route_path; ?>/');

$fixture = $this->repository->findAll();
$fixture = $this-><?= lcfirst($entity_var_singular); ?>Repository->findAll();

<?php foreach ($form_fields as $form_field => $typeOptions): ?>
self::assertSame('Something New', $fixture[0]->get<?= ucfirst($form_field); ?>());
Expand All @@ -117,6 +117,6 @@ public function testRemove(): void
$this->client->submitForm('Delete');

self::assertResponseRedirects('<?= $route_path; ?>/');
self::assertSame(0, $this->repository->count([]));
self::assertSame(0, $this-><?= lcfirst($entity_var_singular); ?>Repository->count([]));
}
}
Loading