Skip to content

Commit f0698a4

Browse files
authored
test: compatibility with PHPUnit 10 (#5701)
* test: compatibility with PHPUnit 10 * fix * another fix * one more fix * fix * try again * again * fixed locally * clean composer.json
1 parent 8407875 commit f0698a4

File tree

109 files changed

+943
-806
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+943
-806
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,8 @@ jobs:
620620
- name: Clear test app cache
621621
run: tests/Fixtures/app/console cache:clear --ansi
622622
- name: Run PHPUnit tests
623-
run: vendor/bin/simple-phpunit
623+
# The PHPUnit Bridge doesn't support PHPUnit 10 yet: https://github.com/symfony/symfony/issues/49069
624+
run: vendor/bin/phpunit -c phpunit10.xml.dist
624625

625626
behat-symfony-next:
626627
name: Behat (PHP ${{ matrix.php }}) (Symfony dev)

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/.php-cs-fixer.php
33
/.php-cs-fixer.cache
44
/.phpunit.result.cache
5+
/.phpunit.cache/
56
/build/
67
/composer.lock
78
/composer.phar

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ Both `simple-phpunit` and `behat` are development dependencies and should be ava
124124

125125
To launch unit tests:
126126

127-
vendor/bin/simple-phpunit --stop-on-failure -vvv
127+
vendor/bin/simple-phpunit --stop-on-defect -vvv
128128

129129
If you want coverage, you will need the `pcov` PHP extension and run:
130130

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
},
2929
"require-dev": {
3030
"behat/behat": "^3.1",
31-
"behat/mink": "^1.9@dev",
31+
"behat/mink": "^1.9",
3232
"doctrine/cache": "^1.11 || ^2.1",
3333
"doctrine/common": "^3.2.2",
3434
"doctrine/data-fixtures": "^1.2.2",

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

3-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" backupGlobals="false" bootstrap="tests/Fixtures/app/bootstrap.php" colors="true">
3+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" backupGlobals="false" bootstrap="tests/Fixtures/app/bootstrap.php" colors="true">
44
<php>
55
<ini name="error_reporting" value="-1" />
66
<ini name="memory_limit" value="-1" />

phpunit10.xml.dist

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" backupGlobals="false" bootstrap="tests/Fixtures/app/bootstrap.php" colors="true" cacheDirectory=".phpunit.cache">
3+
<php>
4+
<ini name="error_reporting" value="-1"/>
5+
<ini name="memory_limit" value="-1"/>
6+
<server name="SYMFONY_DEPRECATIONS_HELPER" value="max[total]=0&amp;ignoreFile=./tests/.ignored-deprecations"/>
7+
<!-- This is necessary for GitHub Actions to work properly -->
8+
<server name="SYMFONY_PHPUNIT_DIR" value="vendor/bin/.phpunit"/>
9+
<server name="SYMFONY_PHPUNIT_REMOVE" value="symfony/yaml"/>
10+
<server name="KERNEL_DIR" value="tests/Fixtures/app/"/>
11+
<server name="KERNEL_CLASS" value="AppKernel"/>
12+
<env name="APP_ENV" value="test"/>
13+
</php>
14+
15+
<testsuites>
16+
<testsuite name="Project Test Suite">
17+
<directory>tests</directory>
18+
</testsuite>
19+
</testsuites>
20+
21+
<groups>
22+
<exclude>
23+
<group>mongodb</group>
24+
</exclude>
25+
</groups>
26+
27+
<source>
28+
<include>
29+
<directory>.</directory>
30+
</include>
31+
<exclude>
32+
<directory>features</directory>
33+
<directory>tests</directory>
34+
<directory>vendor</directory>
35+
<file>.php-cs-fixer.dist.php</file>
36+
</exclude>
37+
</source>
38+
</phpunit>

src/JsonSchema/Tests/SchemaTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function testCollectionJsonSchemaVersion(string $version, string $ref): v
4444
$this->assertSame('Foo', $schema->getItemsDefinitionKey());
4545
}
4646

47-
public function versionProvider(): iterable
47+
public static function versionProvider(): iterable
4848
{
4949
yield [Schema::VERSION_JSON_SCHEMA, '#/definitions/Foo'];
5050
yield [Schema::VERSION_SWAGGER, '#/definitions/Foo'];
@@ -85,7 +85,7 @@ public function testDefinitions(string $version, array $baseDefinitions): void
8585
$this->assertArrayNotHasKey('components', $schema->getArrayCopy(false));
8686
}
8787

88-
public function definitionsDataProvider(): iterable
88+
public static function definitionsDataProvider(): iterable
8989
{
9090
yield [Schema::VERSION_OPENAPI, ['foo' => []]];
9191
yield [Schema::VERSION_JSON_SCHEMA, ['foo' => []]];

src/JsonSchema/Tests/TypeFactoryTest.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function testGetType(array $schema, Type $type): void
4141
$this->assertEquals($schema, $typeFactory->getType($type, 'json', null, null, new Schema(Schema::VERSION_OPENAPI)));
4242
}
4343

44-
public function typeProvider(): iterable
44+
public static function typeProvider(): iterable
4545
{
4646
yield [['type' => 'integer'], new Type(Type::BUILTIN_TYPE_INT)];
4747
yield [['nullable' => true, 'type' => 'integer'], new Type(Type::BUILTIN_TYPE_INT, true)];
@@ -169,7 +169,7 @@ public function testGetTypeWithJsonSchemaSyntax(array $schema, Type $type): void
169169
$this->assertEquals($schema, $typeFactory->getType($type, 'json', null, null, new Schema(Schema::VERSION_JSON_SCHEMA)));
170170
}
171171

172-
public function jsonSchemaTypeProvider(): iterable
172+
public static function jsonSchemaTypeProvider(): iterable
173173
{
174174
yield [['type' => 'integer'], new Type(Type::BUILTIN_TYPE_INT)];
175175
yield [['type' => ['integer', 'null']], new Type(Type::BUILTIN_TYPE_INT, true)];
@@ -290,7 +290,7 @@ public function testGetTypeWithOpenAPIV2Syntax(array $schema, Type $type): void
290290
$this->assertEquals($schema, $typeFactory->getType($type, 'json', null, null, new Schema(Schema::VERSION_SWAGGER)));
291291
}
292292

293-
public function openAPIV2TypeProvider(): iterable
293+
public static function openAPIV2TypeProvider(): iterable
294294
{
295295
yield [['type' => 'integer'], new Type(Type::BUILTIN_TYPE_INT)];
296296
yield [['type' => 'integer'], new Type(Type::BUILTIN_TYPE_INT, true)];
@@ -412,20 +412,21 @@ public function testGetClassType(): void
412412
}
413413

414414
/** @dataProvider classTypeWithNullabilityDataProvider */
415-
public function testGetClassTypeWithNullability(array $expected, SchemaFactoryInterface $schemaFactory, Schema $schema): void
415+
public function testGetClassTypeWithNullability(array $expected, callable $schemaFactoryFactory, Schema $schema): void
416416
{
417417
$typeFactory = new TypeFactory();
418-
$typeFactory->setSchemaFactory($schemaFactory);
418+
$typeFactory->setSchemaFactory($schemaFactoryFactory($this));
419419

420420
self::assertEquals(
421421
$expected,
422422
$typeFactory->getType(new Type(Type::BUILTIN_TYPE_OBJECT, true, Dummy::class), 'jsonld', true, ['foo' => 'bar'], $schema)
423423
);
424424
}
425425

426-
public function classTypeWithNullabilityDataProvider(): iterable
426+
public static function classTypeWithNullabilityDataProvider(): iterable
427427
{
428-
$schemaFactory = $this->createSchemaFactoryMock($schema = new Schema());
428+
$schema = new Schema();
429+
$schemaFactoryFactory = fn (self $that): SchemaFactoryInterface => $that->createSchemaFactoryMock($schema);
429430

430431
yield 'JSON-Schema version' => [
431432
[
@@ -434,11 +435,12 @@ public function classTypeWithNullabilityDataProvider(): iterable
434435
['type' => 'null'],
435436
],
436437
],
437-
$schemaFactory,
438+
$schemaFactoryFactory,
438439
$schema,
439440
];
440441

441-
$schemaFactory = $this->createSchemaFactoryMock($schema = new Schema(Schema::VERSION_OPENAPI));
442+
$schema = new Schema(Schema::VERSION_OPENAPI);
443+
$schemaFactoryFactory = fn (self $that): SchemaFactoryInterface => $that->createSchemaFactoryMock($schema);
442444

443445
yield 'OpenAPI < 3.1 version' => [
444446
[
@@ -447,7 +449,7 @@ public function classTypeWithNullabilityDataProvider(): iterable
447449
],
448450
'nullable' => true,
449451
],
450-
$schemaFactory,
452+
$schemaFactoryFactory,
451453
$schema,
452454
];
453455
}

src/Metadata/Tests/Extractor/PropertyMetadataCompatibilityTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function testValidMetadata(string $extractorClass, PropertyAdapterInterfa
9393
$this->assertEquals($this->buildApiProperty(), $property);
9494
}
9595

96-
public function getExtractors(): array
96+
public static function getExtractors(): array
9797
{
9898
return [
9999
[XmlPropertyExtractor::class, new XmlPropertyAdapter()],

src/Metadata/Tests/Extractor/ResourceMetadataCompatibilityTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ public function testValidMetadata(string $extractorClass, ResourceAdapterInterfa
515515
$this->assertEquals(new ResourceMetadataCollection(self::RESOURCE_CLASS, $this->buildApiResources()), $collection);
516516
}
517517

518-
public function getExtractors(): array
518+
public static function getExtractors(): array
519519
{
520520
return [
521521
[XmlResourceExtractor::class, new XmlResourceAdapter()],

0 commit comments

Comments
 (0)