Skip to content

[Tests] Streamline #52365

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

Merged
merged 1 commit into from
Oct 31, 2023
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public function testMappingTypeDetection()
$this->assertSame($mappingType, \PHP_VERSION_ID < 80000 ? 'annotation' : 'attribute');
}

public static function providerBasicDrivers()
public static function providerBasicDrivers(): array
{
return [
['doctrine.orm.cache.apc.class', ['type' => 'apc']],
Expand Down Expand Up @@ -276,7 +276,7 @@ public function testUnrecognizedCacheDriverException()
$this->invokeLoadCacheDriver($objectManager, $container, $cacheName);
}

public static function providerBundles()
public static function providerBundles(): iterable
{
yield ['AnnotationsBundle', \PHP_VERSION_ID < 80000 ? 'annotation' : 'attribute', '/Entity'];
yield ['AnnotationsOneLineBundle', \PHP_VERSION_ID < 80000 ? 'annotation' : 'attribute', '/Entity'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function testChoiceTranslationDomainIsDisabledByDefault($expanded)
}
}

public static function choiceTranslationDomainProvider()
public static function choiceTranslationDomainProvider(): array
{
return [
[false],
Expand Down Expand Up @@ -240,8 +240,6 @@ public function testConfigureQueryBuilderWithClosureReturningNonQueryBuilder()
return new \stdClass();
},
]);

$field->submit('2');
}

public function testConfigureQueryBuilderWithClosureReturningNullUseDefault()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ public function testValidateResultTypes($entity1, $result)
$this->assertNoViolation();
}

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

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 static function provideVerbosityMappingTests()
public static function provideVerbosityMappingTests(): array
{
return [
[OutputInterface::VERBOSITY_QUIET, Logger::ERROR, true],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ public function testToleratesForIndividualGroups(string $deprecationsHelper, arr
}
}

public static function provideDataForToleratesForGroup() {

public static function provideDataForToleratesForGroup(): iterable
{
yield 'total threshold not reached' => ['max[total]=1', [
'unsilenced' => 0,
'self' => 0,
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 static function mutedProvider()
public static function mutedProvider(): iterable
{
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 static function providerGetTypeDetectsSelf()
public static function providerGetTypeDetectsSelf(): array
{
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 static function providerGetTypeUsesRightTrace()
public static function providerGetTypeUsesRightTrace(): array
{
$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 static function debugDataProvider()
public static function debugDataProvider(): array
{
return [
'debug on' => [true],
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 static function provideCompletionSuggestions()
public static function provideCompletionSuggestions(): iterable
{
yield 'option' => [['--format', ''], ['txt', 'json', 'github']];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function testThemeBlockInheritanceUsingDynamicExtend()
);
}

public static function isSelectedChoiceProvider()
public static function isSelectedChoiceProvider(): array
{
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 static function isRootFormProvider()
public static function isRootFormProvider(): array
{
return [
[true, new FormView()],
Expand Down Expand Up @@ -381,14 +381,14 @@ protected function setTheme(FormView $view, array $themes, $useDefaultThemes = t
$this->renderer->setTheme($view, $themes, $useDefaultThemes);
}

public static function themeBlockInheritanceProvider()
public static function themeBlockInheritanceProvider(): array
{
return [
[['theme.html.twig']],
];
}

public static function themeInheritanceProvider()
public static function themeInheritanceProvider(): array
{
return [
[['parent_label.html.twig'], ['child_label.html.twig']],
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 static function loaderProvider()
public static function loaderProvider(): array
{
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 static function provideCompletionSuggestions()
public static function provideCompletionSuggestions(): iterable
{
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 static function provideCompletionSuggestions()
public static function provideCompletionSuggestions(): iterable
{
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 static function provideCompletionSuggestions()
public static function provideCompletionSuggestions(): iterable
{
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 static function provideCompletionSuggestions()
public static function provideCompletionSuggestions(): iterable
{
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 static function provideCompletionSuggestions()
public static function provideCompletionSuggestions(): iterable
{
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 static function provideCompletionSuggestions()
public static function provideCompletionSuggestions(): iterable
{
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 static function provideCompletionSuggestions()
public static function provideCompletionSuggestions(): iterable
{
$bundle = new ExtensionPresentBundle();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ public function testdenyAccessUnlessGrantedSetsAttributesAsArray($attribute, $ex
}
}

public static function provideDenyAccessUnlessGrantedSetsAttributesAsArray()
public static function provideDenyAccessUnlessGrantedSetsAttributesAsArray(): array
{
$obj = new \stdClass();
$obj->foo = 'bar';
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 static function provider()
public static function provider(): array
{
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 static function urlRedirectProvider()
public static function urlRedirectProvider(): array
{
return [
// Standard ports
Expand Down Expand Up @@ -262,7 +262,7 @@ public function testUrlRedirect($scheme, $httpPort, $httpsPort, $requestScheme,
$this->assertRedirectUrl($returnValue, $expectedUrl);
}

public static function pathQueryParamsProvider()
public static function pathQueryParamsProvider(): array
{
return [
['http://www.example.com/base/redirect-path', '/redirect-path', ''],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,23 @@ public function testTwig()
$this->assertEquals('bar', $controller('mytemplate')->getContent());
}

public function testNoTwig()
public function testNoTwigTemplateActionMethod()
{
$controller = new TemplateController();

$this->expectException(\LogicException::class);
$this->expectExceptionMessage('You cannot use the TemplateController if the Twig Bundle is not available.');
$controller = new TemplateController();

$controller->templateAction('mytemplate')->getContent();
}

public function testNoTwigInvokeMethod()
{
$controller = new TemplateController();

$this->expectException(\LogicException::class);
$this->expectExceptionMessage('You cannot use the TemplateController if the Twig Bundle is not available.');

$controller('mytemplate')->getContent();
}
Comment on lines +35 to 53
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should test both ways independently


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function testValidAssetsPackageNameConfiguration($packageName)
$this->assertArrayHasKey($packageName, $config['assets']['packages']);
}

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

public static function provideInvalidAssetConfigurationTests()
public static function provideInvalidAssetConfigurationTests(): iterable
{
// 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 static function provideValidLockConfigurationTests()
public static function provideValidLockConfigurationTests(): iterable
{
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 @@ -204,7 +204,7 @@ public function testGetDeprecationNoFile()
$this->assertStringContainsString('[WARNING] The deprecation file does not exist', $tester->getDisplay());
}

public static function provideIgnoreBackslashWhenFindingService()
public static function provideIgnoreBackslashWhenFindingService(): array
{
return [
[BackslashClass::class],
Expand Down Expand Up @@ -232,7 +232,7 @@ public function testComplete(array $input, array $expectedSuggestions, array $no
}
}

public static function provideCompletionSuggestions()
public static function provideCompletionSuggestions(): iterable
{
$serviceId = 'console.command.container_debug';
$hiddenServiceId = '.console.command.container_debug.lazy';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function testComplete(array $input, array $expectedSuggestions)
$this->assertSame($expectedSuggestions, $tester->complete($input));
}

public static function provideCompletionSuggestions()
public static function provideCompletionSuggestions(): iterable
{
yield 'option --format' => [
['--format', ''],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ public function dispatch(object $event, string $eventName = null): object
$this->assertSame($dataCollector->getVoterStrategy(), $strategy, 'Wrong value returned by getVoterStrategy');
}

public static function provideRoles()
public static function provideRoles(): array
{
return [
// Basic roles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ public function testSecretRememberMeHandler()
$this->assertSame('very', $handler->getArgument(1));
}

public static function sessionConfigurationProvider()
public static function sessionConfigurationProvider(): array
{
return [
[
Expand Down Expand Up @@ -659,7 +659,7 @@ public function testAuthenticatorManagerEnabledEntryPoint(array $firewall, $entr
$this->assertEquals($entryPointId, (string) $container->getDefinition('security.exception_listener.main')->getArgument(4));
}

public static function provideEntryPointFirewalls()
public static function provideEntryPointFirewalls(): iterable
{
// only one entry point available
yield [['http_basic' => true], 'security.authenticator.http_basic.main'];
Expand All @@ -679,7 +679,7 @@ public static function provideEntryPointFirewalls()
/**
* @dataProvider provideEntryPointRequiredData
*/
public function testEntryPointRequired(array $firewall, $messageRegex)
public function testEntryPointRequired(array $firewall, string $messageRegex)
{
$this->expectException(InvalidConfigurationException::class);
$this->expectExceptionMessageMatches($messageRegex);
Expand All @@ -699,7 +699,7 @@ public function testEntryPointRequired(array $firewall, $messageRegex)
$container->compile();
}

public static function provideEntryPointRequiredData()
public static function provideEntryPointRequiredData(): iterable
{
// more than one entry point available and not explicitly set
yield [
Expand Down Expand Up @@ -749,7 +749,7 @@ public function testConfigureCustomAuthenticator(array $firewall, array $expecte
$this->assertEquals($expectedAuthenticators, array_map('strval', $container->getDefinition('security.authenticator.manager.main')->getArgument(0)));
}

public static function provideConfigureCustomAuthenticatorData()
public static function provideConfigureCustomAuthenticatorData(): iterable
{
yield [
['custom_authenticator' => TestAuthenticator::class],
Expand Down Expand Up @@ -829,7 +829,7 @@ public function testUserCheckerWithAuthenticatorManager(array $config, string $e
$this->assertEquals($expectedUserCheckerClass, $container->findDefinition($userCheckerId)->getClass());
}

public static function provideUserCheckerConfig()
public static function provideUserCheckerConfig(): iterable
{
yield [[], InMemoryUserChecker::class];
yield [['user_checker' => TestUserChecker::class], TestUserChecker::class];
Expand Down
Loading