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] adding repository counts for crud testRemove #1117

Merged
merged 5 commits into from
May 17, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
/tests/tmp/*
/tools/*/composer.lock
/tools/*/vendor
/vendor/
/vendor/
jrushlow marked this conversation as resolved.
Show resolved Hide resolved
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([]));
}
}