Skip to content

Commit

Permalink
Merge pull request #1481 from scyzoryck/phpunit-10
Browse files Browse the repository at this point in the history
chore(phpunit): Allow PHPUnit10
  • Loading branch information
scyzoryck authored Apr 21, 2023
2 parents ac0b16e + 97d4b5c commit b265999
Show file tree
Hide file tree
Showing 40 changed files with 301 additions and 322 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ phpstan.xml
.phpcs-cache
/doc/_build/*
/.phpunit.result.cache
/.phpunit.cache
**/.DS_STORE
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"ocramius/proxy-manager": "^1.0|^2.0",
"phpbench/phpbench": "^1.0",
"phpstan/phpstan": "^1.0.2",
"phpunit/phpunit": "^8.5.21||^9.0",
"phpunit/phpunit": "^8.5.21||^9.0||^10.0",
"psr/container": "^1.0|^2.0",
"symfony/dependency-injection": "^3.0|^4.0|^5.0|^6.0",
"symfony/expression-language": "^3.2|^4.0|^5.0|^6.0",
Expand Down
70 changes: 25 additions & 45 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,47 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
failOnWarning="false"
bootstrap="tests/bootstrap.php"
>
<php>
<ini name="error_reporting" value="-1" />
<ini name="serialize_precision" value="14"/>
<ini name="date.timezone" value="UTC"/>
</php>

<testsuites>
<testsuite name="JMS Serializer Test Suite">
<directory>./tests</directory>
</testsuite>
</testsuites>

<groups>
<exclude>
<group>performance</group>
</exclude>
</groups>

<!-- PHPUnit <9 coverage filters -->
<filter>
<whitelist>
<directory>src</directory>
</whitelist>
</filter>

<!-- PHPUnit >=9 coverage filters -->
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
<exclude>
<file>./src/Annotation/ReadOnly.php</file>
</exclude>
</coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" colors="true" beStrictAboutOutputDuringTests="true" failOnRisky="true" failOnWarning="false" bootstrap="tests/bootstrap.php" cacheDirectory=".phpunit.cache">
<php>
<ini name="error_reporting" value="-1"/>
<ini name="serialize_precision" value="14"/>
<ini name="date.timezone" value="UTC"/>
</php>
<testsuites>
<testsuite name="JMS Serializer Test Suite">
<directory>./tests</directory>
</testsuite>
</testsuites>
<groups>
<exclude>
<group>performance</group>
</exclude>
</groups>
<!-- PHPUnit >=9 coverage filters -->
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
<exclude>
<file>./src/Annotation/ReadOnly.php</file>
</exclude>
</coverage>
</phpunit>
4 changes: 2 additions & 2 deletions tests/Deserializer/BaseDeserializationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function testDeserializationInvalidDataCausesException($data, string $typ
$serializer->fromArray($data, $type);
}

public function dataTypeCannotBeCasted(): iterable
public static function dataTypeCannotBeCasted(): iterable
{
yield 'array to string' => [
['pub_name' => ['bla', 'bla']],
Expand Down Expand Up @@ -56,7 +56,7 @@ public function testDeserializerGroupExclusion(array $data, array $groups, array
self::assertSame($expected, $serializer->toArray($object));
}

public function dataDeserializerGroupExclusion(): iterable
public static function dataDeserializerGroupExclusion(): iterable
{
$data = [
'foo' => 'foo',
Expand Down
4 changes: 2 additions & 2 deletions tests/Exclusion/GroupsExclusionStrategyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function testUninitializedContextIsWorking(array $propertyGroups, array $
self::assertEquals($strat->shouldSkipProperty($metadata, SerializationContext::create()), $exclude);
}

public function getExclusionRules()
public static function getExclusionRules()
{
return [
[['foo'], ['foo'], false],
Expand Down Expand Up @@ -71,7 +71,7 @@ public function testGroupsFor(array $groups, array $propsVisited, array $resulti
self::assertEquals($groupsFor, $resultingGroups);
}

public function getGroupsFor()
public static function getGroupsFor()
{
return [
[['foo'], ['prop'], ['foo']],
Expand Down
4 changes: 2 additions & 2 deletions tests/Handler/DateHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected function setUp(): void
$this->timezone = new \DateTimeZone('UTC');
}

public function getParams()
public static function getParams()
{
return [
[['Y-m-d']],
Expand Down Expand Up @@ -75,7 +75,7 @@ public function testDeserializeDateInterval($dateInterval, $expected)
self::assertEquals($expected['s'], $deserialized->s);
}

public function getDeserializeDateInterval()
public static function getDeserializeDateInterval()
{
return [
['P0Y0M0DT3H5M7.520S', ['s' => 7, 'f' => 0.52]],
Expand Down
6 changes: 3 additions & 3 deletions tests/Handler/EnumHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function testOrdinaryEnumCanNotBeUsedAsBackedEnumWhenDeserializing()

public function testBackedDeserializationFailsWhenNoValueMatches()
{
self::expectError();
$this->expectException(\Error::class);

$visitor = $this->createMock(DeserializationVisitorInterface::class);
$type = [
Expand All @@ -71,8 +71,8 @@ public function testBackedDeserializationFailsWhenNoValueMatches()

public function testBackedDeserializationFailsWhenValueTypeMismatch()
{
self::expectException(RuntimeException::class);
self::expectErrorMessage(sprintf('"any" is not a valid backing value for enum "%s"', BackedSuitInt::class));
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage(sprintf('"any" is not a valid backing value for enum "%s"', BackedSuitInt::class));

$visitor = $this->createMock(DeserializationVisitorInterface::class);
$type = [
Expand Down
2 changes: 1 addition & 1 deletion tests/Handler/IteratorHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class IteratorHandlerTest extends TestCase
*/
private $handlerRegistry;

public function iteratorsProvider(): array
public static function iteratorsProvider(): array
{
return [
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use JMS\Serializer\GraphNavigatorInterface;
use JMS\Serializer\Handler\LazyHandlerRegistry;

abstract class LazyHandlerRegistryTest extends HandlerRegistryTest
abstract class LazyHandlerRegistryTestCase extends HandlerRegistryTest
{
protected $container;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Psr\Container\ContainerInterface;

class LazyHandlerRegistryWithPsr11ContainerTest extends LazyHandlerRegistryTest
class LazyHandlerRegistryWithPsr11ContainerTest extends LazyHandlerRegistryTestCase
{
protected function createContainer()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Symfony\Component\DependencyInjection\Container;

class LazyHandlerRegistryWithSymfonyContainerTest extends LazyHandlerRegistryTest
class LazyHandlerRegistryWithSymfonyContainerTest extends LazyHandlerRegistryTestCase
{
protected function createContainer()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Handler/SymfonyUidHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

final class SymfonyUidHandlerTest extends TestCase
{
public function dataUid(): \Generator
public static function dataUid(): \Generator
{
yield sprintf('%s instance', Ulid::class) => [new Ulid()];
yield sprintf('%s instance', Uuid::class) => [Uuid::v1()];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use PHPUnit\Framework\TestCase;

abstract class AbstractPropertyMetadataTest extends TestCase
abstract class AbstractPropertyMetadataTestCase extends TestCase
{
protected function setNonDefaultMetadataValues($metadata)
{
Expand Down
6 changes: 3 additions & 3 deletions tests/Metadata/ClassMetadataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class ClassMetadataTest extends TestCase
{
public function getAccessOrderCases()
public static function getAccessOrderCases()
{
return [
[['b', 'a'], ['b', 'a']],
Expand Down Expand Up @@ -93,7 +93,7 @@ public function testAccessorTypePublicMethodException($getter, $setter, $message
$metadata->setAccessor(PropertyMetadata::ACCESS_TYPE_PUBLIC_METHOD, $getter, $setter);
}

public function providerPublicMethodData()
public static function providerPublicMethodData()
{
return [
['a', null, null, 'geta', 'seta'],
Expand All @@ -103,7 +103,7 @@ public function providerPublicMethodData()
];
}

public function providerPublicMethodException()
public static function providerPublicMethodException()
{
return [
[null, null, 'a public getE method, nor a public isE method, nor a public hasE method in class'],
Expand Down
2 changes: 1 addition & 1 deletion tests/Metadata/Driver/AnnotationDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use JMS\Serializer\Naming\IdenticalPropertyNamingStrategy;
use Metadata\Driver\DriverInterface;

class AnnotationDriverTest extends BaseAnnotationOrAttributeDriverTest
class AnnotationDriverTest extends BaseAnnotationOrAttributeDriverTestCase
{
protected function getDriver(?string $subDir = null, bool $addUnderscoreDir = true): DriverInterface
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Metadata/Driver/AttributeDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use JMS\Serializer\Naming\IdenticalPropertyNamingStrategy;
use Metadata\Driver\DriverInterface;

class AttributeDriverTest extends BaseAnnotationOrAttributeDriverTest
class AttributeDriverTest extends BaseAnnotationOrAttributeDriverTestCase
{
protected function setUp(): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use JMS\Serializer\Tests\Fixtures\AllExcludedObject;
use Metadata\Driver\DriverInterface;

abstract class BaseAnnotationOrAttributeDriverTest extends BaseDriverTest
abstract class BaseAnnotationOrAttributeDriverTestCase extends BaseDriverTestCase
{
abstract protected function getDriver(?string $subDir = null, bool $addUnderscoreDir = true): DriverInterface;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
use Symfony\Component\ExpressionLanguage\ExpressionFunction;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;

abstract class BaseDriverTest extends TestCase
abstract class BaseDriverTestCase extends TestCase
{
public function testLoadBlogPostMetadata()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Metadata/Driver/XmlDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Metadata\Driver\DriverInterface;
use Metadata\Driver\FileLocator;

class XmlDriverTest extends BaseDriverTest
class XmlDriverTest extends BaseDriverTestCase
{
public function testInvalidXml()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Metadata/Driver/YamlDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use Metadata\Driver\DriverInterface;
use Metadata\Driver\FileLocator;

class YamlDriverTest extends BaseDriverTest
class YamlDriverTest extends BaseDriverTestCase
{
public function testAccessorOrderIsInferred(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Metadata/ExpressionPropertyMetadataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use JMS\Serializer\Metadata\ExpressionPropertyMetadata;

class ExpressionPropertyMetadataTest extends AbstractPropertyMetadataTest
class ExpressionPropertyMetadataTest extends AbstractPropertyMetadataTestCase
{
public function testSerialization()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Metadata/PropertyMetadataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use JMS\Serializer\Metadata\PropertyMetadata;
use JMS\Serializer\Tests\Fixtures\SimpleObject;

class PropertyMetadataTest extends AbstractPropertyMetadataTest
class PropertyMetadataTest extends AbstractPropertyMetadataTestCase
{
public function testSerialization()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Metadata/StaticPropertyMetadataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use JMS\Serializer\Metadata\StaticPropertyMetadata;

class StaticPropertyMetadataTest extends AbstractPropertyMetadataTest
class StaticPropertyMetadataTest extends AbstractPropertyMetadataTestCase
{
public function testSerialization()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Metadata/VirtualPropertyMetadataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use JMS\Serializer\Metadata\VirtualPropertyMetadata;
use JMS\Serializer\Tests\Fixtures\ObjectWithVirtualProperties;

class VirtualPropertyMetadataTest extends AbstractPropertyMetadataTest
class VirtualPropertyMetadataTest extends AbstractPropertyMetadataTestCase
{
public function testSerialization()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Ordering/CustomPropertyOrderingStrategyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function testOrder(array $ordering, array $keysToSort, array $expectedRes
self::assertEquals($expectedResult, array_keys($sortedProperties));
}

public function dataOrder(): iterable
public static function dataOrder(): iterable
{
$order = ['one', 'two', 'three'];

Expand Down
2 changes: 1 addition & 1 deletion tests/Serializer/ArrayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function testToArrayWithScalar($input)
self::assertEquals([$input], $result);
}

public function scalarValues()
public static function scalarValues()
{
return [
[42],
Expand Down
Loading

0 comments on commit b265999

Please sign in to comment.