8000 Use `static` data providers by OskarStark · Pull Request #48283 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Use static data providers #48283

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
wants to merge 11 commits into from
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
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .php-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8.0
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public function testSerialization($param, array $types, $expected, $explainable,
$this->assertSame($runnable, $collectedQueries['default'][0]['runnable']);
}

public function paramProvider(): array
public static function paramProvider(): array
{
return [
['some value', [], 'some value', true],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public function testFixManagersAutoMappings(array $originalEm1, array $originalE
], $expectedEm2));
}

public function providerBasicDrivers()
public static function providerBasicDrivers()
{
return [
['doctrine.orm.cache.apc.class', ['type' => 'apc']],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public function testEmbeddedIdentifierName()
$loader->getEntitiesByIds('id.value', [1, '', 2, 3, 'foo']);
}

public function provideGuidEntityClasses()
public static function provideGuidEntityClasses()
{
return [
['Symfony\Bridge\Doctrine\Tests\Fixtures\GuidIdEntity'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function testChoiceTranslationDomainIsDisabledByDefault($expanded)
}
}

public function choiceTranslationDomainProvider()
public static function choiceTranslationDomainProvider()
{
return [
[false],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public function testExtractEnum()
$this->assertNull($this->createExtractor()->getTypes(DoctrineEnum::class, 'enumCustom', []));
}

public function typesProvider()
public static function typesProvider()
{
$provider = [
['id', [new Type(Type::BUILTIN_TYPE_INT)]],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ public function testValidateResultTypes($entity1, $result)
$this->assertNoViolation();
}

public function resultTypesProvider()
public static function resultTypesProvider()
{
$entity = new SingleIntIdEntity(1, 'foo');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public function testClassValidator(bool $expected, string $classValidatorRegexp
$this->assertSame($expected, $doctrineLoader->loadClassMetadata($classMetadata));
}

public function regexpProvider()
public static function regexpProvider()
{
return [
[false, null],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function testFormat(array $record, $expectedMessage)
self::assertSame($expectedMessage, $formatter->format($record));
}

public function providerFormatTests(): array
public static function providerFormatTests(): array
{
$currentDateTime = new \DateTime();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function testVerbosityMapping($verbosity, $level, $isHandling, array $map
$this->assertFalse($handler->handle($infoRecord), 'The handler finished handling the log.');
}

public function provideVerbosityMappingTests()
public static function provideVerbosityMappingTests()
{
return [
[OutputInterface::VERBOSITY_QUIET, Logger::ERROR, true],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,23 @@ public function testIsActivated($url, $record, $expected)
$this->assertEquals($expected, $strategy->isHandlerActivated($record));
}

public function isActivatedProvider()
public static function isActivatedProvider()
{
return [
['/test', ['level' => Logger::ERROR], true],
['/400', ['level' => Logger::ERROR, 'context' => $this->getContextException(400)], true],
['/400/a', ['level' => Logger::ERROR, 'context' => $this->getContextException(400)], false],
['/400/b', ['level' => Logger::ERROR, 'context' => $this->getContextException(400)], false],
['/400/c', ['level' => Logger::ERROR, 'context' => $this->getContextException(400)], true],
['/401', ['level' => Logger::ERROR, 'context' => $this->getContextException(401)], true],
['/403', ['level' => Logger::ERROR, 'context' => $this->getContextException(403)], false],
['/404', ['level' => Logger::ERROR, 'context' => $this->getContextException(404)], false],
['/405', ['level' => Logger::ERROR, 'context' => $this->getContextException(405)], false],
['/500', ['level' => Logger::ERROR, 'context' => $this->getContextException(500)], true],
['/400', ['level' => Logger::ERROR, 'context' => self::getContextException(400)], true],
['/400/a', ['level' => Logger::ERROR, 'context' => self::getContextException(400)], false],
['/400/b', ['level' => Logger::ERROR, 'context' => self::getContextException(400)], false],
['/400/c', ['level' => Logger::ERROR, 'context' => self::getContextException(400)], true],
['/401', ['level' => Logger::ERROR, 'context' => self::getContextException(401)], true],
['/403', ['level' => Logger::ERROR, 'context' => self::getContextException(403)], false],
['/404', ['level' => Logger::ERROR, 'context' => self::getContextException(404)], false],
['/405', ['level' => Logger::ERROR, 'context' => self::getContextException(405)], false],
['/500', ['level' => Logger::ERROR, 'context' => self::getContextException(500)], true],
];
}

protected function getContextException($code)
protected static function getContextException($code)
{
return ['exception' => new HttpException($code)];
}
Expand Down
F438
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,22 @@ public function testIsActivated($url, $record, $expected)
$this->assertEquals($expected, $strategy->isHandlerActivated($record));
}

public function isActivatedProvider()
public static function isActivatedProvider()
{
return [
['/test', ['level' => Logger::DEBUG], false],
['/foo', ['level' => Logger::DEBUG, 'context' => $this->getContextException(404)], false],
['/baz/bar', ['level' => Logger::ERROR, 'context' => $this->getContextException(404)], false],
['/foo', ['level' => Logger::ERROR, 'context' => $this->getContextException(404)], false],
['/foo', ['level' => Logger::ERROR, 'context' => $this->getContextException(500)], true],
['/foo', ['level' => Logger::DEBUG, 'context' => self::getContextException(404)], false],
['/baz/bar', ['level' => Logger::ERROR, 'context' => self::getContextException(404)], false],
['/foo', ['level' => Logger::ERROR, 'context' => self::getContextException(404)], false],
['/foo', ['level' => Logger::ERROR, 'context' => self::getContextException(500)], true],

['/test', ['level' => Logger::ERROR], true],
['/baz', ['level' => Logger::ERROR, 'context' => $this->getContextException(404)], true],
['/baz', ['level' => Logger::ERROR, 'context' => $this->getContextException(500)], true],
['/baz', ['level' => Logger::ERROR, 'context' => self::getContextException(404)], true],
['/baz', ['level' => Logger::ERROR, 'context' => self::getContextException(500)], true],
];
}

protected function getContextException($code)
protected static function getContextException($code)
{
return ['exception' => new HttpException($code)];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ public function testDatetimeFormat(array $record, $expectedTimestamp)
self::assertSame($expectedTimestamp, $records[0]['timestamp']);
}

public function providerDatetimeFormatTests(): array
public static function providerDatetimeFormatTests(): array
{
$record = $this->getRecord();
$record = self::getRecord();

return [
[array_merge($record, ['datetime' => new \DateTime('2019-01-01T00:01:00+00:00')]), 1546300860],
Expand Down Expand Up @@ -99,7 +99,7 @@ public function testInheritedClassWithoutArgument()
$debugProcessorChild->countErrors();
}

private function getRecord($level = Logger::WARNING, $message = 'test'): array
private static function getRecord($level = Logger::WARNING, $message = 'test'): array
{
return [
'message' => $message,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function testItMutesOnlySpecificErrorMessagesWhenTheCallingCodeIsInPhpuni
$this->assertSame($muted, $deprecation->isMuted());
}

public function mutedProvider()
public static function mutedProvider()
{
yield 'not from phpunit, and not a whitelisted message' => [
false,
Expand Down Expand Up @@ -147,7 +147,7 @@ public function testItTakesMutesDeprecationFromPhpUnitFiles()
$this->assertTrue($deprecation->isMuted());
}

public function providerGetTypeDetectsSelf()
public static function providerGetTypeDetectsSelf()
{
return [
'not_from_vendors_file' => [Deprecation::TYPE_SELF, '', 'MyClass1', __FILE__],
Expand Down Expand Up @@ -182,7 +182,7 @@ public function testGetTypeDetectsSelf(string $expectedType, string $message, st
$this->assertSame($expectedType, $deprecation->getType());
}

public function providerGetTypeUsesRightTrace()
public static function providerGetTypeUsesRightTrace()
{
$vendorDir = self::getVendorDir();
$fakeTrace = [
Expand Down
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/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()
public static function getClassNameProvider()
{
return [
['F\Q\N\Foo', '<abbr title="F\Q\N\Foo">Foo</abbr>'],
['Bare', '<abbr title="Bare">Bare</abbr>'],
];
}

public function getMethodNameProvider()
public static function getMethodNameProvider()
{
return [
['F\Q\N\Foo::Method', '<abbr title="F\Q\N\Foo">Foo</abbr>::Method()'],
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
F438
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,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 @@ -143,7 +143,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 @@ -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 @@ -126,7 +126,7 @@ public function testValidAssetsPackageNameConfiguration($packageName)
$this->assertArrayHasKey($packageName, $config['assets']['packages']);
}

public function provideValidAssetsPackageNameConfigurationTests()
public static function provideValidAssetsPackageNameConfigurationTests()
{
return [
['foobar'],
Expand All @@ -152,7 +152,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 @@ -205,7 +205,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
Original file line number Diff line number Diff line change
Expand Up @@ -1672,7 +1672,7 @@ public function testHttpClientFullDefaultOptions()
], $defaultOptions['peer_fingerprint']);
}

public function provideMailer(): array
public static function provideMailer(): array
{
return [
['mailer_with_dsn', ['main' => 'smtp://example.com']],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function testSkipsOtherControllerFormats($controller)
$this->assertEquals($controller, $request->attributes->get('_controller'));
}

public function provideSkippedControllers()
public static function provideSkippedControllers()
{
yield ['Other:format'];
yield [function () {}];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function testDescribeEnvVar()
$this->assertStringContainsString(file_get_contents(__DIR__.'/Fixtures/describe_env_vars.txt'), $tester->getDisplay(true));
}

public function provideIgnoreBackslashWhenFindingService()
public static function provideIgnoreBackslashWhenFindingService()
{
return [
[BackslashClass::class],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function testParseFromFilename($file, $ref)
}
}

public function getFilenameToTemplateProvider()
public static function getFilenameToTemplateProvider()
{
return [
['/path/to/section/name.format.engine', new TemplateReference('', '/path/to/section', 'name', 'format', 'engine')],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function testParse($name, $logicalName, $path, $ref)
$this->assertSame($path, $template->getPath());
}

public function parseProvider()
public static function parseProvider()
{
return [
['FooBundle:Post:index.html.php', 'FooBundle:Post:index.html.php', '@FooBundle/Resources/views/Post/index.html.php', new TemplateReference('FooBundle', 'Post', 'index', 'html', 'php')],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function testGetPathForTemplate($template, $path)
$this->assertSame($template->getPath(), $path);
}

public function getTemplateToPathProvider()
public static function getTemplateToPathProvider()
{
return [
[new TemplateReference('FooBundle', 'Post', 'index', 'html', 'php'), '@FooBundle/Resources/views/Post/index.html.php'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public function testGetListeners()
$this->assertSame(1, $listenerCalled);
}

public function providerCollectDecisionLog(): \Generator
public static function providerCollectDecisionLog(): \Generator
{
$voter1 = $this->getMockBuilder(VoterInterface::class)->getMockForAbstractClass();
$voter2 = $this->getMockBuilder(VoterInterface::class)->getMockForAbstractClass();
Expand Down Expand Up @@ -381,7 +381,7 @@ public function testCollectDecisionLog(string $strategy, array $decisionLog, arr
$this->assertSame($dataCollector->getVoterStrategy(), $strategy, 'Wrong value returned by getVoterStrategy');
}

public function provideRoles()
public static function provideRoles()
{
return [
// Basic roles
Expand Down
Loading
0