8000 [Tests] Declare static data providers by alexandre-daubois · Pull Request #48953 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Tests] Declare static data providers #48953

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

Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
[Tests] Declare static data providers
  • Loading branch information
alexandre-daubois committed Jan 11, 2023
commit c750d0367b4700615909f6e67158a6d3e1c1624a
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Twig/Tests/AppVariableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function testDebug($debugFlag)
$this->assertEquals($debugFlag, $this->appVariable->getDebug());
}

public function debugDataProvider()
public static function debugDataProvider()
{
return [
'debug on' => [true],
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php
< 8000 td id="diff-a5a5638c8a617d2d54ce131c6ee7989ee88d485aad4c9b6b9d2da31bccf111d7L86" data-line-number="86" class="blob-num blob-num-context js-linkable-line-number">
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function testDebugTemplateName(array $input, string $output, array $paths
$this->assertStringMatchesFormat($output, $tester->getDisplay(true));
}

public function getDebugTemplateNameTestData()
public static function getDebugTemplateNameTestData()
{
$defaultPaths = [
'templates/' => null,
Expand Down Expand Up @@ -315,7 +315,7 @@ public function testComplete(array $input, array $expectedSuggestions)
$this->assertSame($expectedSuggestions, $suggestions);
}

public function provideCompletionSuggestions(): iterable
public static function provideCompletionSuggestions(): iterable
{
yield 'name' => [['email'], []];
yield 'option --format' => [['--format', ''], ['text', 'json']];
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,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 src/Symfony/Bridge/Twig/Tests/Extension/CodeExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ public function testGettingMethodAbbreviation($method, $abbr)
$this->assertEquals($this->getExtension()->abbrMethod($method), $abbr);
}

public function getClassNameProvider(): array
public static function getClassNameProvider(): array
{
return [
['F\Q\N\Foo', '<abbr title="F\Q\N\Foo">Foo</abbr>'],
['Bare', '<abbr title="Bare">Bare</abbr>'],
];
}

public function getMethodNameProvider(): array
public static function getMethodNameProvider(): array
{
return [
['F\Q\N\Foo::Method', '<abbr title="F\Q\N\Foo">Foo</abbr>::Method()'],
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function testDumpTag($template, $debug, $expectedOutput, $expectedDumped)
$this->assertSame($expectedDumped, $dumped);
}

public function getDumpTags()
public static function getDumpTags()
{
return [
['A{% dump %}B', true, 'AB', []],
Expand Down Expand Up @@ -88,7 +88,7 @@ public function testDump($context, $args, $expectedOutput, $debug = true)
$this->assertEquals($expectedOutput, $dump);
}

public function getDumpArgs()
public static function getDumpArgs()
{
return [
[[], [], '', false],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function testThemeBlockInheritanceUsingDynamicExtend()
);
}

public function isSelectedChoiceProvider()
public static function isSelectedChoiceProvider()
{
return [
[true, '0', '0'],
Expand Down Expand Up @@ -150,7 +150,7 @@ public function testStartTagHasActionAttributeWhenActionIsZero()
$this->assertSame('<form name="form" method="get" action="0">', $html);
}

public function isRootFormProvider()
public static function isRootFormProvider()
{
return [
[true, new FormView()],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function testGenerateAbsoluteUrl($expected, $path, $pathinfo)
$this->assertEquals($expected, $extension->generateAbsoluteUrl($path));
}

public function getGenerateAbsoluteUrlData()
public static function getGenerateAbsoluteUrlData()
{
return [
['http://localhost/foo.png', '/foo.png', '/foo/bar.html'],
Expand Down Expand Up @@ -84,7 +84,7 @@ public function testGenerateAbsoluteUrlWithoutRequestAndRequestContext($path)
$this->assertEquals($path, $extension->generateAbsoluteUrl($path));
}

public function getGenerateAbsoluteUrlRequestContextData()
public static function getGenerateAbsoluteUrlRequestContextData()
{
return [
['/foo.png', '/foo', 'localhost', 'http', 80, 443, 'http://localhost/foo.png'],
Expand Down Expand Up @@ -129,7 +129,7 @@ public function testGenerateRelativePath($expected, $path, $pathinfo)
$this->assertEquals($expected, $extension->generateRelativePath($path));
}

public function getGenerateRelativePathData()
public static function getGenerateRelativePathData()
{
return [
['../foo.png', '/foo.png', '/foo/bar.html'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function testEscaping($template, $mustBeEscaped)
$this->assertSame($mustBeEscaped, $nodes->getNode('body')->getNode(0)->getNode('expr') instanceof FilterExpression);
}

public function getEscapingTemplates()
public static function getEscapingTemplates()
{
return [
['{{ path("foo") }}', false],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function testSerializeFilter(string $template, string $expectedResult)
self::assertSame($expectedResult, $twig->render('template', ['object' => new SerializerModelFixture()]));
}

public function serializerDataProvider(): \Generator
public static function serializerDataProvider(): \Generator
{
yield ['{{ object|serialize }}', '{&quot;name&quot;:&quot;howdy&quot;,&quot;title&quot;:&quot;fixture&quot;}'];
yield ['{{ object|serialize(\'yaml\') }}', '{ name: howdy, title: fixture }'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function testTiming($template, $events)
}
}

public function getTimingTemplates()
public static function getTimingTemplates()
{
return [
['{% stopwatch "foo" %}something{% endstopwatch %}', 'foo'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function testTransComplexBody()
$this->getTemplate("{% trans %}\n{{ 1 + 2 }}{% endtrans %}")->render();
}

public function getTransTests()
public static function getTransTests()
{
return [
// trans tag
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function testNewModuleWithoutDefaultDomainTag(Node $node)
$this->assertEquals([[self::$message, null]], $visitor->getMessages());
}

public function getDefaultDomainAssignmentTestData()
public static function getDefaultDomainAssignmentTestData()
{
return [
[TwigNodeProvider::getTransFilter(self::$message)],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function testMessageExtractionWithInvalidDomainNode()
$this->testMessagesExtraction($node, [[$message, TranslationNodeVisitor::UNDEFINED_DOMAIN]]);
}

public function getMessagesExtractionTestData()
public static function getMessagesExtractionTestData()
{
$message = 'new key';
$domain = 'domain';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function testCompile($source, $expected)
$this->assertEquals($expected, $parser->parse($stream)->getNode('body')->getNode(0));
}

public function getTestsForFormTheme()
public static function getTestsForFormTheme()
{
return [
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function testExtract($template, $messages)
}
}

public function getExtractData()
public static function getExtractData()
{
return [
['{{ "new key" | trans() }}', ['new key' => 'messages']],
Expand Down Expand Up @@ -102,7 +102,7 @@ public function testExtractSyntaxError($resources, array $messages)
$this->assertSame($messages, $catalogue->all());
}

public function resourcesWithSyntaxErrorsProvider(): array
public static function resourcesWithSyntaxErrorsProvider(): array
{
return [
[__DIR__.'/../Fixtures', ['messages' => ['Hi!' => 'Hi!']]],
Expand Down Expand Up @@ -133,7 +133,7 @@ public function testExtractWithFiles($resource)
$this->assertEquals('Hi!', $catalogue->get('Hi!', 'messages'));
}

public function resourceProvider(): array
public static function resourceProvider(): array
{
$directory = __DIR__.'/../Fixtures/extractor/';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function testUnsetClosureFileInfoShouldBeRegisteredInVarCloner()
$this->assertTrue($called);
}

public function provideServicesUsingDumpDestinationCreation(): array
public static function provideServicesUsingDumpDestinationCreation(): array
{
return [
['tcp://localhost:1234', 'tcp://localhost:1234', null],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function testWarmUp(array $loaders)
$this->assertTrue($arrayPool->getItem('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Author')->isHit());
}

public function loaderProvider()
public static function loaderProvider()
{
return [
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function testComplete(array $input, array $expectedSuggestions)
$this->assertSame($expectedSuggestions, $suggestions);
}

public function provideCompletionSuggestions()
public static function provideCompletionSuggestions()
{
yield 'pool_name' => [
['f'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function testComplete(array $input, array $expectedSuggestions)
$this->assertSame($expectedSuggestions, $suggestions);
}

public function provideCompletionSuggestions()
public static function provideCompletionSuggestions()
{
yield 'pool_name' => [
['f'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function testComplete(array $input, array $expectedSuggestions)
$this->assertSame($expectedSuggestions, $suggestions);
}

public function provideCompletionSuggestions()
public static function provideCompletionSuggestions()
{
yield 'event' => [[''], ['Symfony\Component\Mailer\Event\MessageEvent', 'console.command']];
yield 'event for other dispatcher' => [['--dispatcher', 'other_event_dispatcher', ''], ['other_event', 'App\OtherEvent']];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function testComplete(bool $withLocalVault, array $input, array $expected
$this->assertSame($expectedSuggestions, $suggestions);
}

public function provideCompletionSuggestions()
public static function provideCompletionSuggestions()
{
yield 'name' => [true, [''], ['SECRET', 'OTHER_SECRET']];
yield '--local name (with local vault)' => [true, ['--local', ''], ['SECRET']];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function testComplete(array $input, array $expectedSuggestions)
$this->assertSame($expectedSuggestions, $suggestions);
}

public function provideCompletionSuggestions()
public static function provideCompletionSuggestions()
{
yield 'name' => [[''], ['SECRET', 'OTHER_SECRET']];
yield '--local name (with local vault)' => [['--local', ''], ['SECRET', 'OTHER_SECRET']];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ function ($path, $catalogue) use ($extractedMessagesWithDomains) {
$this->assertSame($expectedSuggestions, $suggestions);
}

public function provideCompletionSuggestions()
public static function provideCompletionSuggestions()
{
yield 'locale' => [
[''],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function testComplete(array $input, array $expectedSuggestions)
$this->assertSame($expectedSuggestions, $suggestions);
}

public function provideCompletionSuggestions()
public static function provideCompletionSuggestions()
{
$bundle = new ExtensionPresentBundle();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function testComplete(array $input, array $expectedSuggestions)
$this->assertSame($expectedSuggestions, $suggestions);
}

public function provideCompletionSuggestions(): iterable
public static function provideCompletionSuggestions(): iterable
{
yield 'option --dump-format' => [['--dump-format', ''], ['puml', 'mermaid', 'dot']];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public function testGetClassDescription($object, $expectedDescription)
$this->assertEquals($expectedDescription, $this->getDescriptor()->getClassDescription($object));
}

public function getClassDescriptionTestData()
public static function getClassDescriptionTestData()
{
return [
[ClassWithDocCommentOnMultipleLines::class, 'This is the first line of the description. This is the second line.'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function testRoute($permanent, $keepRequestMethod, $keepQueryParams, $ign
$this->assertEquals($expectedCode, $returnResponse->getStatusCode());
}

public function provider()
public static function provider()
{
return [
[true, false, false, false, 301, ['additional-parameter' => 'value']],
Expand Down Expand Up @@ -210,7 +210,7 @@ public function testUrlRedirectDefaultPorts()
$this->assertRedirectUrl($returnValue, $expectedUrl);
}

public function urlRedirectProvider()
public static function urlRedirectProvider()
{
return [
// Standard ports
Expand Down Expand Up @@ -262,7 +262,7 @@ public function testUrlRedirect($scheme, $httpPort, $httpsPort, $requestScheme,
$this->assertRedirectUrl($returnValue, $expectedUrl);
}

public function pathQueryParamsProvider()
public static function pathQueryParamsProvider()
{
return [
['http://www.example.com/base/redirect-path', '/redirect-path', ''],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function testProcessKeepsDataCollectorIfTranslatorImplementsTranslatorBag
$this->assertTrue($this->container->hasDefinition('data_collector.translation'));
}

public function getImplementingTranslatorBagInterfaceTranslatorClassNames()
public static function getImplementingTranslatorBagInterfaceTranslatorClassNames()
{
return [
['Symfony\Component\Translation\Translator'],
Expand Down Expand Up @@ -97,7 +97,7 @@ public function testProcessRemovesDataCollectorIfTranslatorDoesNotImplementTrans
$this->assertFalse($this->container->hasDefinition('data_collector.translation'));
}

public function getNotImplementingTranslatorBagInterfaceTranslatorClassNames()
public static function getNotImplementingTranslatorBagInterfaceTranslatorClassNames()
{
return [
['Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\TranslatorWithTranslatorBag'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function testValidCollector()
$this->assertEquals('add', $methodCalls[0][0]); // grab the method part of the first call
}

public function provideValidCollectorWithTemplateUsingAutoconfigure(): \Generator
public static function provideValidCollectorWithTemplateUsingAutoconfigure(): \Generator
{
yield [new class() implements TemplateAwareDataCollectorInterface {
public function collect(Request $request, Response $response, \Throwable $exception = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function testInvalidSessionName($sessionName)
);
}

public function getTestInvalidSessionName()
public static function getTestInvalidSessionName()
{
return [
['a.b'],
Expand Down Expand Up @@ -113,7 +113,7 @@ public function testValidAssetsPackageNameConfiguration($packageName)
$this->assertArrayHasKey($packageName, $config['assets']['packages']);
}

public function provideValidAssetsPackageNameConfigurationTests()
public static function provideValidAssetsPackageNameConfigurationTests()
{
return [
['foobar'],
Expand All @@ -139,7 +139,7 @@ public function testInvalidAssetsConfiguration(array $assetConfig, $expectedMess
]);
}

public function provideInvalidAssetConfigurationTests()
public static function provideInvalidAssetConfigurationTests()
{
// helper to turn config into embedded package config
$createPackageConfig = function (array $packageConfig) {
Expand Down Expand Up @@ -192,7 +192,7 @@ public function testValidLockConfiguration($lockConfig, $processedConfig)
$this->assertEquals($processedConfig, $config['lock']);
}

public function provideValidLockConfigurationTests()
public static function provideValidLockConfigurationTests()
{
yield [null, ['enabled' => true, 'resources' => ['default' => [class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphore' : 'flock']]]];

Expand Down
Loading
0