diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4ba9339..849914b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php: ['8.1', '8.2'] + php: ['8.1', '8.2', '8.3', '8.4'] symfony: ['4.4.*', '5.4.*', '6.1.*', '6.2.*'] steps: @@ -44,7 +44,7 @@ jobs: strategy: max-parallel: 10 matrix: - php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2'] + php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] steps: - name: Set up PHP diff --git a/Makefile b/Makefile index 14c1583..2cd3cd2 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,12 @@ test-php81: test-php82: docker run --rm -v $(DIR):/project -w /project webdevops/php:8.2 make test +test-php83: + docker run --rm -v $(DIR):/project -w /project webdevops/php:8.3 make test + +test-php84: + docker run --rm -v $(DIR):/project -w /project webdevops/php:8.4 make test + test: composer update --prefer-dist --no-interaction ${COMPOSER_PARAMS} composer test diff --git a/src/BreadcrumbTrail/Trail.php b/src/BreadcrumbTrail/Trail.php index 9a28223..6c737d4 100644 --- a/src/BreadcrumbTrail/Trail.php +++ b/src/BreadcrumbTrail/Trail.php @@ -104,6 +104,10 @@ public function add($breadcrumbOrTitle, $routeName = null, $routeParameters = [] } foreach ($routeParameters as $key => $parameterValue) { + if ($parameterValue === null) { + continue; + } + if (is_numeric($key)) { $routeParameters[$parameterValue] = $request->get($parameterValue); unset($routeParameters[$key]); diff --git a/tests/BreadcrumbTrail/TrailTest.php b/tests/BreadcrumbTrail/TrailTest.php index 5f24e87..796585c 100644 --- a/tests/BreadcrumbTrail/TrailTest.php +++ b/tests/BreadcrumbTrail/TrailTest.php @@ -29,6 +29,31 @@ public function testRenderSimpleValueObjectValueInBreadcrumbTitle() $breadcrumb = $iterator->current(); self::assertEquals($expected, $breadcrumb->title); } + + public function testAddWithNullRouteParameter() + { + $router = $this->createMock(UrlGeneratorInterface::class); + $routeName = 'route_name'; + $router + ->expects(self::once()) + ->method('generate') + ->with($routeName, ['id' => null], UrlGeneratorInterface::ABSOLUTE_URL) + ->willReturn('https://example.test/page'); + $requestStack = new RequestStack(); + $requestStack->push(new Request()); + + $trail = new Trail($router, $requestStack); + $title = 'Title'; + $trail->add($title, $routeName, ['id' => null]); + + $iterator = $trail->getIterator(); + self::assertCount(1, $iterator); + + /** @var Breadcrumb $breadcrumb */ + $breadcrumb = $iterator->current(); + self::assertSame($title, $breadcrumb->title); + self::assertSame('https://example.test/page', $breadcrumb->url); + } } final class User