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 4b81c20 commit 0b4af14
Show file tree
Hide file tree
Showing 30 changed files with 59 additions and 59 deletions.
6 changes: 3 additions & 3 deletions Tests/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ public function testFindWithAmbiguousAbbreviations($abbreviation, $expectedExcep
$application->find($abbreviation);
}

public function provideAmbiguousAbbreviations()
public static function provideAmbiguousAbbreviations()
{
return [
['f', 'Command "f" is not defined.'],
Expand Down Expand Up @@ -547,7 +547,7 @@ public function testDontRunAlternativeCommandName()
$this->assertStringContainsString('Do you want to run "foo" instead? (yes/no) [no]:', $display);
}

public function provideInvalidCommandNamesSingle()
public static function provideInvalidCommandNamesSingle()
{
return [
['foo3:barr'],
Expand Down Expand Up @@ -1239,7 +1239,7 @@ public function testAddingAlreadySetDefinitionElementData($def)
$application->run($input, $output);
}

public function getAddingAlreadySetDefinitionElementData()
public static function getAddingAlreadySetDefinitionElementData()
{
return [
[new InputArgument('command', InputArgument::REQUIRED)],
Expand Down
2 changes: 1 addition & 1 deletion Tests/CI/GithubActionReporterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function testAnnotationsFormat(string $type, string $message, string $fil
self::assertSame($expected.\PHP_EOL, $buffer->fetch());
}

public function annotationsFormatProvider(): iterable
public static function annotationsFormatProvider(): iterable
{
yield 'warning' => ['warning', 'A warning', null, null, null, '::warning::A warning'];
yield 'error' => ['error', 'An error', null, null, null, '::error::An error'];
Expand Down
4 changes: 2 additions & 2 deletions Tests/Command/CommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function testInvalidCommandNames($name)
$command->setName($name);
}

public function provideInvalidCommandNames()
public static function provideInvalidCommandNames()
{
return [
[''],
Expand Down Expand Up @@ -338,7 +338,7 @@ public function testSetCode()
$this->assertEquals('interact called'.\PHP_EOL.'from the code...'.\PHP_EOL, $tester->getDisplay());
}

public function getSetCodeBindToClosureTests()
public static function getSetCodeBindToClosureTests()
{
return [
[true, 'not bound to the command'],
Expand Down
6 changes: 3 additions & 3 deletions Tests/Command/CompleteCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function testInputAndCurrentOptionValidation(array $input, ?string $excep
}
}

public function provideInputAndCurrentOptionValues()
public static function provideInputAndCurrentOptionValues()
{
yield [[], 'The "--current" option must be set and it must be an integer'];
yield [['--current' => 'a'], 'The "--current" option must be set and it must be an integer'];
Expand All @@ -100,7 +100,7 @@ public function testCompleteCommandName(array $input, array $suggestions)
$this->assertEquals(implode("\n", $suggestions).\PHP_EOL, $this->tester->getDisplay());
}

public function provideCompleteCommandNameInputs()
public static function provideCompleteCommandNameInputs()
{
yield 'empty' => [['bin/console'], ['help', 'list', 'completion', 'hello', 'ahoy']];
yield 'partial' => [['bin/console', 'he'], ['help', 'list', 'completion', 'hello', 'ahoy']];
Expand All @@ -117,7 +117,7 @@ public function testCompleteCommandInputDefinition(array $input, array $suggesti
$this->assertEquals(implode("\n", $suggestions).\PHP_EOL, $this->tester->getDisplay());
}

public function provideCompleteCommandInputDefinitionInputs()
public static function provideCompleteCommandInputDefinitionInputs()
{
yield 'definition' => [['bin/console', 'hello', '-'], ['--help', '--quiet', '--verbose', '--version', '--ansi', '--no-ansi', '--no-interaction']];
yield 'custom' => [['bin/console', 'hello'], ['Fabien', 'Robin', 'Wouter']];
Expand Down
2 changes: 1 addition & 1 deletion Tests/Command/DumpCompletionCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function testComplete(array $input, array $expectedSuggestions)
$this->assertSame($expectedSuggestions, $suggestions);
}

public function provideCompletionSuggestions()
public static function provideCompletionSuggestions()
{
yield 'shell' => [
[''],
Expand Down
2 changes: 1 addition & 1 deletion Tests/Command/HelpCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function testComplete(array $input, array $expectedSuggestions)
$this->assertSame($expectedSuggestions, $suggestions);
}

public function provideCompletionSuggestions()
public static function provideCompletionSuggestions()
{
yield 'option --format' => [
['--format', ''],
Expand Down
2 changes: 1 addition & 1 deletion Tests/Command/ListCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function testComplete(array $input, array $expectedSuggestions)
$this->assertSame($expectedSuggestions, $suggestions);
}

public function provideCompletionSuggestions()
public static function provideCompletionSuggestions()
{
yield 'option --format' => [
['--format', ''],
Expand Down
6 changes: 3 additions & 3 deletions Tests/Completion/CompletionInputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function testBind(CompletionInput $input, string $expectedType, ?string $
$this->assertEquals($expectedValue, $input->getCompletionValue(), 'Unexpected value');
}

public function provideBindData()
public static function provideBindData()
{
// option names
yield 'optname-minimal-input' => [CompletionInput::fromTokens(['bin/console', '-'], 1), CompletionInput::TYPE_OPTION_NAME, null, '-'];
Expand Down Expand Up @@ -90,7 +90,7 @@ public function testBindWithLastArrayArgument(CompletionInput $input, ?string $e
$this->assertEquals($expectedValue, $input->getCompletionValue(), 'Unexpected value');
}

public function provideBindWithLastArrayArgumentData()
public static function provideBindWithLastArrayArgumentData()
{
yield [CompletionInput::fromTokens(['bin/console'], 1), null];
yield [CompletionInput::fromTokens(['bin/console', 'symfony', 'sensiolabs'], 3), null];
Expand Down Expand Up @@ -124,7 +124,7 @@ public function testFromString($inputStr, array $expectedTokens)
$this->assertEquals($expectedTokens, $tokensProperty->getValue($input));
}

public function provideFromStringData()
public static function provideFromStringData()
{
yield ['bin/console cache:clear', ['bin/console', 'cache:clear']];
yield ['bin/console --env prod', ['bin/console', '--env', 'prod']];
Expand Down
2 changes: 1 addition & 1 deletion Tests/DependencyInjection/AddConsoleCommandPassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function testProcessFallsBackToDefaultName()
$this->assertSame(['new-name' => 'with-default-name'], $container->getDefinition('console.command_loader')->getArgument(1));
}

public function visibilityProvider()
public static function visibilityProvider()
{
return [
[true],
Expand Down
2 changes: 1 addition & 1 deletion Tests/Descriptor/ApplicationDescriptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function testGetNamespaces(array $expected, array $names)
$this->assertSame($expected, array_keys((new ApplicationDescription($application))->getNamespaces()));
}

public function getNamespacesProvider()
public static function getNamespacesProvider()
{
return [
[['_global'], ['foobar']],
Expand Down
4 changes: 2 additions & 2 deletions Tests/Formatter/OutputFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public function testInlineStyleOptions(string $tag, string $expected = null, str
}
}

public function provideInlineStyleOptionsCases()
public static function provideInlineStyleOptionsCases()
{
return [
['<unknown=_unknown_>'],
Expand Down Expand Up @@ -258,7 +258,7 @@ public function testNotDecoratedFormatter(string $input, string $expectedNonDeco
}
}

public function provideDecoratedAndNonDecoratedOutput()
public static function provideDecoratedAndNonDecoratedOutput()
{
return [
['<error>some error</error>', 'some error', "\033[37;41msome error\033[39;49m"],
Expand Down
2 changes: 1 addition & 1 deletion Tests/Helper/DumperNativeFallbackTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function testInvoke($variable, $primitiveString)
$this->assertSame($primitiveString, $dumper($variable));
}

public function provideVariables()
public static function provideVariables()
{
return [
[null, 'null'],
Expand Down
2 changes: 1 addition & 1 deletion Tests/Helper/DumperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function testInvoke($variable)
$this->assertDumpMatchesFormat($dumper($variable), $variable);
}

public function provideVariables()
public static function provideVariables()
{
return [
[null],
Expand Down
4 changes: 2 additions & 2 deletions Tests/Helper/HelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

class HelperTest extends TestCase
{
public function formatTimeProvider()
public static function formatTimeProvider()
{
return [
[0, '< 1 sec'],
Expand All @@ -43,7 +43,7 @@ public function formatTimeProvider()
];
}

public function decoratedTextProvider()
public static function decoratedTextProvider()
{
return [
['abc', 'abc'],
Expand Down
2 changes: 1 addition & 1 deletion Tests/Helper/ProcessHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function testPassedCallbackIsExecuted()
$this->assertTrue($executed);
}

public function provideCommandsAndOutput()
public static function provideCommandsAndOutput()
{
$successOutputVerbose = <<<'EOT'
RUN php -r "echo 42;"
Expand Down
2 changes: 1 addition & 1 deletion Tests/Helper/ProgressBarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ public function testFormatsWithoutMax($format)
/**
* Provides each defined format.
*/
public function provideFormat(): array
public static function provideFormat(): array
{
return [
['normal'],
Expand Down
2 changes: 1 addition & 1 deletion Tests/Helper/ProgressIndicatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function testFormats($format)
/**
* Provides each defined format.
*/
public function provideFormat(): array
public static function provideFormat(): array
{
return [
['normal'],
Expand Down
10 changes: 5 additions & 5 deletions Tests/Helper/QuestionHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ public function testAskWithAutocompleteWithExactMatch()
$this->assertSame('b', $dialog->ask($this->createStreamableInputInterfaceMock($inputStream), $this->createOutputInterface(), $question));
}

public function getInputs()
public static function getInputs()
{
return [
['$'], // 1 byte character
Expand Down Expand Up @@ -536,7 +536,7 @@ public function testAskConfirmation($question, $expected, $default = true)
$this->assertEquals($expected, $dialog->ask($this->createStreamableInputInterfaceMock($inputStream), $this->createOutputInterface(), $question), 'confirmation question should '.($expected ? 'pass' : 'cancel'));
}

public function getAskConfirmationData()
public static function getAskConfirmationData()
{
return [
['', true],
Expand Down Expand Up @@ -612,7 +612,7 @@ public function testSelectChoiceFromSimpleChoices($providedAnswer, $expectedValu
$this->assertSame($expectedValue, $answer);
}

public function simpleAnswerProvider()
public static function simpleAnswerProvider()
{
return [
[0, 'My environment 1'],
Expand Down Expand Up @@ -647,7 +647,7 @@ public function testSpecialCharacterChoiceFromMultipleChoiceList($providedAnswer
$this->assertSame($expectedValue, $answer);
}

public function specialCharacterInMultipleChoice()
public static function specialCharacterInMultipleChoice()
{
return [
['.', ['.']],
Expand Down Expand Up @@ -697,7 +697,7 @@ public function testAmbiguousChoiceFromChoicelist()
$dialog->ask($this->createStreamableInputInterfaceMock($this->getInputStream("My environment\n")), $this->createOutputInterface(), $question);
}

public function answerProvider()
public static function answerProvider()
{
return [
['env_1', 'env_1'],
Expand Down
6 changes: 3 additions & 3 deletions Tests/Helper/TableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function testRenderAddRowsOneByOne($headers, $rows, $style, $expected, $d
$this->assertEquals($expected, $this->getOutputContent($output));
}

public function renderProvider()
public static function renderProvider()
{
$books = [
['99921-58-10-7', 'Divine Comedy', 'Dante Alighieri'],
Expand Down Expand Up @@ -1268,7 +1268,7 @@ public function testSetTitle($headerTitle, $footerTitle, $style, $expected)
$this->assertEquals($expected, $this->getOutputContent($output));
}

public function renderSetTitle()
public static function renderSetTitle()
{
return [
[
Expand Down Expand Up @@ -1481,7 +1481,7 @@ public function testBoxedStyleWithColspan()
$this->assertSame($expected, $this->getOutputContent($output));
}

public function provideRenderHorizontalTests()
public static function provideRenderHorizontalTests()
{
$headers = ['foo', 'bar', 'baz'];
$rows = [['one', 'two', 'tree'], ['1', '2', '3']];
Expand Down
10 changes: 5 additions & 5 deletions Tests/Input/ArgvInputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function testParseOptionsNegatable($input, $options, $expectedOptions, $m
$this->assertEquals($expectedOptions, $input->getOptions(), $message);
}

public function provideOptions()
public static function provideOptions()
{
return [
[
Expand Down Expand Up @@ -187,7 +187,7 @@ public function provideOptions()
];
}

public function provideNegatableOptions()
public static function provideNegatableOptions()
{
return [
[
Expand Down Expand Up @@ -259,7 +259,7 @@ public function testInvalidInputNegatable($argv, $definition, $expectedException
$input->bind($definition);
}

public function provideInvalidInput()
public static function provideInvalidInput()
{
return [
[
Expand Down Expand Up @@ -330,7 +330,7 @@ public function provideInvalidInput()
];
}

public function provideInvalidNegatableInput()
public static function provideInvalidNegatableInput()
{
return [
[
Expand Down Expand Up @@ -516,7 +516,7 @@ public function testGetParameterOptionEqualSign($argv, $key, $default, $onlyPara
$this->assertEquals($expected, $input->getParameterOption($key, $default, $onlyParams), '->getParameterOption() returns the expected value');
}

public function provideGetParameterOptionValues()
public static function provideGetParameterOptionValues()
{
return [
[['app/console', 'foo:bar'], '-e', 'default', false, 'default'],
Expand Down
4 changes: 2 additions & 2 deletions Tests/Input/ArrayInputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function testParseOptions($input, $options, $expectedOptions, $message)
$this->assertEquals($expectedOptions, $input->getOptions(), $message);
}

public function provideOptions()
public static function provideOptions()
{
return [
[
Expand Down Expand Up @@ -133,7 +133,7 @@ public function testParseInvalidInput($parameters, $definition, $expectedExcepti
new ArrayInput($parameters, $definition);
}

public function provideInvalidInput()
public static function provideInvalidInput()
{
return [
[
Expand Down
2 changes: 1 addition & 1 deletion Tests/Input/InputDefinitionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ public function testGetSynopsis(InputDefinition $definition, $expectedSynopsis,
$this->assertEquals($expectedSynopsis, $definition->getSynopsis(), $message ? '->getSynopsis() '.$message : '');
}

public function getGetSynopsisData()
public static function getGetSynopsisData()
{
return [
[new InputDefinition([new InputOption('foo')]), '[--foo]', 'puts optional options in square brackets'],
Expand Down
2 changes: 1 addition & 1 deletion Tests/Input/StringInputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function testInputOptionWithGivenString()
$this->assertEquals('bar', $input->getOption('foo'));
}

public function getTokenizeData()
public static function getTokenizeData()
{
return [
['', [], '->tokenize() parses an empty string'],
Expand Down
Loading

0 comments on commit 0b4af14

Please sign in to comment.