Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/BreadcrumbTrail/Trail.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@
}

foreach ($routeParameters as $key => $parameterValue) {
if ($parameterValue === null) {
continue;
}

if (is_numeric($key)) {
$routeParameters[$parameterValue] = $request->get($parameterValue);
unset($routeParameters[$key]);
Expand Down Expand Up @@ -137,7 +141,7 @@
$breadcrumb = new Breadcrumb($breadcrumbOrTitle, $url, $attributes);
}

if (!\is_int($position)) {

Check failure on line 144 in src/BreadcrumbTrail/Trail.php

View workflow job for this annotation

GitHub Actions / Static code analysis

Call to function is_int() with int will always evaluate to true.
throw new \InvalidArgumentException('The position of a breadcrumb must be an integer.');
}

Expand Down
25 changes: 25 additions & 0 deletions tests/BreadcrumbTrail/TrailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading