Compare commits
No commits in common. "2d3100b5c944b865d54ad3563cf3b21ab553b39f" and "a974688872bd038b1de7e946b08205367260ddbd" have entirely different histories.
2d3100b5c9
...
a974688872
1 changed files with 16 additions and 28 deletions
|
@ -8,13 +8,10 @@ use App\Entity\MenuItem;
|
||||||
use App\Entity\OrderItem;
|
use App\Entity\OrderItem;
|
||||||
use App\Tests\DbWebTest;
|
use App\Tests\DbWebTest;
|
||||||
use Override;
|
use Override;
|
||||||
use Symfony\Component\BrowserKit\Cookie;
|
|
||||||
use Symfony\Component\DomCrawler\Crawler;
|
use Symfony\Component\DomCrawler\Crawler;
|
||||||
|
|
||||||
use function assert;
|
|
||||||
use function range;
|
use function range;
|
||||||
use function sprintf;
|
use function sprintf;
|
||||||
use function str_ends_with;
|
|
||||||
|
|
||||||
final class FoodOrderControllerTest extends DbWebTest
|
final class FoodOrderControllerTest extends DbWebTest
|
||||||
{
|
{
|
||||||
|
@ -140,10 +137,10 @@ final class FoodOrderControllerTest extends DbWebTest
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testWith [1, 0, 2]
|
* @testWith [1, 0, 1]
|
||||||
* [2, 1, 3]
|
* [2, 1, 1]
|
||||||
* [3, 2, 4]
|
* [3, 1, 1]
|
||||||
* [4, 3, 0, 5]
|
* [4, 1, 0, 5]
|
||||||
*/
|
*/
|
||||||
public function testPaginatedFirstPage(int $page, int $prevPage, int $nextPage, int $items = 10): void
|
public function testPaginatedFirstPage(int $page, int $prevPage, int $nextPage, int $items = 10): void
|
||||||
{
|
{
|
||||||
|
@ -157,27 +154,22 @@ final class FoodOrderControllerTest extends DbWebTest
|
||||||
$items,
|
$items,
|
||||||
'nobody'
|
'nobody'
|
||||||
);
|
);
|
||||||
if ($prevPage > 0) {
|
$this->assertElementContainsCount(
|
||||||
$prevPage = $prevPage === 1 ? '' : "/{$prevPage}";
|
$crawler,
|
||||||
$node = $crawler->filter('a')
|
'a',
|
||||||
->reduce(static fn(Crawler $node, $i): bool => $node->text() === 'previous page')
|
$nextPage,
|
||||||
->first();
|
'next page'
|
||||||
$target = $node->attr('href');
|
);
|
||||||
$this->assertTrue(str_ends_with((string) $target, $prevPage));
|
$this->assertElementContainsCount(
|
||||||
}
|
$crawler,
|
||||||
if ($prevPage > 3) {
|
'a',
|
||||||
$node = $crawler->filter('a')
|
$prevPage,
|
||||||
->reduce(static fn(Crawler $node, $i): bool => $node->text() === 'next page')
|
'previous page'
|
||||||
->first();
|
);
|
||||||
$target = $node->attr('href');
|
|
||||||
$this->assertTrue(str_ends_with((string) $target, "/{$nextPage}"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNew(): void
|
public function testNew(): void
|
||||||
{
|
{
|
||||||
$this->client->getCookieJar()
|
|
||||||
->set(new Cookie('username', 'Testing-1'));
|
|
||||||
$this->client->request('GET', sprintf('%snew', $this->path));
|
$this->client->request('GET', sprintf('%snew', $this->path));
|
||||||
|
|
||||||
self::assertResponseStatusCodeSame(200);
|
self::assertResponseStatusCodeSame(200);
|
||||||
|
@ -188,10 +180,6 @@ final class FoodOrderControllerTest extends DbWebTest
|
||||||
|
|
||||||
self::assertResponseRedirects("{$this->path}list");
|
self::assertResponseRedirects("{$this->path}list");
|
||||||
self::assertSame(1, $this->repository->count([]));
|
self::assertSame(1, $this->repository->count([]));
|
||||||
$order = $this->repository->findOneBy([
|
|
||||||
'createdBy' => 'Testing-1',
|
|
||||||
]);
|
|
||||||
assert($order instanceof FoodOrder);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testOpen(): void
|
public function testOpen(): void
|
||||||
|
|
Loading…
Add table
Reference in a new issue