Skip to content

Commit

Permalink
Migrate to static data providers using rector/rector
Browse files Browse the repository at this point in the history
  • Loading branch information
OskarStark authored and nicolas-grekas committed Feb 14, 2023
1 parent 505c736 commit 5e325f3
Show file tree
Hide file tree
Showing 16 changed files with 27 additions and 27 deletions.
8 changes: 4 additions & 4 deletions Tests/Annotation/ContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function testThrowsOnEmptyContextLegacy(callable $factory)
$factory();
}

public function provideTestThrowsOnEmptyContextLegacyData(): iterable
public static function provideTestThrowsOnEmptyContextLegacyData(): iterable
{
yield 'doctrine-style: value option as empty array' => [function () { new Context(['value' => []]); }];
yield 'doctrine-style: context option as empty array' => [function () { new Context(['context' => []]); }];
Expand All @@ -70,7 +70,7 @@ public function testThrowsOnNonArrayContext(array $options)
new Context($options);
}

public function provideTestThrowsOnNonArrayContextData(): iterable
public static function provideTestThrowsOnNonArrayContextData(): iterable
{
yield 'non-array context' => [['context' => 'not_an_array']];
yield 'non-array normalization context' => [['normalizationContext' => 'not_an_array']];
Expand Down Expand Up @@ -136,7 +136,7 @@ public function testValidInputs(callable $factory, string $expectedDump)
$this->assertDumpEquals($expectedDump, $factory());
}

public function provideValidInputs(): iterable
public static function provideValidInputs(): iterable
{
yield 'named arguments: with context option' => [
function () { return new Context(...['context' => ['foo' => 'bar']]); },
Expand Down Expand Up @@ -224,7 +224,7 @@ public function testValidLegacyInputs(callable $factory, string $expectedDump)
$this->assertDumpEquals($expectedDump, $factory());
}

public function provideValidLegacyInputs(): iterable
public static function provideValidLegacyInputs(): iterable
{
yield 'doctrine-style: with context option' => [
function () { return new Context(['context' => ['foo' => 'bar']]); },
Expand Down
2 changes: 1 addition & 1 deletion Tests/Annotation/MaxDepthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function testNotSetMaxDepthParameter()
new MaxDepth([]);
}

public function provideInvalidValues()
public static function provideInvalidValues()
{
return [
[''],
Expand Down
2 changes: 1 addition & 1 deletion Tests/Annotation/SerializedNameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function testNotSetSerializedNameParameter()
new SerializedName([]);
}

public function provideInvalidValues(): array
public static function provideInvalidValues(): array
{
return [
[''],
Expand Down
2 changes: 1 addition & 1 deletion Tests/DeserializeNestedArrayOfObjectsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

class DeserializeNestedArrayOfObjectsTest extends TestCase
{
public function provider()
public static function provider()
{
return [
// from property PhpDoc
Expand Down
4 changes: 2 additions & 2 deletions Tests/Encoder/JsonDecodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function testDecode($toDecode, $expected, $context)
);
}

public function decodeProvider()
public static function decodeProvider()
{
$stdClass = new \stdClass();
$stdClass->foo = 'bar';
Expand All @@ -65,7 +65,7 @@ public function testDecodeWithException($value)
$this->decode->decode($value, JsonEncoder::FORMAT);
}

public function decodeProviderException()
public static function decodeProviderException()
{
return [
["{'foo': 'bar'}"],
Expand Down
2 changes: 1 addition & 1 deletion Tests/Encoder/JsonEncodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function testEncode($toEncode, $expected, $context)
);
}

public function encodeProvider()
public static function encodeProvider()
{
return [
[[], '[]', []],
Expand Down
2 changes: 1 addition & 1 deletion Tests/Mapping/Factory/CompiledClassMetadataFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function testItDelegatesHasMetadataForCall()
$this->assertTrue($compiledClassMetadataFactory->hasMetadataFor(SerializedNameDummy::class));
}

public function valueProvider()
public static function valueProvider()
{
return [
[Dummy::class],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function testDenormalize($underscored, $camelCased, $useLowerCamelCase)
$this->assertEquals($nameConverter->denormalize($underscored), $camelCased);
}

public function attributeProvider()
public static function attributeProvider()
{
return [
['coop_tilleuls', 'coopTilleuls', true],
Expand Down
6 changes: 3 additions & 3 deletions Tests/NameConverter/MetadataAwareNameConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function testDenormalizeWithFallback($expected, $propertyName)
$this->assertEquals($expected, $nameConverter->denormalize($propertyName, SerializedNameDummy::class));
}

public function attributeProvider(): array
public static function attributeProvider(): array
{
return [
['foo', 'baz'],
Expand All @@ -107,7 +107,7 @@ public function attributeProvider(): array
];
}

public function fallbackAttributeProvider(): array
public static function fallbackAttributeProvider(): array
{
return [
['foo', 'baz'],
Expand Down Expand Up @@ -141,7 +141,7 @@ public function testDenormalizeWithGroups($expected, $propertyName, $context = [
$this->assertEquals($expected, $nameConverter->denormalize($propertyName, OtherSerializedNameDummy::class, null, $context));
}

public function attributeAndContextProvider()
public static function attributeAndContextProvider()
{
return [
['buz', 'buz', ['groups' => ['a']]],
Expand Down
2 changes: 1 addition & 1 deletion Tests/Normalizer/AbstractNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public function testObjectWithVariadicConstructorTypedArguments(AbstractNormaliz
}
}

public function getNormalizer()
public static function getNormalizer()
{
$extractor = new PhpDocExtractor();

Expand Down
2 changes: 1 addition & 1 deletion Tests/Normalizer/ConstraintViolationListNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function testNormalizePayloadFields($fields, array $expected = null)
$this->assertSame($expected, $violation['payload']);
}

public function payloadFieldsProvider(): iterable
public static function payloadFieldsProvider(): iterable
{
yield [['severity', 'anotherField1'], ['severity' => 'warning']];
yield [null, ['severity' => 'warning', 'anotherField2' => 'aValue']];
Expand Down
4 changes: 2 additions & 2 deletions Tests/Normalizer/DataUriNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public function testInvalidData($uri)
$this->normalizer->denormalize($uri, 'SplFileObject');
}

public function invalidUriProvider()
public static function invalidUriProvider()
{
return [
['dataxbase64'],
Expand All @@ -156,7 +156,7 @@ public function testValidData($uri)
$this->assertInstanceOf(\SplFileObject::class, $this->normalizer->denormalize($uri, 'SplFileObject'));
}

public function validUriProvider()
public static function validUriProvider()
{
return [
['data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD///+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4Ug9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC'],
Expand Down
2 changes: 1 addition & 1 deletion Tests/Normalizer/DateIntervalNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected function setUp(): void
$this->normalizer = new DateIntervalNormalizer();
}

public function dataProviderISO()
public static function dataProviderISO()
{
$data = [
['P%YY%MM%DDT%HH%IM%SS', 'P00Y00M00DT00H00M00S', 'PT0S'],
Expand Down
6 changes: 3 additions & 3 deletions Tests/Normalizer/DateTimeNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function testNormalizeUsingTimeZonePassedInContext($expected, $input, $ti
]));
}

public function normalizeUsingTimeZonePassedInContextProvider()
public static function normalizeUsingTimeZonePassedInContextProvider()
{
yield ['2016-12-01T00:00:00+00:00', new \DateTime('2016/12/01', new \DateTimeZone('UTC')), null];
yield ['2016-12-01T00:00:00+09:00', new \DateTime('2016/12/01', new \DateTimeZone('Japan')), new \DateTimeZone('Japan')];
Expand All @@ -99,7 +99,7 @@ public function testNormalizeUsingTimeZonePassedInContextAndFormattedWithMicrose
);
}

public function normalizeUsingTimeZonePassedInContextAndExpectedFormatWithMicrosecondsProvider()
public static function normalizeUsingTimeZonePassedInContextAndExpectedFormatWithMicrosecondsProvider()
{
yield [
'2018-12-01T18:03:06.067634',
Expand Down Expand Up @@ -211,7 +211,7 @@ public function testDenormalizeUsingTimezonePassedInContext($input, $expected, $
$this->assertEquals($expected, $actual);
}

public function denormalizeUsingTimezonePassedInContextProvider()
public static function denormalizeUsingTimezonePassedInContextProvider()
{
yield 'with timezone' => [
'2016/12/01 17:35:00',
Expand Down
4 changes: 2 additions & 2 deletions Tests/Normalizer/UidNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function testSupportsNormalization()
$this->assertFalse($this->normalizer->supportsNormalization(new \stdClass()));
}

public function normalizeProvider()
public static function normalizeProvider()
{
$uidFormats = [null, 'canonical', 'base58', 'base32', 'rfc4122'];
$data = [
Expand Down Expand Up @@ -117,7 +117,7 @@ public function testNormalize(string $expected, AbstractUid $uid, ?string $uidFo
] : []));
}

public function dataProvider()
public static function dataProvider()
{
return [
['9b7541de-6f87-11ea-ab3c-9da9a81562fc', UuidV1::class],
Expand Down
4 changes: 2 additions & 2 deletions Tests/SerializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ public function testNormalizeTransformEmptyArrayObjectToArray()
$this->assertSame('{"foo":[],"bar":["notempty"],"baz":{"nested":[]},"a":{"nested":[]},"b":[]}', $serializer->serialize($object, 'json'));
}

public function provideObjectOrCollectionTests()
public static function provideObjectOrCollectionTests()
{
$serializer = new Serializer(
[
Expand Down Expand Up @@ -1238,7 +1238,7 @@ public function testNoCollectDenormalizationErrorsWithWrongEnum()
}
}

public function provideCollectDenormalizationErrors()
public static function provideCollectDenormalizationErrors()
{
return [
[null],
Expand Down

0 comments on commit 5e325f3

Please sign in to comment.