Skip to content

Commit

Permalink
[Tests] Streamline
Browse files Browse the repository at this point in the history
  • Loading branch information
OskarStark authored and nicolas-grekas committed Oct 31, 2023
1 parent 896ce66 commit 4eeac66
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Tests/CacheWarmer/SerializerCacheWarmerTest.php
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
2 changes: 1 addition & 1 deletion Tests/Command/CachePoolClearCommandTest.php
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
2 changes: 1 addition & 1 deletion Tests/Command/CachePoolDeleteCommandTest.php
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
2 changes: 1 addition & 1 deletion Tests/Command/EventDispatcherDebugCommandTest.php
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
2 changes: 1 addition & 1 deletion Tests/Command/SecretsRemoveCommandTest.php
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
2 changes: 1 addition & 1 deletion Tests/Command/SecretsSetCommandTest.php
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
2 changes: 1 addition & 1 deletion Tests/Command/TranslationDebugCommandTest.php
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
2 changes: 1 addition & 1 deletion Tests/Command/TranslationUpdateCommandCompletionTest.php
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
2 changes: 1 addition & 1 deletion Tests/Controller/AbstractControllerTest.php
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
6 changes: 3 additions & 3 deletions Tests/Controller/RedirectControllerTest.php
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
14 changes: 12 additions & 2 deletions Tests/Controller/TemplateControllerTest.php
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();
}

Expand Down
6 changes: 3 additions & 3 deletions Tests/DependencyInjection/ConfigurationTest.php
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
4 changes: 2 additions & 2 deletions Tests/Functional/ContainerDebugCommandTest.php
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
2 changes: 1 addition & 1 deletion Tests/Functional/RouterDebugCommandTest.php
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

0 comments on commit 4eeac66

Please sign in to comment.