Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps(composer): Update to PHPUnit 11 & Rector 1.0 #1540

Merged
merged 1 commit into from
Mar 23, 2024
Merged
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
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@
"jackalope/jackalope-doctrine-dbal": "^1.3",
"ocramius/proxy-manager": "^1.0 || ^2.0",
"phpbench/phpbench": "^1.0",
"phpstan/phpstan": "^1.0.2",
"phpunit/phpunit": "^9.0 || ^10.0",
"phpstan/phpstan": "^1.10.57",
"phpunit/phpunit": "^9.0 || ^10.0 || ^11.0",
"psr/container": "^1.0 || ^2.0",
"rector/rector": "^0.19.0",
"rector/rector": "^1.0.0",
"symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0",
"symfony/expression-language": "^5.4 || ^6.0 || ^7.0",
"symfony/filesystem": "^5.4 || ^6.0 || ^7.0",
Expand Down
9 changes: 8 additions & 1 deletion phpstan/ignore-by-php-version.neon.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php declare(strict_types = 1);

use PHPUnit\Framework\Attributes\DataProvider;
use Symfony\Component\Uid\UuidV7;

$includes = [];
if (PHP_VERSION_ID < 80000) {
$includes[] = __DIR__ . '/no-typed-prop.neon';
Expand All @@ -11,14 +14,18 @@
}
if (PHP_VERSION_ID >= 80000) {
$includes[] = __DIR__ . '/ignore-missing-attribute.neon';
if(!class_exists(DataProvider::class)) {
$includes[] = __DIR__ . '/no-phpunit-attributes.neon';
}
}
if (PHP_VERSION_ID >= 80100 && PHP_VERSION_ID < 80200) {
$includes[] = __DIR__ . '/php-81.neon';
}
if(!class_exists(Symfony\Component\Uid\UuidV7::class)) {
if(!class_exists(UuidV7::class)) {
$includes[] = __DIR__ . '/no-uuid-7.neon';
}


$config = [];
$config['includes'] = $includes;
$config['parameters']['phpVersion'] = PHP_VERSION_ID;
Expand Down
3 changes: 3 additions & 0 deletions phpstan/no-phpunit-attributes.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
parameters:
ignoreErrors:
- '~Attribute class PHPUnit\\Framework\\Attributes\\.* does not exist~'
2 changes: 1 addition & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
$rectorConfig->paths([
__DIR__ . '/src',
]);
$rectorConfig->sets([LevelSetList::UP_TO_PHP_74]);
$rectorConfig->phpVersion(74);
};
3 changes: 3 additions & 0 deletions tests/Deserializer/BaseDeserializationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
use JMS\Serializer\Tests\Fixtures\GroupsObject;
use JMS\Serializer\Tests\Fixtures\Price;
use JMS\Serializer\Tests\Fixtures\Publisher;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

class BaseDeserializationTest extends TestCase
{
/**
* @dataProvider dataTypeCannotBeCasted
*/
#[DataProvider('dataTypeCannotBeCasted')]
public function testDeserializationInvalidDataCausesException($data, string $type): void
{
$serializer = SerializerBuilder::create()->build();
Expand Down Expand Up @@ -48,6 +50,7 @@ public static function dataTypeCannotBeCasted(): iterable
/**
* @dataProvider dataDeserializerGroupExclusion
*/
#[DataProvider('dataDeserializerGroupExclusion')]
public function testDeserializerGroupExclusion(array $data, array $groups, array $expected): void
{
$serializer = SerializerBuilder::create()->build();
Expand Down
20 changes: 10 additions & 10 deletions tests/Exclusion/DisjunctExclusionStrategyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function testShouldSkipClassShortCircuiting()
$first->expects($this->once())
->method('shouldSkipClass')
->with($metadata, $context)
->will($this->returnValue(true));
->willReturn(true);

$last->expects($this->never())
->method('shouldSkipClass');
Expand All @@ -46,12 +46,12 @@ public function testShouldSkipClassDisjunctBehavior()
$first->expects($this->once())
->method('shouldSkipClass')
->with($metadata, $context)
->will($this->returnValue(false));
->willReturn(false);

$last->expects($this->once())
->method('shouldSkipClass')
->with($metadata, $context)
->will($this->returnValue(true));
->willReturn(true);

self::assertTrue($strat->shouldSkipClass($metadata, $context));
}
Expand All @@ -69,12 +69,12 @@ public function testShouldSkipClassReturnsFalseIfNoPredicateMatched()
$first->expects($this->once())
->method('shouldSkipClass')
->with($metadata, $context)
->will($this->returnValue(false));
->willReturn(false);

$last->expects($this->once())
->method('shouldSkipClass')
->with($metadata, $context)
->will($this->returnValue(false));
->willReturn(false);

self::assertFalse($strat->shouldSkipClass($metadata, $context));
}
Expand All @@ -92,7 +92,7 @@ public function testShouldSkipPropertyShortCircuiting()
$first->expects($this->once())
->method('shouldSkipProperty')
->with($metadata, $context)
->will($this->returnValue(true));
->willReturn(true);

$last->expects($this->never())
->method('shouldSkipProperty');
Expand All @@ -113,12 +113,12 @@ public function testShouldSkipPropertyDisjunct()
$first->expects($this->once())
->method('shouldSkipProperty')
->with($metadata, $context)
->will($this->returnValue(false));
->willReturn(false);

$last->expects($this->once())
->method('shouldSkipProperty')
->with($metadata, $context)
->will($this->returnValue(true));
->willReturn(true);

self::assertTrue($strat->shouldSkipProperty($metadata, $context));
}
Expand All @@ -136,12 +136,12 @@ public function testShouldSkipPropertyReturnsFalseIfNoPredicateMatches()
$first->expects($this->once())
->method('shouldSkipProperty')
->with($metadata, $context)
->will($this->returnValue(false));
->willReturn(false);

$last->expects($this->once())
->method('shouldSkipProperty')
->with($metadata, $context)
->will($this->returnValue(false));
->willReturn(false);

self::assertFalse($strat->shouldSkipProperty($metadata, $context));
}
Expand Down
9 changes: 4 additions & 5 deletions tests/Exclusion/GroupsExclusionStrategyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,16 @@
use JMS\Serializer\Exclusion\GroupsExclusionStrategy;
use JMS\Serializer\Metadata\StaticPropertyMetadata;
use JMS\Serializer\SerializationContext;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

class GroupsExclusionStrategyTest extends TestCase
{
/**
* @param array $propertyGroups
* @param array $groups
* @param bool $exclude
*
* @dataProvider getExclusionRules
*/
public function testUninitializedContextIsWorking(array $propertyGroups, array $groups, $exclude)
#[DataProvider('getExclusionRules')]
public function testUninitializedContextIsWorking(array $propertyGroups, array $groups, bool $exclude)
{
$metadata = new StaticPropertyMetadata('stdClass', 'prop', 'propVal');
$metadata->groups = $propertyGroups;
Expand Down Expand Up @@ -57,6 +55,7 @@ public static function getExclusionRules()
/**
* @dataProvider getGroupsFor
*/
#[DataProvider('getGroupsFor')]
public function testGroupsFor(array $groups, array $propsVisited, array $resultingGroups)
{
$exclusion = new GroupsExclusionStrategy($groups);
Expand Down
2 changes: 2 additions & 0 deletions tests/Handler/ArrayCollectionDepthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use JMS\Serializer\SerializationContext;
use JMS\Serializer\Serializer as JMSSerializer;
use JMS\Serializer\SerializerBuilder;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

class ArrayCollectionDepthTest extends TestCase
Expand All @@ -28,6 +29,7 @@ protected function setUp(): void
*
* @dataProvider getCollections
*/
#[DataProvider('getCollections')]
public function testDepth($collection)
{
$context = SerializationContext::create()
Expand Down
3 changes: 3 additions & 0 deletions tests/Handler/ArrayCollectionHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
use JMS\Serializer\Tests\Fixtures\ExclusionStrategy\AlwaysExcludeExclusionStrategy;
use JMS\Serializer\Visitor\SerializationVisitorInterface;
use Metadata\MetadataFactoryInterface;
use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;
use PHPUnit\Framework\TestCase;

class ArrayCollectionHandlerTest extends TestCase
{
/**
* @doesNotPerformAssertions
*/
#[DoesNotPerformAssertions]
public function testSerializeArray()
{
$handler = new ArrayCollectionHandler();
Expand All @@ -36,6 +38,7 @@ public function testSerializeArray()
/**
* @doesNotPerformAssertions
*/
#[DoesNotPerformAssertions]
public function testSerializeArraySkipByExclusionStrategy()
{
$handler = new ArrayCollectionHandler(false);
Expand Down
12 changes: 6 additions & 6 deletions tests/Handler/DateHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
use JMS\Serializer\SerializationContext;
use JMS\Serializer\Visitor\DeserializationVisitorInterface;
use JMS\Serializer\Visitor\SerializationVisitorInterface;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;
use PHPUnit\Framework\TestCase;

class DateHandlerTest extends TestCase
Expand Down Expand Up @@ -39,11 +41,11 @@ public static function getParams()
}

/**
* @param array $params
*
* @doesNotPerformAssertions
* @dataProvider getParams
*/
#[DataProvider('getParams')]
#[DoesNotPerformAssertions]
public function testSerializeDate(array $params)
{
$context = $this->getMockBuilder(SerializationContext::class)->getMock();
Expand All @@ -57,12 +59,10 @@ public function testSerializeDate(array $params)
}

/**
* @param string $dateInterval
* @param \DateTime $expected
*
* @dataProvider getDeserializeDateInterval
*/
public function testDeserializeDateInterval($dateInterval, $expected)
#[DataProvider('getDeserializeDateInterval')]
public function testDeserializeDateInterval(string $dateInterval, array $expected)
{
$visitor = $this->getMockBuilder(DeserializationVisitorInterface::class)->getMock();
$visitor->method('visitString')->with('2017-06-18');
Expand Down
2 changes: 2 additions & 0 deletions tests/Handler/IteratorHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use JMS\Serializer\SerializationContext;
use JMS\Serializer\Visitor\DeserializationVisitorInterface;
use JMS\Serializer\Visitor\SerializationVisitorInterface;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

final class IteratorHandlerTest extends TestCase
Expand Down Expand Up @@ -40,6 +41,7 @@ public static function iteratorsProvider(): array
/**
* @dataProvider iteratorsProvider
*/
#[DataProvider('iteratorsProvider')]
public function testSerialize(\Iterator $iterator): void
{
$type = get_class($iterator);
Expand Down
6 changes: 6 additions & 0 deletions tests/Handler/SymfonyUidHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use JMS\Serializer\Handler\SymfonyUidHandler;
use JMS\Serializer\SerializerBuilder;
use JMS\Serializer\SerializerInterface;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Uid\AbstractUid;
use Symfony\Component\Uid\Ulid;
Expand Down Expand Up @@ -46,6 +47,7 @@ public static function dataUid(): \Generator
/**
* @dataProvider dataUid
*/
#[DataProvider('dataUid')]
public function testSerializeUidToJson(AbstractUid $uid): void
{
self::assertJsonStringEqualsJsonString(
Expand All @@ -57,6 +59,7 @@ public function testSerializeUidToJson(AbstractUid $uid): void
/**
* @dataProvider dataUid
*/
#[DataProvider('dataUid')]
public function testSerializeUidToXmlWithCData(AbstractUid $uid): void
{
self::assertXmlStringEqualsXmlString(
Expand All @@ -68,6 +71,7 @@ public function testSerializeUidToXmlWithCData(AbstractUid $uid): void
/**
* @dataProvider dataUid
*/
#[DataProvider('dataUid')]
public function testSerializeUidToXmlWithoutCData(AbstractUid $uid): void
{
self::assertXmlStringEqualsXmlString(
Expand Down Expand Up @@ -117,6 +121,7 @@ public function testSerializeUidRejectsInvalidFormat(): void
/**
* @dataProvider dataUid
*/
#[DataProvider('dataUid')]
public function testDeserializeUidFromJson(AbstractUid $uid): void
{
self::assertTrue($uid->equals($this->createSerializer()->deserialize(sprintf('"%s"', (string) $uid), \get_class($uid), 'json')));
Expand All @@ -125,6 +130,7 @@ public function testDeserializeUidFromJson(AbstractUid $uid): void
/**
* @dataProvider dataUid
*/
#[DataProvider('dataUid')]
public function testDeserializeUidFromXml(AbstractUid $uid): void
{
self::assertTrue($uid->equals($this->createSerializer()->deserialize(sprintf('<?xml version="1.0" encoding="UTF-8"?><result>%s</result>', (string) $uid), \get_class($uid), 'xml')));
Expand Down
Loading
Loading