Skip to content

Commit 918f677

Browse files
OskarStarknicolas-grekas
authored andcommitted
[Tests] Streamline
1 parent 4e86cf2 commit 918f677

File tree

65 files changed

+147
-144
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+147
-144
lines changed

src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public function testMappingTypeDetection()
197197
$this->assertSame($mappingType, \PHP_VERSION_ID < 80000 ? 'annotation' : 'attribute');
198198
}
199199

200-
public static function providerBasicDrivers()
200+
public static function providerBasicDrivers(): array
201201
{
202202
return [
203203
['doctrine.orm.cache.apc.class', ['type' => 'apc']],
@@ -276,7 +276,7 @@ public function testUnrecognizedCacheDriverException()
276276
$this->invokeLoadCacheDriver($objectManager, $container, $cacheName);
277277
}
278278

279-
public static function providerBundles()
279+
public static function providerBundles(): iterable
280280
{
281281
yield ['AnnotationsBundle', \PHP_VERSION_ID < 80000 ? 'annotation' : 'attribute', '/Entity'];
282282
yield ['AnnotationsOneLineBundle', \PHP_VERSION_ID < 80000 ? 'annotation' : 'attribute', '/Entity'];

src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public function testChoiceTranslationDomainIsDisabledByDefault($expanded)
158158
}
159159
}
160160

161-
public static function choiceTranslationDomainProvider()
161+
public static function choiceTranslationDomainProvider(): array
162162
{
163163
return [
164164
[false],
@@ -240,8 +240,6 @@ public function testConfigureQueryBuilderWithClosureReturningNonQueryBuilder()
240240
return new \stdClass();
241241
},
242242
]);
243-
244-
$field->submit('2');
245243
}
246244

247245
public function testConfigureQueryBuilderWithClosureReturningNullUseDefault()

src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ public function testValidateResultTypes($entity1, $result)
479479
$this->assertNoViolation();
480480
}
481481

482-
public static function resultTypesProvider()
482+
public static function resultTypesProvider(): array
483483
{
484484
$entity = new SingleIntIdEntity(1, 'foo');
485485

src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function testVerbosityMapping($verbosity, $level, $isHandling, array $map
8989
$this->assertFalse($handler->handle($infoRecord), 'The handler finished handling the log.');
9090
}
9191

92-
public static function provideVerbosityMappingTests()
92+
public static function provideVerbosityMappingTests(): array
9393
{
9494
return [
9595
[OutputInterface::VERBOSITY_QUIET, Logger::ERROR, true],

src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/ConfigurationTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ public function testToleratesForIndividualGroups(string $deprecationsHelper, arr
249249
}
250250
}
251251

252-
public static function provideDataForToleratesForGroup() {
253-
252+
public static function provideDataForToleratesForGroup(): iterable
253+
{
254254
yield 'total threshold not reached' => ['max[total]=1', [
255255
'unsilenced' => 0,
256256
'self' => 0,

src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function testItMutesOnlySpecificErrorMessagesWhenTheCallingCodeIsInPhpuni
9797
$this->assertSame($muted, $deprecation->isMuted());
9898
}
9999

100-
public static function mutedProvider()
100+
public static function mutedProvider(): iterable
101101
{
102102
yield 'not from phpunit, and not a whitelisted message' => [
103103
false,
@@ -147,7 +147,7 @@ public function testItTakesMutesDeprecationFromPhpUnitFiles()
147147
$this->assertTrue($deprecation->isMuted());
148148
}
149149

150-
public static function providerGetTypeDetectsSelf()
150+
public static function providerGetTypeDetectsSelf(): array
151151
{
152152
return [
153153
'not_from_vendors_file' => [Deprecation::TYPE_SELF, '', 'MyClass1', __FILE__],
@@ -182,7 +182,7 @@ public function testGetTypeDetectsSelf(string $expectedType, string $message, st
182182
$this->assertSame($expectedType, $deprecation->getType());
183183
}
184184

185-
public static function providerGetTypeUsesRightTrace()
185+
public static function providerGetTypeUsesRightTrace(): array
186186
{
187187
$vendorDir = self::getVendorDir();
188188
$fakeTrace = [

src/Symfony/Bridge/Twig/Tests/AppVariableTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function testDebug($debugFlag)
4343
$this->assertEquals($debugFlag, $this->appVariable->getDebug());
4444
}
4545

46-
public static function debugDataProvider()
46+
public static function debugDataProvider(): array
4747
{
4848
return [
4949
'debug on' => [true],

src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public function testComplete(array $input, array $expectedSuggestions)
150150
$this->assertSame($expectedSuggestions, $tester->complete($input));
151151
}
152152

153-
public static function provideCompletionSuggestions()
153+
public static function provideCompletionSuggestions(): iterable
154154
{
155155
yield 'option' => [['--format', ''], ['txt', 'json', 'github']];
156156
}

src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function testThemeBlockInheritanceUsingDynamicExtend()
100100
);
101101
}
102102

103-
public static function isSelectedChoiceProvider()
103+
public static function isSelectedChoiceProvider(): array
104104
{
105105
return [
106106
[true, '0', '0'],
@@ -150,7 +150,7 @@ public function testStartTagHasActionAttributeWhenActionIsZero()
150150
$this->assertSame('<form name="form" method="get" action="0">', $html);
151151
}
152152

153-
public static function isRootFormProvider()
153+
public static function isRootFormProvider(): array
154154
{
155155
return [
156156
[true, new FormView()],
@@ -381,14 +381,14 @@ protected function setTheme(FormView $view, array $themes, $useDefaultThemes = t
381381
$this->renderer->setTheme($view, $themes, $useDefaultThemes);
382382
}
383383

384-
public static function themeBlockInheritanceProvider()
384+
public static function themeBlockInheritanceProvider(): array
385385
{
386386
return [
387387
[['theme.html.twig']],
388388
];
389389
}
390390

391-
public static function themeInheritanceProvider()
391+
public static function themeInheritanceProvider(): array
392392
{
393393
return [
394394
[['parent_label.html.twig'], ['child_label.html.twig']],

src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/SerializerCacheWarmerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function testWarmUp(array $loaders)
4040
$this->assertTrue($arrayPool->getItem('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Author')->isHit());
4141
}
4242

43-
public static function loaderProvider()
43+
public static function loaderProvider(): array
4444
{
4545
return [
4646
[

src/Symfony/Bundle/FrameworkBundle/Tests/Command/CachePoolClearCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function testComplete(array $input, array $expectedSuggestions)
4444
$this->assertSame($expectedSuggestions, $suggestions);
4545
}
4646

47-
public static function provideCompletionSuggestions()
47+
public static function provideCompletionSuggestions(): iterable
4848
{
4949
yield 'pool_name' => [
5050
['f'],

src/Symfony/Bundle/FrameworkBundle/Tests/Command/CachePoolDeleteCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function testComplete(array $input, array $expectedSuggestions)
9898
$this->assertSame($expectedSuggestions, $suggestions);
9999
}
100100

101-
public static function provideCompletionSuggestions()
101+
public static function provideCompletionSuggestions(): iterable
102102
{
103103
yield 'pool_name' => [
104104
['f'],

src/Symfony/Bundle/FrameworkBundle/Tests/Command/EventDispatcherDebugCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function testComplete(array $input, array $expectedSuggestions)
3131
$this->assertSame($expectedSuggestions, $suggestions);
3232
}
3333

34-
public static function provideCompletionSuggestions()
34+
public static function provideCompletionSuggestions(): iterable
3535
{
3636
yield 'event' => [[''], ['Symfony\Component\Mailer\Event\MessageEvent', 'console.command']];
3737
yield 'event for other dispatcher' => [['--dispatcher', 'other_event_dispatcher', ''], ['other_event', 'App\OtherEvent']];

src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsRemoveCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function testComplete(bool $withLocalVault, array $input, array $expected
3737
$this->assertSame($expectedSuggestions, $suggestions);
3838
}
3939

40-
public static function provideCompletionSuggestions()
40+
public static function provideCompletionSuggestions(): iterable
4141
{
4242
yield 'name' => [true, [''], ['SECRET', 'OTHER_SECRET']];
4343
yield '--local name (with local vault)' => [true, ['--local', ''], ['SECRET']];

src/Symfony/Bundle/FrameworkBundle/Tests/Command/SecretsSetCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function testComplete(array $input, array $expectedSuggestions)
3232
$this->assertSame($expectedSuggestions, $suggestions);
3333
}
3434

35-
public static function provideCompletionSuggestions()
35+
public static function provideCompletionSuggestions(): iterable
3636
{
3737
yield 'name' => [[''], ['SECRET', 'OTHER_SECRET']];
3838
yield '--local name (with local vault)' => [['--local', ''], ['SECRET', 'OTHER_SECRET']];

src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ function ($path, $catalogue) use ($extractedMessagesWithDomains) {
269269
$this->assertSame($expectedSuggestions, $suggestions);
270270
}
271271

272-
public static function provideCompletionSuggestions()
272+
public static function provideCompletionSuggestions(): iterable
273273
{
274274
yield 'locale' => [
275275
[''],

src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandCompletionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function testComplete(array $input, array $expectedSuggestions)
4242
$this->assertSame($expectedSuggestions, $suggestions);
4343
}
4444

45-
public static function provideCompletionSuggestions()
45+
public static function provideCompletionSuggestions(): iterable
4646
{
4747
$bundle = new ExtensionPresentBundle();
4848

src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ public function testdenyAccessUnlessGrantedSetsAttributesAsArray($attribute, $ex
409409
}
410410
}
411411

412-
public static function provideDenyAccessUnlessGrantedSetsAttributesAsArray()
412+
public static function provideDenyAccessUnlessGrantedSetsAttributesAsArray(): array
413413
{
414414
$obj = new \stdClass();
415415
$obj->foo = 'bar';

src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function testRoute($permanent, $keepRequestMethod, $keepQueryParams, $ign
103103
$this->assertEquals($expectedCode, $returnResponse->getStatusCode());
104104
}
105105

106-
public static function provider()
106+
public static function provider(): array
107107
{
108108
return [
109109
[true, false, false, false, 301, ['additional-parameter' => 'value']],
@@ -210,7 +210,7 @@ public function testUrlRedirectDefaultPorts()
210210
$this->assertRedirectUrl($returnValue, $expectedUrl);
211211
}
212212

213-
public static function urlRedirectProvider()
213+
public static function urlRedirectProvider(): array
214214
{
215215
return [
216216
// Standard ports
@@ -262,7 +262,7 @@ public function testUrlRedirect($scheme, $httpPort, $httpsPort, $requestScheme,
262262
$this->assertRedirectUrl($returnValue, $expectedUrl);
263263
}
264264

265-
public static function pathQueryParamsProvider()
265+
public static function pathQueryParamsProvider(): array
266266
{
267267
return [
268268
['http://www.example.com/base/redirect-path', '/redirect-path', ''],

src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,23 @@ public function testTwig()
3232
$this->assertEquals('bar', $controller('mytemplate')->getContent());
3333
}
3434

35-
public function testNoTwig()
35+
public function testNoTwigTemplateActionMethod()
3636
{
37+
$controller = new TemplateController();
38+
3739
$this->expectException(\LogicException::class);
3840
$this->expectExceptionMessage('You cannot use the TemplateController if the Twig Bundle is not available.');
39-
$controller = new TemplateController();
4041

4142
$controller->templateAction('mytemplate')->getContent();
43+
}
44+
45+
public function testNoTwigInvokeMethod()
46+
{
47+
$controller = new TemplateController();
48+
49+
$this->expectException(\LogicException::class);
50+
$this->expectExceptionMessage('You cannot use the TemplateController if the Twig Bundle is not available.');
51+
4252
$controller('mytemplate')->getContent();
4353
}
4454

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function testValidAssetsPackageNameConfiguration($packageName)
113113
$this->assertArrayHasKey($packageName, $config['assets']['packages']);
114114
}
115115

116-
public static function provideValidAssetsPackageNameConfigurationTests()
116+
public static function provideValidAssetsPackageNameConfigurationTests(): array
117117
{
118118
return [
119119
['foobar'],
@@ -139,7 +139,7 @@ public function testInvalidAssetsConfiguration(array $assetConfig, $expectedMess
139139
]);
140140
}
141141

142-
public static function provideInvalidAssetConfigurationTests()
142+
public static function provideInvalidAssetConfigurationTests(): iterable
143143
{
144144
// helper to turn config into embedded package config
145145
$createPackageConfig = function (array $packageConfig) {
@@ -192,7 +192,7 @@ public function testValidLockConfiguration($lockConfig, $processedConfig)
192192
$this->assertEquals($processedConfig, $config['lock']);
193193
}
194194

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

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerDebugCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ public function testGetDeprecationNoFile()
204204
$this->assertStringContainsString('[WARNING] The deprecation file does not exist', $tester->getDisplay());
205205
}
206206

207-
public static function provideIgnoreBackslashWhenFindingService()
207+
public static function provideIgnoreBackslashWhenFindingService(): array
208208
{
209209
return [
210210
[BackslashClass::class],
@@ -232,7 +232,7 @@ public function testComplete(array $input, array $expectedSuggestions, array $no
232232
}
233233
}
234234

235-
public static function provideCompletionSuggestions()
235+
public static function provideCompletionSuggestions(): iterable
236236
{
237237
$serviceId = 'console.command.container_debug';
238238
$hiddenServiceId = '.console.command.container_debug.lazy';

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/RouterDebugCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function testComplete(array $input, array $expectedSuggestions)
100100
$this->assertSame($expectedSuggestions, $tester->complete($input));
101101
}
102102

103-
public static function provideCompletionSuggestions()
103+
public static function provideCompletionSuggestions(): iterable
104104
{
105105
yield 'option --format' => [
106106
['--format', ''],

src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ public function dispatch(object $event, string $eventName = null): object
400400
$this->assertSame($dataCollector->getVoterStrategy(), $strategy, 'Wrong value returned by getVoterStrategy');
401401
}
402402

403-
public static function provideRoles()
403+
public static function provideRoles(): array
404404
{
405405
return [
406406
// Basic roles

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ public function testSecretRememberMeHandler()
526526
$this->assertSame('very', $handler->getArgument(1));
527527
}
528528

529-
public static function sessionConfigurationProvider()
529+
public static function sessionConfigurationProvider(): array
530530
{
531531
return [
532532
[
@@ -659,7 +659,7 @@ public function testAuthenticatorManagerEnabledEntryPoint(array $firewall, $entr
659659
$this->assertEquals($entryPointId, (string) $container->getDefinition('security.exception_listener.main')->getArgument(4));
660660
}
661661

662-
public static function provideEntryPointFirewalls()
662+
public static function provideEntryPointFirewalls(): iterable
663663
{
664664
// only one entry point available
665665
yield [['http_basic' => true], 'security.authenticator.http_basic.main'];
@@ -679,7 +679,7 @@ public static function provideEntryPointFirewalls()
679679
/**
680680
* @dataProvider provideEntryPointRequiredData
681681
*/
682-
public function testEntryPointRequired(array $firewall, $messageRegex)
682+
public function testEntryPointRequired(array $firewall, string $messageRegex)
683683
{
684684
$this->expectException(InvalidConfigurationException::class);
685685
$this->expectExceptionMessageMatches($messageRegex);
@@ -699,7 +699,7 @@ public function testEntryPointRequired(array $firewall, $messageRegex)
699699
$container->compile();
700700
}
701701

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

752-
public static function provideConfigureCustomAuthenticatorData()
752+
public static function provideConfigureCustomAuthenticatorData(): iterable
753753
{
754754
yield [
755755
['custom_authenticator' => TestAuthenticator::class],
@@ -829,7 +829,7 @@ public function testUserCheckerWithAuthenticatorManager(array $config, string $e
829829
$this->assertEquals($expectedUserCheckerClass, $container->findDefinition($userCheckerId)->getClass());
830830
}
831831

832-
public static function provideUserCheckerConfig()
832+
public static function provideUserCheckerConfig(): iterable
833833
{
834834
yield [[], InMemoryUserChecker::class];
835835
yield [['user_checker' => TestUserChecker::class], TestUserChecker::class];

0 commit comments

Comments
 (0)