Skip to content

Commit 8061bfd

Browse files
committed
Merge branch '4.x' into 5.x
2 parents 064c119 + 3aff958 commit 8061bfd

11 files changed

Lines changed: 76 additions & 37 deletions

.github/workflows/run-tests.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,32 @@ jobs:
99
strategy:
1010
fail-fast: true
1111
matrix:
12-
php: ['8.4']
13-
symfony: ['6.4.*', '7.3.*']
12+
php: ['8.4', '8.5']
13+
symfony: ['6.4.*', '7.3.*', '7.4.*@rc']
1414
pagerfanta: ['']
1515
composer-flags: ['--prefer-stable']
1616
can-fail: [false]
17+
with-jms: [true]
1718
with-twig: [true]
1819
include:
1920
# Run "no Twig" build on latest PHP and Symfony LTS
2021
- php: '8.4'
2122
symfony: '6.4.*'
2223
composer-flags: '--prefer-stable'
2324
can-fail: false
25+
with-jms: true
2426
with-twig: false
2527
- php: '8.4'
2628
symfony: '6.4.*'
2729
composer-flags: '--prefer-stable --prefer-lowest'
2830
can-fail: false
31+
with-jms: true
32+
with-twig: true
33+
- php: '8.5'
34+
symfony: '8.0.*@rc'
35+
composer-flags: '--prefer-stable'
36+
can-fail: true
37+
with-jms: false
2938
with-twig: true
3039

3140
name: "PHP ${{ matrix.php }}${{ matrix.pagerfanta != '' && format(' - Pagerfanta {0}', matrix.pagerfanta) || '' }}${{ matrix.with-twig == false && ' - Without Twig' || '' }} - Symfony ${{ matrix.symfony }}${{ matrix.composer-flags != '' && format(' - Composer {0}', matrix.composer-flags) || '' }}"
@@ -54,6 +63,10 @@ jobs:
5463
composer require --no-update pagerfanta/core:${{ matrix.pagerfanta }}
5564
composer require --dev --no-update pagerfanta/twig:${{ matrix.pagerfanta }}
5665
66+
- name: Remove JMS Serializer
67+
if: matrix.with-jms == false
68+
run: composer remove --dev --no-update jms/serializer jms/serializer-bundle
69+
5770
- name: Remove Twig
5871
if: matrix.with-twig == false
5972
run: composer remove --dev --no-update pagerfanta/twig symfony/twig-bridge symfony/twig-bundle twig/twig

composer.json

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,38 @@
44
"description": "Bundle integrating Pagerfanta with Symfony",
55
"keywords": ["pagerfanta", "pagination", "symfony"],
66
"license": "MIT",
7+
"repositories": [
8+
{
9+
"type": "vcs",
10+
"url": "https://github.com/mbabker/SymfonyDependencyInjectionTest"
11+
}
12+
],
713
"require": {
814
"php": "^8.4",
915
"pagerfanta/core": "^4.7 || ^5.0",
1016
"psr/container": "^1.0 || ^2.0",
11-
"symfony/config": "^6.4 || ^7.3",
12-
"symfony/dependency-injection": "^6.4 || ^7.3",
13-
"symfony/http-foundation": "^6.4 || ^7.3",
14-
"symfony/http-kernel": "^6.4 || ^7.3",
15-
"symfony/property-access": "^6.4 || ^7.3",
16-
"symfony/routing": "^6.4 || ^7.3"
17+
"symfony/config": "^6.4 || ^7.3 || ^8.0",
18+
"symfony/dependency-injection": "^6.4 || ^7.3 || ^8.0",
19+
"symfony/http-foundation": "^6.4 || ^7.3 || ^8.0",
20+
"symfony/http-kernel": "^6.4 || ^7.3 || ^8.0",
21+
"symfony/property-access": "^6.4 || ^7.3 || ^8.0",
22+
"symfony/routing": "^6.4 || ^7.3 || ^8.0"
1723
},
1824
"require-dev": {
1925
"jms/serializer": "^3.32",
2026
"jms/serializer-bundle": "^5.4",
21-
"matthiasnoback/symfony-dependency-injection-test": "^5.0",
27+
"matthiasnoback/symfony-dependency-injection-test": "dev-ci-updates as 6.1.0.1",
2228
"pagerfanta/twig": "^4.7 || ^5.0",
2329
"phpstan/extension-installer": "^1.3",
24-
"phpstan/phpstan": "2.1.31",
25-
"phpstan/phpstan-phpunit": "2.0.7",
30+
"phpstan/phpstan": "2.1.32",
31+
"phpstan/phpstan-phpunit": "2.0.8",
2632
"phpstan/phpstan-symfony": "2.0.8",
27-
"phpunit/phpunit": "9.6.29",
28-
"rector/rector": "2.2.3",
29-
"symfony/phpunit-bridge": "^6.4 || ^7.3",
30-
"symfony/serializer": "^6.4 || ^7.3",
31-
"symfony/twig-bridge": "^6.4 || ^7.3",
32-
"symfony/twig-bundle": "^6.4 || ^7.3",
33-
"symfony/translation": "^6.4 || ^7.3",
33+
"phpunit/phpunit": "10.5.58 || 11.5.44",
34+
"rector/rector": "2.2.8",
35+
"symfony/serializer": "^6.4 || ^7.3 || ^8.0",
36+
"symfony/twig-bridge": "^6.4 || ^7.3 || ^8.0",
37+
"symfony/twig-bundle": "^6.4 || ^7.3 || ^8.0",
38+
"symfony/translation": "^6.4 || ^7.3 || ^8.0",
3439
"twig/twig": "^3.12"
3540
},
3641
"conflict": {

phpstan-baseline.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ parameters:
6161
path: src/View/ContainerBackedImmutableViewFactory.php
6262

6363
-
64-
message: '#^Parameter \#2 \$array of static method PHPUnit\\Framework\\Assert\:\:assertArrayHasKey\(\) expects array\|ArrayAccess, mixed given\.$#'
64+
message: '#^Parameter \#2 \$array of static method PHPUnit\\Framework\\Assert\:\:assertArrayHasKey\(\) expects array\<mixed\>\|ArrayAccess\<\(int\|string\), mixed\>, mixed given\.$#'
6565
identifier: argument.type
6666
count: 1
6767
path: tests/DependencyInjection/BabDevPagerfantaExtensionTest.php

phpstan.neon

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ parameters:
77
- %currentWorkingDirectory%/config
88
- %currentWorkingDirectory%/src
99
- %currentWorkingDirectory%/tests
10+
excludePaths:
11+
- %currentWorkingDirectory%/src/DependencyInjection/Configuration.php
1012
treatPhpDocTypesAsCertain: false
1113
ignoreErrors:
1214
-

phpunit.xml.dist

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,9 @@
1111
</testsuite>
1212
</testsuites>
1313

14-
<coverage processUncoveredFiles="true">
14+
<source>
1515
<include>
16-
<directory suffix=".php">./src</directory>
16+
<directory>./src</directory>
1717
</include>
18-
</coverage>
19-
20-
<listeners>
21-
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
22-
</listeners>
23-
24-
<php>
25-
<!-- Ignore deprecations from lowest stable and symfony/serializer:^6.3 -->
26-
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[indirect]=1&amp;max[indirect]=10&amp;max[direct]=18"/>
27-
</php>
18+
</source>
2819
</phpunit>

tests/DependencyInjection/BabDevPagerfantaExtensionTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ public function testContainerIsLoadedWithDefaultConfigurationWhenTwigBundleIsIns
8888
],
8989
);
9090

91+
$this->container->setParameter('kernel.build_dir', __DIR__);
92+
$this->container->setParameter('kernel.cache_dir', __DIR__);
9193
$this->container->setParameter('kernel.debug', false);
9294
$this->container->setParameter('kernel.build_dir', __DIR__);
9395
$this->container->setParameter('kernel.cache_dir', __DIR__);
@@ -141,6 +143,10 @@ public function testContainerIsLoadedWithDefaultConfigurationWhenTwigBundleIsIns
141143

142144
public function testContainerIsLoadedWithDefaultConfigurationWhenJMSSerializerBundleIsInstalled(): void
143145
{
146+
if (!class_exists(JMSSerializerBundle::class)) {
147+
self::markTestSkipped('Test requires JMSSerializerBundle');
148+
}
149+
144150
$this->container->setParameter(
145151
'kernel.bundles',
146152
[

tests/RouteGenerator/RequestAwareRouteGeneratorFactoryTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use BabDev\PagerfantaBundle\RouteGenerator\RequestAwareRouteGeneratorFactory;
66
use Pagerfanta\Exception\RuntimeException;
7+
use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;
78
use PHPUnit\Framework\MockObject\MockObject;
89
use PHPUnit\Framework\TestCase;
910
use Symfony\Component\HttpFoundation\Request;
@@ -36,6 +37,7 @@ protected function tearDown(): void
3637
/**
3738
* @doesNotPerformAssertions
3839
*/
40+
#[DoesNotPerformAssertions]
3941
public function testTheGeneratorIsCreatedWhenResolvingTheRouteNameFromTheRequest(): void
4042
{
4143
$request = Request::create('/');
@@ -50,6 +52,7 @@ public function testTheGeneratorIsCreatedWhenResolvingTheRouteNameFromTheRequest
5052
/**
5153
* @doesNotPerformAssertions
5254
*/
55+
#[DoesNotPerformAssertions]
5356
public function testTheGeneratorIsCreatedWhenGivenARouteNameDuringASubrequest(): void
5457
{
5558
$masterRequest = Request::create('/');

tests/Serializer/Handler/PagerfantaHandlerTest.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,21 @@
1111
use JMS\Serializer\SerializerInterface;
1212
use Pagerfanta\Adapter\FixedAdapter;
1313
use Pagerfanta\Pagerfanta;
14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\TestCase;
1516

17+
/**
18+
* @note The {@see PagerfantaHandler::PRESERVE_KEYS_KEY} constant value is inlined to avoid autoloader issues when the JMS packages are not installed
19+
*/
1620
final class PagerfantaHandlerTest extends TestCase
1721
{
22+
public static function setUpBeforeClass(): void
23+
{
24+
if (!class_exists(SerializerBuilder::class)) {
25+
self::markTestSkipped('Test requires JMS Serializer');
26+
}
27+
}
28+
1829
public function testSerializeToJson(): void
1930
{
2031
$pager = new Pagerfanta(new FixedAdapter(100, range(1, 5)));
@@ -33,14 +44,15 @@ public static function dataSerializeWithPreserveKeysContext(): \Generator
3344
{
3445
yield 'Context not set' => [[0 => 'item1', 2 => 'item2', 4 => 'item3'], [], '{"items":{"0":"item1","2":"item2","4":"item3"},"pagination":{"current_page":1,"has_previous_page":false,"has_next_page":false,"per_page":10,"total_items":3,"total_pages":1}}'];
3546

36-
yield 'Context with preserve keys disabled' => [[0 => 'item1', 2 => 'item2', 4 => 'item3'], [PagerfantaHandler::PRESERVE_KEYS_KEY => false], '{"items":["item1","item2","item3"],"pagination":{"current_page":1,"has_previous_page":false,"has_next_page":false,"per_page":10,"total_items":3,"total_pages":1}}'];
47+
yield 'Context with preserve keys disabled' => [[0 => 'item1', 2 => 'item2', 4 => 'item3'], ['pagerfanta_preserve_keys' => false], '{"items":["item1","item2","item3"],"pagination":{"current_page":1,"has_previous_page":false,"has_next_page":false,"per_page":10,"total_items":3,"total_pages":1}}'];
3748

38-
yield 'Context with preserve keys enabled' => [[0 => 'item1', 2 => 'item2', 4 => 'item3'], [PagerfantaHandler::PRESERVE_KEYS_KEY => true], '{"items":{"0":"item1","2":"item2","4":"item3"},"pagination":{"current_page":1,"has_previous_page":false,"has_next_page":false,"per_page":10,"total_items":3,"total_pages":1}}'];
49+
yield 'Context with preserve keys enabled' => [[0 => 'item1', 2 => 'item2', 4 => 'item3'], ['pagerfanta_preserve_keys' => true], '{"items":{"0":"item1","2":"item2","4":"item3"},"pagination":{"current_page":1,"has_previous_page":false,"has_next_page":false,"per_page":10,"total_items":3,"total_pages":1}}'];
3950
}
4051

4152
/**
4253
* @dataProvider dataSerializeWithPreserveKeysContext
4354
*/
55+
#[DataProvider('dataSerializeWithPreserveKeysContext')]
4456
public function testSerializeToJsonWithPreserveKeysContext(array $data, array $context, string $expectedJson): void
4557
{
4658
$pager = new Pagerfanta(new FixedAdapter(\count($data), $data));
@@ -66,7 +78,7 @@ public function testNormalizeRejectsInvalidPreserveKeysContext(): void
6678
$pager->setMaxPerPage(5);
6779

6880
$serializationContext = new SerializationContext();
69-
$serializationContext->setAttribute(PagerfantaHandler::PRESERVE_KEYS_KEY, 'invalid');
81+
$serializationContext->setAttribute('pagerfanta_preserve_keys', 'invalid');
7082

7183
$this->createSerializer()->serialize($pager, 'json', $serializationContext);
7284
}

tests/Serializer/Normalizer/PagerfantaNormalizerTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Pagerfanta\Adapter\NullAdapter;
88
use Pagerfanta\Pagerfanta;
99
use Pagerfanta\PagerfantaInterface;
10+
use PHPUnit\Framework\Attributes\DataProvider;
1011
use PHPUnit\Framework\TestCase;
1112
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
1213
use Symfony\Component\Serializer\Exception\LogicException;
@@ -50,6 +51,7 @@ public static function dataNormalizeWithPreserveKeysContext(): \Generator
5051
/**
5152
* @dataProvider dataNormalizeWithPreserveKeysContext
5253
*/
54+
#[DataProvider('dataNormalizeWithPreserveKeysContext')]
5355
public function testNormalizeWithPreserveKeysContext(array $data, array $context, array $expectedItems): void
5456
{
5557
$pager = new Pagerfanta(new FixedAdapter(\count($data), $data));
@@ -87,7 +89,7 @@ public function testNormalizeOnlyAcceptsPagerfantaInstances(): void
8789
new PagerfantaNormalizer()->normalize(new \stdClass());
8890
}
8991

90-
public function dataSupportsNormalization(): \Generator
92+
public static function dataSupportsNormalization(): \Generator
9193
{
9294
yield 'Supported' => [new Pagerfanta(new NullAdapter(25)), true];
9395
yield 'Not Supported' => [new \stdClass(), false];
@@ -96,6 +98,7 @@ public function dataSupportsNormalization(): \Generator
9698
/**
9799
* @dataProvider dataSupportsNormalization
98100
*/
101+
#[DataProvider('dataSupportsNormalization')]
99102
public function testSupportsNormalization(mixed $data, bool $supported): void
100103
{
101104
self::assertSame($supported, new PagerfantaNormalizer()->supportsNormalization($data));

tests/Twig/TwigUndefinedCallableHandlerTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace BabDev\PagerfantaBundle\Tests\Twig;
44

55
use BabDev\PagerfantaBundle\Twig\UndefinedCallableHandler;
6+
use PHPUnit\Framework\Attributes\DataProvider;
67
use PHPUnit\Framework\TestCase;
78
use Twig\Error\SyntaxError;
89

@@ -15,7 +16,7 @@ public static function setUpBeforeClass(): void
1516
}
1617
}
1718

18-
public function dataSupportedFunctions(): \Generator
19+
public static function dataSupportedFunctions(): \Generator
1920
{
2021
yield '"pagerfanta" function' => ['pagerfanta'];
2122
yield '"pagerfanta_page_url" function' => ['pagerfanta_page_url'];
@@ -24,6 +25,7 @@ public function dataSupportedFunctions(): \Generator
2425
/**
2526
* @dataProvider dataSupportedFunctions
2627
*/
28+
#[DataProvider('dataSupportedFunctions')]
2729
public function testThrowsASyntaxErrorForSupportedTwigFunctionsWhenNotDefined(string $function): void
2830
{
2931
$this->expectException(SyntaxError::class);

0 commit comments

Comments
 (0)