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 7432eef commit c8336db
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion Tests/Command/LintCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public function testComplete(array $input, array $expectedSuggestions)
$this->assertSame($expectedSuggestions, $tester->complete($input));
}

public function provideCompletionSuggestions()
public static function provideCompletionSuggestions()
{
yield 'option' => [['--format', ''], ['txt', 'json', 'github']];
}
Expand Down
4 changes: 2 additions & 2 deletions Tests/DumperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public function testEscapedEscapeSequencesInQuotedScalar($input, $expected)
$this->assertSameData($input, $this->parser->parse($expected));
}

public function getEscapeSequences()
public static function getEscapeSequences()
{
return [
'empty string' => ['', "''"],
Expand Down Expand Up @@ -275,7 +275,7 @@ public function testDumpObjectAsMap($object, $expected)
$this->assertSameData($expected, $this->parser->parse($yaml, Yaml::PARSE_OBJECT_FOR_MAP));
}

public function objectAsMapProvider()
public static function objectAsMapProvider()
{
$tests = [];

Expand Down
42 changes: 21 additions & 21 deletions Tests/InlineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function testParsePhpConstants($yaml, $value)
$this->assertSame($value, $actual);
}

public function getTestsForParsePhpConstants()
public static function getTestsForParsePhpConstants()
{
return [
['!php/const Symfony\Component\Yaml\Yaml::PARSE_CONSTANT', Yaml::PARSE_CONSTANT],
Expand Down Expand Up @@ -195,7 +195,7 @@ public function testParseReferences($yaml, $expected)
$this->assertSame($expected, Inline::parse($yaml, 0, $references));
}

public function getDataForParseReferences()
public static function getDataForParseReferences()
{
return [
'scalar' => ['*var', 'var-value'],
Expand Down Expand Up @@ -245,7 +245,7 @@ public function testParseUnquotedScalarStartingWithReservedIndicator($indicator)
Inline::parse(sprintf('{ foo: %sfoo }', $indicator));
}

public function getReservedIndicators()
public static function getReservedIndicators()
{
return [['@'], ['`']];
}
Expand All @@ -261,7 +261,7 @@ public function testParseUnquotedScalarStartingWithScalarIndicator($indicator)
Inline::parse(sprintf('{ foo: %sfoo }', $indicator));
}

public function getScalarIndicators()
public static function getScalarIndicators()
{
return [['|'], ['>'], ['%']];
}
Expand All @@ -274,7 +274,7 @@ public function testIsHash($array, $expected)
$this->assertSame($expected, Inline::isHash($array));
}

public function getDataForIsHash()
public static function getDataForIsHash()
{
return [
[[], false],
Expand All @@ -284,7 +284,7 @@ public function getDataForIsHash()
];
}

public function getTestsForParse()
public static function getTestsForParse()
{
return [
['', ''],
Expand Down Expand Up @@ -370,7 +370,7 @@ public function getTestsForParse()
];
}

public function getTestsForParseWithMapObjects()
public static function getTestsForParseWithMapObjects()
{
return [
['', ''],
Expand Down Expand Up @@ -451,7 +451,7 @@ public function getTestsForParseWithMapObjects()
];
}

public function getTestsForDump()
public static function getTestsForDump()
{
return [
['null', null],
Expand Down Expand Up @@ -549,7 +549,7 @@ public function testParseTimestampAsDateTimeObject(string $yaml, int $year, int
$this->assertSame($timezone, $date->format('O'));
}

public function getTimestampTests(): array
public static function getTimestampTests(): array
{
return [
'canonical' => ['2001-12-15T02:59:43.1Z', 2001, 12, 15, 2, 59, 43, 100000, '+0000'],
Expand Down Expand Up @@ -591,7 +591,7 @@ public function testDumpUnitEnum()
$this->assertSame("!php/const Symfony\Component\Yaml\Tests\Fixtures\FooUnitEnum::BAR", Inline::dump(FooUnitEnum::BAR));
}

public function getDateTimeDumpTests()
public static function getDateTimeDumpTests()
{
$tests = [];

Expand All @@ -612,7 +612,7 @@ public function testParseBinaryData($data)
$this->assertSame('Hello world', Inline::parse($data));
}

public function getBinaryData()
public static function getBinaryData()
{
return [
'enclosed with double quotes' => ['!!binary "SGVsbG8gd29ybGQ="'],
Expand All @@ -632,7 +632,7 @@ public function testParseInvalidBinaryData($data, $expectedMessage)
Inline::parse($data);
}

public function getInvalidBinaryData()
public static function getInvalidBinaryData()
{
return [
'length not a multiple of four' => ['!!binary "SGVsbG8d29ybGQ="', '/The normalized base64 encoded data \(data without whitespace characters\) length must be a multiple of four \(\d+ bytes given\)/'],
Expand Down Expand Up @@ -674,7 +674,7 @@ public function testParseMissingMappingValueAsNull($yaml, $expected)
$this->assertSame($expected, Inline::parse($yaml));
}

public function getTestsForNullValues()
public static function getTestsForNullValues()
{
return [
'null before closing curly brace' => ['{foo:}', ['foo' => null]],
Expand All @@ -697,7 +697,7 @@ public function testImplicitStringCastingOfMappingKeysIsDeprecated($yaml, $expec
$this->assertSame($expected, Inline::parse($yaml));
}

public function getNotPhpCompatibleMappingKeyData()
public static function getNotPhpCompatibleMappingKeyData()
{
return [
'boolean-true' => ['{true: "foo"}', ['true' => 'foo']],
Expand Down Expand Up @@ -776,7 +776,7 @@ public function testParseOctalNumbers($expected, $yaml)
self::assertSame($expected, Inline::parse($yaml));
}

public function getTestsForOctalNumbers()
public static function getTestsForOctalNumbers()
{
return [
'positive octal number' => [28, '0o34'],
Expand All @@ -797,7 +797,7 @@ public function testParseOctalNumbersYaml11Notation(int $expected, string $yaml,
self::assertSame($expected, Inline::parse($yaml));
}

public function getTestsForOctalNumbersYaml11Notation()
public static function getTestsForOctalNumbersYaml11Notation()
{
return [
'positive octal number' => [28, '034', '0o34'],
Expand All @@ -818,7 +818,7 @@ public function testPhpObjectWithEmptyValue($expected, $value)
$this->assertSame($expected, Inline::parse($value, Yaml::PARSE_OBJECT));
}

public function phpObjectTagWithEmptyValueProvider()
public static function phpObjectTagWithEmptyValueProvider()
{
return [
[false, '!php/object'],
Expand All @@ -842,7 +842,7 @@ public function testPhpConstTagWithEmptyValue($expected, $value)
$this->assertSame($expected, Inline::parse($value, Yaml::PARSE_CONSTANT));
}

public function phpConstTagWithEmptyValueProvider()
public static function phpConstTagWithEmptyValueProvider()
{
return [
['', '!php/const'],
Expand Down Expand Up @@ -894,7 +894,7 @@ public function testUnquotedExclamationMarkThrows(string $value)
Inline::parse($value);
}

public function unquotedExclamationMarkThrowsProvider()
public static function unquotedExclamationMarkThrowsProvider()
{
return [
['!'],
Expand Down Expand Up @@ -926,7 +926,7 @@ public function testQuotedExclamationMark($expected, string $value)
}

// This provider should stay consistent with unquotedExclamationMarkThrowsProvider
public function quotedExclamationMarkProvider()
public static function quotedExclamationMarkProvider()
{
return [
['!', '"!"'],
Expand Down Expand Up @@ -956,7 +956,7 @@ public function testParseIdeographicSpace(string $yaml, string $expected)
$this->assertSame($expected, Inline::parse($yaml));
}

public function ideographicSpaceProvider(): array
public static function ideographicSpaceProvider(): array
{
return [
["\u{3000}", ' '],
Expand Down
32 changes: 16 additions & 16 deletions Tests/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function testTabsAsIndentationInYaml(string $given, string $expectedMessa
$this->parser->parse($given);
}

public function invalidIndentation(): array
public static function invalidIndentation(): array
{
return [
[
Expand Down Expand Up @@ -189,7 +189,7 @@ public function testValidTokenSeparation(string $given, array $expected)
$this->assertSameData($expected, $actual);
}

public function validTokenSeparators(): array
public static function validTokenSeparators(): array
{
return [
[
Expand Down Expand Up @@ -222,7 +222,7 @@ public function testEndOfTheDocumentMarker()
$this->assertEquals('foo', $this->parser->parse($yaml));
}

public function getBlockChompingTests()
public static function getBlockChompingTests()
{
$tests = [];

Expand Down Expand Up @@ -586,7 +586,7 @@ public function testObjectForMap($yaml, $expected)
$this->assertSameData($expected, $this->parser->parse($yaml, $flags));
}

public function getObjectForMapTests()
public static function getObjectForMapTests()
{
$tests = [];

Expand Down Expand Up @@ -833,7 +833,7 @@ public function testNonStringFollowedByCommentEmbeddedInMapping()
$this->assertSame($expected, $this->parser->parse($yaml));
}

public function getParseExceptionNotAffectedMultiLineStringLastResortParsing()
public static function getParseExceptionNotAffectedMultiLineStringLastResortParsing()
{
$tests = [];

Expand Down Expand Up @@ -975,7 +975,7 @@ public function testParseExceptionOnDuplicate($input, $duplicateKey, $lineNumber
Yaml::parse($input);
}

public function getParseExceptionOnDuplicateData()
public static function getParseExceptionOnDuplicateData()
{
$tests = [];

Expand Down Expand Up @@ -1280,7 +1280,7 @@ public function testCommentLikeStringsAreNotStrippedInBlockScalars($yaml, $expec
$this->assertSame($expectedParserResult, $this->parser->parse($yaml));
}

public function getCommentLikeStringInScalarBlockData()
public static function getCommentLikeStringInScalarBlockData()
{
$tests = [];

Expand Down Expand Up @@ -1465,7 +1465,7 @@ public function testParseBinaryData($data)
$this->assertSame(['data' => 'Hello world'], $this->parser->parse($data));
}

public function getBinaryData()
public static function getBinaryData()
{
return [
'enclosed with double quotes' => ['data: !!binary "SGVsbG8gd29ybGQ="'],
Expand Down Expand Up @@ -1497,7 +1497,7 @@ public function testParseInvalidBinaryData($data, $expectedMessage)
$this->parser->parse($data);
}

public function getInvalidBinaryData()
public static function getInvalidBinaryData()
{
return [
'length not a multiple of four' => ['data: !!binary "SGVsbG8d29ybGQ="', '/The normalized base64 encoded data \(data without whitespace characters\) length must be a multiple of four \(\d+ bytes given\)/'],
Expand Down Expand Up @@ -1563,7 +1563,7 @@ public function testParserThrowsExceptionWithCorrectLineNumber($lineNumber, $yam
$this->parser->parse($yaml);
}

public function parserThrowsExceptionWithCorrectLineNumberProvider()
public static function parserThrowsExceptionWithCorrectLineNumberProvider()
{
return [
[
Expand Down Expand Up @@ -1720,7 +1720,7 @@ public function testParseQuotedStringContainingEscapedQuotationCharacters(string
$this->assertSame($expected, $this->parser->parse($yaml));
}

public function escapedQuotationCharactersInQuotedStrings()
public static function escapedQuotationCharactersInQuotedStrings()
{
return [
'single quoted string' => [
Expand Down Expand Up @@ -1778,7 +1778,7 @@ public function testParseMultiLineMappingValue($yaml, $expected, $parseError)
$this->assertSame($expected, $this->parser->parse($yaml));
}

public function multiLineDataProvider()
public static function multiLineDataProvider()
{
$tests = [];

Expand Down Expand Up @@ -1845,7 +1845,7 @@ public function testInlineNotationSpanningMultipleLines($expected, string $yaml)
$this->assertSame($expected, $this->parser->parse($yaml));
}

public function inlineNotationSpanningMultipleLinesProvider(): array
public static function inlineNotationSpanningMultipleLinesProvider(): array
{
return [
'mapping' => [
Expand Down Expand Up @@ -2234,7 +2234,7 @@ public function testCustomTagSupport($expected, $yaml)
$this->assertSameData($expected, $this->parser->parse($yaml, Yaml::PARSE_CUSTOM_TAGS));
}

public function taggedValuesProvider()
public static function taggedValuesProvider()
{
return [
'scalars' => [
Expand Down Expand Up @@ -2658,7 +2658,7 @@ public function testDetectCircularReferences($yaml)
$this->parser->parse($yaml, Yaml::PARSE_CUSTOM_TAGS);
}

public function circularReferenceProvider()
public static function circularReferenceProvider()
{
$tests = [];

Expand Down Expand Up @@ -2698,7 +2698,7 @@ public function testParseIndentedMappings($yaml, $expected)
$this->assertSame($expected, $this->parser->parse($yaml));
}

public function indentedMappingData()
public static function indentedMappingData()
{
$tests = [];

Expand Down

0 comments on commit c8336db

Please sign in to comment.