From 2d3100b5c944b865d54ad3563cf3b21ab553b39f Mon Sep 17 00:00:00 2001 From: Continuous Integration Date: Wed, 18 Dec 2024 23:38:27 +0000 Subject: [PATCH] Continuous Integration Fixes --- tests/Controller/FoodOrderControllerTest.php | 29 ++++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/tests/Controller/FoodOrderControllerTest.php b/tests/Controller/FoodOrderControllerTest.php index 1e46b47..3abd8a2 100644 --- a/tests/Controller/FoodOrderControllerTest.php +++ b/tests/Controller/FoodOrderControllerTest.php @@ -8,10 +8,13 @@ use App\Entity\MenuItem; use App\Entity\OrderItem; use App\Tests\DbWebTest; use Override; +use Symfony\Component\BrowserKit\Cookie; use Symfony\Component\DomCrawler\Crawler; +use function assert; use function range; use function sprintf; +use function str_ends_with; final class FoodOrderControllerTest extends DbWebTest { @@ -155,26 +158,26 @@ final class FoodOrderControllerTest extends DbWebTest 'nobody' ); if ($prevPage > 0) { - if ($prevPage === 1) { - $prevPage = ''; - } else { - $prevPage = "/{$prevPage}"; - } - - $node = $crawler->filter('a')->reduce(fn(Crawler $node, $i): bool => $node->text() === 'previous page')->first(); + $prevPage = $prevPage === 1 ? '' : "/{$prevPage}"; + $node = $crawler->filter('a') + ->reduce(static fn(Crawler $node, $i): bool => $node->text() === 'previous page') + ->first(); $target = $node->attr('href'); - $this->assertTrue(str_ends_with($target, $prevPage)); + $this->assertTrue(str_ends_with((string) $target, $prevPage)); } if ($prevPage > 3) { - $node = $crawler->filter('a')->reduce(fn(Crawler $node, $i): bool => $node->text() === 'next page')->first(); + $node = $crawler->filter('a') + ->reduce(static fn(Crawler $node, $i): bool => $node->text() === 'next page') + ->first(); $target = $node->attr('href'); - $this->assertTrue(str_ends_with($target, "/{$nextPage}")); + $this->assertTrue(str_ends_with((string) $target, "/{$nextPage}")); } } public function testNew(): void { - $this->client->getCookieJar()->set(new \Symfony\Component\BrowserKit\Cookie('username', 'Testing-1')); + $this->client->getCookieJar() + ->set(new Cookie('username', 'Testing-1')); $this->client->request('GET', sprintf('%snew', $this->path)); self::assertResponseStatusCodeSame(200); @@ -185,7 +188,9 @@ final class FoodOrderControllerTest extends DbWebTest self::assertResponseRedirects("{$this->path}list"); self::assertSame(1, $this->repository->count([])); - $order = $this->repository->findOneBy(['createdBy' => 'Testing-1']); + $order = $this->repository->findOneBy([ + 'createdBy' => 'Testing-1', + ]); assert($order instanceof FoodOrder); }