Skip to content

Commit

Permalink
Merge pull request #1117 from dr-matt-smith/main
Browse files Browse the repository at this point in the history
[make:crud] adding repository counts for crud testRemove
  • Loading branch information
jrushlow authored May 17, 2022
2 parents c35143f + ad218f3 commit 090f40b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Resources/skeleton/crud/test/Test.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public function testIndex(): void

public function testNew(): void
{
$originalNumObjectsInRepository = count($this->repository->findAll());

$this->markTestIncomplete();
$this->client->request('GET', sprintf('%snew', $this->path));

Expand All @@ -47,9 +49,9 @@ public function testNew(): void
<?php endforeach; ?>
]);

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

self::assertSame(1, $this->repository->count([]));
self::assertSame($originalNumObjectsInRepository + 1, count($this->repository->findAll()));
}

public function testShow(): void
Expand Down Expand Up @@ -100,17 +102,22 @@ public function testEdit(): void
public function testRemove(): void
{
$this->markTestIncomplete();

$originalNumObjectsInRepository = count($this->repository->findAll());

$fixture = new <?= $entity_class_name; ?>();
<?php foreach ($form_fields as $form_field => $typeOptions): ?>
$fixture->set<?= ucfirst($form_field); ?>('My Title');
<?php endforeach; ?>

$this->repository->add($fixture, true);

self::assertSame($originalNumObjectsInRepository + 1, count($this->repository->findAll()));

$this->client->request('GET', sprintf('%s%s', $this->path, $fixture->getId()));
$this->client->submitForm('Delete');

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

0 comments on commit 090f40b

Please sign in to comment.