From 11ee84c09ea9dfa4a433932ddc7fcb34c74a34aa Mon Sep 17 00:00:00 2001 From: Hamza Amrouche Date: Wed, 17 Apr 2019 16:07:28 +0200 Subject: [PATCH 01/59] minor: ChoiceType callable deprecation after/before seems wrong That is on me 3 years ago ! --- UPGRADE-4.0.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/UPGRADE-4.0.md b/UPGRADE-4.0.md index fbe988fa3497f..5703b4a5a7408 100644 --- a/UPGRADE-4.0.md +++ b/UPGRADE-4.0.md @@ -297,19 +297,17 @@ Form `ArrayAccess` in `ResizeFormListener::preSubmit` method has been removed. * Using callable strings as choice options in ChoiceType is not supported - anymore in favor of passing PropertyPath instances. + anymore. Before: ```php - 'choice_value' => new PropertyPath('range'), 'choice_label' => 'strtoupper', ``` After: ```php - 'choice_value' => 'range', 'choice_label' => function ($choice) { return strtoupper($choice); }, From 30b560c4df3066cfc20459f4339c3c97e9905828 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 22 May 2019 16:48:58 +0200 Subject: [PATCH 02/59] [github] define 4.4 as the feature branch --- .github/PULL_REQUEST_TEMPLATE.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 426b55def0001..3d686194101c0 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,6 +1,6 @@ | Q | A | ------------- | --- -| Branch? | master for features / 3.4, 4.2 or 4.3 for bug fixes +| Branch? | 4.4 for features / 3.4, 4.2 or 4.3 for bug fixes | Bug fix? | yes/no | New feature? | yes/no | BC breaks? | no @@ -17,5 +17,6 @@ understand your PR and can be used as a start for the documentation. Additionally (see https://symfony.com/roadmap): - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - - Features and deprecations must be submitted against the master branch. + - Features and deprecations must be submitted against branch 4.4. + - Legacy code removals go to the master branch. --> From f9beee7424e81f593f8497a3b5ab973160935f2f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 30 May 2019 08:26:43 +0200 Subject: [PATCH 03/59] bumped Symfony version to 4.3.1 --- src/Symfony/Component/HttpKernel/Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index e0154b7d23bb5..a1b81ed928fb8 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '4.3.0'; - const VERSION_ID = 40300; + const VERSION = '4.3.1-DEV'; + const VERSION_ID = 40301; const MAJOR_VERSION = 4; const MINOR_VERSION = 3; - const RELEASE_VERSION = 0; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 1; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '01/2020'; const END_OF_LIFE = '07/2020'; From 3a88f11662e9bdd8cc22be25831ac0839b40688e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 30 May 2019 10:57:55 +0200 Subject: [PATCH 04/59] Use a more appropriate group when deprecating mode The deprecation comes from a vendor: the phpunit bridge itself, so it's either the direct or the indirect group. And since only the end user is supposed to set the group, then this is supposed to be a direct deprecation. --- src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php index a1aee18b8c2d6..55089e0be11f6 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php @@ -228,9 +228,9 @@ private function getConfiguration() return $this->configuration = Configuration::inWeakMode(); } if (self::MODE_WEAK_VENDORS === $mode) { - ++$this->deprecations['remaining selfCount']; + ++$this->deprecations['remaining directCount']; $msg = sprintf('Setting SYMFONY_DEPRECATIONS_HELPER to "%s" is deprecated in favor of "max[self]=0"', $mode); - $ref = &$this->deprecations['remaining self'][$msg]['count']; + $ref = &$this->deprecations['remaining direct'][$msg]['count']; ++$ref; $mode = 'max[self]=0'; } From 33844376dafad207de784fd06e02f5ba1cc78ebf Mon Sep 17 00:00:00 2001 From: Chi-teck Date: Thu, 30 May 2019 14:28:08 +0500 Subject: [PATCH 05/59] Fix parameter documentation for Inflector::pluralize() method --- src/Symfony/Component/Inflector/Inflector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Inflector/Inflector.php b/src/Symfony/Component/Inflector/Inflector.php index 19edd1ae6acd5..15198293cf535 100644 --- a/src/Symfony/Component/Inflector/Inflector.php +++ b/src/Symfony/Component/Inflector/Inflector.php @@ -410,7 +410,7 @@ public static function singularize(string $plural) * If the method can't determine the form with certainty, an array of the * possible plurals is returned. * - * @param string $singular A word in plural form + * @param string $singular A word in singular form * * @return string|array The plural form or an array of possible plural forms */ From 2da9e3f7171b2db0dc82fc2d946850595248a229 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 30 May 2019 11:47:28 +0200 Subject: [PATCH 06/59] [HttpClient] Minor fix in an error message --- src/Symfony/Component/HttpClient/Response/CurlResponse.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpClient/Response/CurlResponse.php b/src/Symfony/Component/HttpClient/Response/CurlResponse.php index 6af5f5af3d68b..8cb5081e7057a 100644 --- a/src/Symfony/Component/HttpClient/Response/CurlResponse.php +++ b/src/Symfony/Component/HttpClient/Response/CurlResponse.php @@ -260,7 +260,7 @@ private static function perform(CurlClientState $multi, array &$responses = null while ($info = curl_multi_info_read($multi->handle)) { $multi->handlesActivity[(int) $info['handle']][] = null; - $multi->handlesActivity[(int) $info['handle']][] = \in_array($info['result'], [\CURLE_OK, \CURLE_TOO_MANY_REDIRECTS], true) || (\CURLE_WRITE_ERROR === $info['result'] && 'destruct' === @curl_getinfo($info['handle'], CURLINFO_PRIVATE)) ? null : new TransportException(sprintf('%s for"%s".', curl_strerror($info['result']), curl_getinfo($info['handle'], CURLINFO_EFFECTIVE_URL))); + $multi->handlesActivity[(int) $info['handle']][] = \in_array($info['result'], [\CURLE_OK, \CURLE_TOO_MANY_REDIRECTS], true) || (\CURLE_WRITE_ERROR === $info['result'] && 'destruct' === @curl_getinfo($info['handle'], CURLINFO_PRIVATE)) ? null : new TransportException(sprintf('%s for "%s".', curl_strerror($info['result']), curl_getinfo($info['handle'], CURLINFO_EFFECTIVE_URL))); } } finally { self::$performing = false; From 6982025e3a8755b4659f28b1e36d2d7484acac69 Mon Sep 17 00:00:00 2001 From: Andrii Dembitskyi Date: Thu, 30 May 2019 10:50:58 +0300 Subject: [PATCH 07/59] Add missed use class for Symfony\Bundle\FrameworkBundle\Test\WebTestCase::$client --- src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php b/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php index 417556578b7b7..caed6fe8a29cb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php +++ b/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php @@ -23,7 +23,7 @@ abstract class WebTestCase extends KernelTestCase { use WebTestAssertionsTrait; - /** @var Client|null */ + /** @var KernelBrowser|null */ protected static $client; protected function doTearDown(): void From bf782ecb38eddc5b6856552a536df4c965f3b0e4 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 30 May 2019 16:12:14 +0200 Subject: [PATCH 08/59] Disable php_unit_mock_short_will_return rule of php-cs --- .php_cs.dist | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.php_cs.dist b/.php_cs.dist index 8523be670698e..8cc2c0a05bd61 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -18,6 +18,8 @@ return PhpCsFixer\Config::create() 'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced'], // Part of future @Symfony ruleset in PHP-CS-Fixer To be removed from the config file once upgrading 'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'], + // Part of @Symfony:risky in PHP-CS-Fixer 2.15.0. Incompatible with PHPUnit 4 that is required for Symfony 3.4 + 'php_unit_mock_short_will_return' => false, ]) ->setRiskyAllowed(true) ->setFinder( From 4fb67df612b46f0fb508e852c9b729dfb531ffd6 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 30 May 2019 16:56:20 +0200 Subject: [PATCH 09/59] Use willReturn() instead of will(returnValue()). --- .php_cs.dist | 2 - .../DoctrineDataCollectorTest.php | 8 +- .../DoctrineExtensionTest.php | 4 +- .../DoctrineParserCacheTest.php | 4 +- .../Tests/Form/DoctrineOrmTypeGuesserTest.php | 22 ++-- .../Form/Type/EntityTypePerformanceTest.php | 4 +- .../Tests/Form/Type/EntityTypeTest.php | 4 +- .../Security/User/EntityUserProviderTest.php | 2 +- .../Constraints/UniqueEntityValidatorTest.php | 24 ++-- .../Tests/Handler/ConsoleHandlerTest.php | 8 +- .../Tests/Processor/WebProcessorTest.php | 4 +- .../Extension/HttpKernelExtensionTest.php | 8 +- .../Tests/CacheWarmer/TemplateFinderTest.php | 2 +- .../TemplatePathsCacheWarmerTest.php | 6 +- .../Tests/Command/RouterDebugCommandTest.php | 6 +- .../Tests/Command/RouterMatchCommandTest.php | 8 +- .../Command/TranslationDebugCommandTest.php | 32 +++--- .../Command/TranslationUpdateCommandTest.php | 36 +++--- .../Tests/Console/ApplicationTest.php | 10 +- .../Controller/ControllerNameParserTest.php | 10 +- .../Controller/ControllerResolverTest.php | 2 +- .../Tests/Controller/ControllerTraitTest.php | 10 +- .../Controller/RedirectControllerTest.php | 20 ++-- .../Controller/TemplateControllerTest.php | 8 +- .../Tests/Routing/RouterTest.php | 4 +- .../Tests/Templating/DelegatingEngineTest.php | 8 +- .../Tests/Templating/GlobalVariablesTest.php | 6 +- .../Templating/Loader/TemplateLocatorTest.php | 2 +- .../Templating/TemplateNameParserTest.php | 4 +- .../Tests/Templating/TimedPhpEngineTest.php | 6 +- .../Tests/Translation/TranslatorTest.php | 32 +++--- .../ConstraintValidatorFactoryTest.php | 2 +- .../Security/Factory/AbstractFactoryTest.php | 6 +- .../Controller/PreviewErrorControllerTest.php | 2 +- .../Tests/Loader/FilesystemLoaderTest.php | 10 +- .../TwigBundle/Tests/TemplateIteratorTest.php | 8 +- .../Controller/ProfilerControllerTest.php | 6 +- .../Csp/ContentSecurityPolicyHandlerTest.php | 2 +- .../WebDebugToolbarListenerTest.php | 10 +- .../Tests/Profiler/TemplateManagerTest.php | 8 +- .../Component/Asset/Tests/PathPackageTest.php | 2 +- .../Component/Asset/Tests/UrlPackageTest.php | 2 +- .../Cache/Tests/Adapter/ChainAdapterTest.php | 4 +- .../Tests/Adapter/TagAwareAdapterTest.php | 4 +- .../Cache/Tests/Simple/ChainCacheTest.php | 4 +- .../Tests/Loader/DelegatingLoaderTest.php | 8 +- .../Tests/Loader/LoaderResolverTest.php | 2 +- .../Config/Tests/Loader/LoaderTest.php | 12 +- .../Console/Tests/ApplicationTest.php | 4 +- .../Console/Tests/Command/CommandTest.php | 2 +- .../Helper/AbstractQuestionHelperTest.php | 2 +- .../Console/Tests/Helper/HelperSetTest.php | 2 +- .../Tests/Helper/QuestionHelperTest.php | 2 +- .../Helper/SymfonyQuestionHelperTest.php | 2 +- .../Tests/Logger/ConsoleLoggerTest.php | 2 +- .../Debug/Tests/ErrorHandlerTest.php | 10 +- .../Compiler/AutowireExceptionPassTest.php | 20 ++-- .../MergeExtensionConfigurationPassTest.php | 12 +- ...ContainerParametersResourceCheckerTest.php | 4 +- .../Tests/ContainerBuilderTest.php | 4 +- .../Component/DomCrawler/Tests/FormTest.php | 4 +- .../Tests/ImmutableEventDispatcherTest.php | 6 +- .../Tests/ExpressionLanguageTest.php | 20 ++-- .../Tests/Iterator/FilterIteratorTest.php | 4 +- .../Form/Tests/AbstractDivLayoutTest.php | 2 +- .../Form/Tests/AbstractRequestHandlerTest.php | 4 +- .../Form/Tests/AbstractTableLayoutTest.php | 2 +- .../Factory/CachingFactoryDecoratorTest.php | 74 ++++++------ .../Factory/PropertyAccessDecoratorTest.php | 72 ++++++------ .../Tests/ChoiceList/LazyChoiceListTest.php | 30 ++--- .../Component/Form/Tests/CompoundFormTest.php | 42 +++---- .../DataTransformerChainTest.php | 8 +- .../Csrf/Type/FormTypeCsrfExtensionTest.php | 16 +-- .../DataCollector/FormDataCollectorTest.php | 106 +++++++++--------- .../DataCollector/FormDataExtractorTest.php | 8 +- .../Type/FormTypeValidatorExtensionTest.php | 2 +- .../Component/Form/Tests/FormBuilderTest.php | 8 +- .../Component/Form/Tests/FormFactoryTest.php | 100 ++++++++--------- .../Form/Tests/ResolvedFormTypeTest.php | 40 +++---- .../Component/Form/Tests/SimpleFormTest.php | 8 +- .../HttpFoundation/Tests/File/FileTest.php | 2 +- .../Handler/MemcacheSessionHandlerTest.php | 4 +- .../Handler/MemcachedSessionHandlerTest.php | 6 +- .../Handler/MongoDbSessionHandlerTest.php | 32 +++--- .../Storage/Handler/PdoSessionHandlerTest.php | 10 +- .../Handler/WriteCheckSessionHandlerTest.php | 10 +- .../Storage/Proxy/SessionHandlerProxyTest.php | 8 +- .../CacheWarmer/CacheWarmerAggregateTest.php | 2 +- .../Component/HttpKernel/Tests/ClientTest.php | 2 +- .../Tests/Config/FileLocatorTest.php | 2 +- .../ContainerControllerResolverTest.php | 32 +++--- .../Controller/ControllerResolverTest.php | 2 +- .../DataCollector/LoggerDataCollectorTest.php | 8 +- .../DataCollector/TimeDataCollectorTest.php | 2 +- .../Debug/TraceableEventDispatcherTest.php | 8 +- .../LazyLoadingFragmentHandlerTest.php | 16 +-- .../AddRequestFormatsListenerTest.php | 2 +- .../DebugHandlersListenerTest.php | 2 +- .../EventListener/ExceptionListenerTest.php | 8 +- .../EventListener/LocaleListenerTest.php | 6 +- .../EventListener/ProfilerListenerTest.php | 2 +- .../EventListener/RouterListenerTest.php | 8 +- .../EventListener/TestSessionListenerTest.php | 12 +- .../EventListener/TranslatorListenerTest.php | 2 +- .../Tests/Fragment/FragmentHandlerTest.php | 4 +- .../Fragment/InlineFragmentRendererTest.php | 14 +-- .../HttpKernel/Tests/HttpCache/EsiTest.php | 4 +- .../HttpKernel/Tests/HttpCache/SsiTest.php | 4 +- .../HttpKernel/Tests/HttpKernelTest.php | 4 +- .../Component/HttpKernel/Tests/KernelTest.php | 56 ++++----- .../HttpKernel/Tests/Log/LoggerTest.php | 2 +- .../Bundle/Reader/BundleEntryReaderTest.php | 58 +++++----- .../Component/Ldap/Tests/LdapClientTest.php | 6 +- src/Symfony/Component/Ldap/Tests/LdapTest.php | 2 +- .../Tests/ProcessFailedExceptionTest.php | 26 ++--- .../Tests/PropertyAccessorCollectionTest.php | 6 +- .../Loader/AnnotationClassLoaderTest.php | 26 ++--- .../Loader/AnnotationDirectoryLoaderTest.php | 10 +- .../Tests/Loader/AnnotationFileLoaderTest.php | 2 +- .../Tests/Loader/ObjectRouteLoaderTest.php | 2 +- .../Matcher/RedirectableUrlMatcherTest.php | 10 +- .../Tests/RouteCollectionBuilderTest.php | 18 +-- .../Component/Routing/Tests/RouterTest.php | 6 +- .../AuthenticationProviderManagerTest.php | 4 +- .../AnonymousAuthenticationProviderTest.php | 2 +- .../DaoAuthenticationProviderTest.php | 36 +++--- .../LdapBindAuthenticationProviderTest.php | 10 +- ...uthenticatedAuthenticationProviderTest.php | 12 +- .../RememberMeAuthenticationProviderTest.php | 6 +- .../SimpleAuthenticationProviderTest.php | 12 +- .../UserAuthenticationProviderTest.php | 28 ++--- .../Token/AbstractTokenTest.php | 2 +- .../Token/RememberMeTokenTest.php | 2 +- .../AccessDecisionManagerTest.php | 6 +- .../AuthorizationCheckerTest.php | 8 +- .../Voter/ExpressionVoterTest.php | 4 +- .../Authorization/Voter/RoleVoterTest.php | 2 +- .../Tests/Encoder/UserPasswordEncoderTest.php | 14 +-- .../Security/Core/Tests/SecurityTest.php | 10 +- .../Core/Tests/User/ChainUserProviderTest.php | 16 +-- .../Core/Tests/User/LdapUserProviderTest.php | 86 +++++++------- .../Core/Tests/User/UserCheckerTest.php | 22 ++-- .../Constraints/UserPasswordValidatorTest.php | 14 +-- .../Csrf/Tests/CsrfTokenManagerTest.php | 22 ++-- .../FormLoginAuthenticatorTest.php | 4 +- .../GuardAuthenticationListenerTest.php | 34 +++--- .../Tests/GuardAuthenticatorHandlerTest.php | 8 +- .../GuardAuthenticationProviderTest.php | 28 ++--- .../Security/Http/Tests/AccessMapTest.php | 2 +- ...efaultAuthenticationFailureHandlerTest.php | 18 +-- ...efaultAuthenticationSuccessHandlerTest.php | 4 +- .../SimpleAuthenticationHandlerTest.php | 20 ++-- .../FormAuthenticationEntryPointTest.php | 6 +- .../AbstractPreAuthenticatedListenerTest.php | 32 +++--- .../Tests/Firewall/AccessListenerTest.php | 32 +++--- .../AnonymousAuthenticationListenerTest.php | 6 +- .../BasicAuthenticationListenerTest.php | 24 ++-- .../Tests/Firewall/ChannelListenerTest.php | 28 ++--- .../Tests/Firewall/ContextListenerTest.php | 22 ++-- .../DigestAuthenticationListenerTest.php | 4 +- .../Tests/Firewall/ExceptionListenerTest.php | 14 +-- .../Tests/Firewall/LogoutListenerTest.php | 26 ++--- .../Tests/Firewall/RememberMeListenerTest.php | 70 ++++++------ .../SimplePreAuthenticationListenerTest.php | 8 +- .../Tests/Firewall/SwitchUserListenerTest.php | 18 +-- ...PasswordFormAuthenticationListenerTest.php | 10 +- ...PasswordJsonAuthenticationListenerTest.php | 2 +- .../Security/Http/Tests/FirewallMapTest.php | 8 +- .../Security/Http/Tests/FirewallTest.php | 6 +- .../Security/Http/Tests/HttpUtilsTest.php | 14 +-- .../DefaultLogoutSuccessHandlerTest.php | 2 +- .../Tests/Logout/SessionLogoutHandlerTest.php | 2 +- .../AbstractRememberMeServicesTest.php | 26 ++--- ...istentTokenBasedRememberMeServicesTest.php | 22 ++-- .../Tests/RememberMe/ResponseListenerTest.php | 6 +- .../TokenBasedRememberMeServicesTest.php | 24 ++-- .../SessionAuthenticationStrategyTest.php | 2 +- .../Tests/Encoder/ChainDecoderTest.php | 8 +- .../Tests/Encoder/ChainEncoderTest.php | 8 +- .../Factory/CacheMetadataFactoryTest.php | 4 +- .../Factory/ClassMetadataFactoryTest.php | 4 +- .../Normalizer/ArrayDenormalizerTest.php | 8 +- .../Normalizer/GetSetMethodNormalizerTest.php | 2 +- .../JsonSerializableNormalizerTest.php | 8 +- .../Tests/Normalizer/ObjectNormalizerTest.php | 2 +- .../Templating/Tests/DelegatingEngineTest.php | 10 +- .../TranslationDataCollectorTest.php | 4 +- .../Tests/MessageCatalogueTest.php | 14 +-- .../Translation/Tests/TranslatorCacheTest.php | 6 +- .../Test/ConstraintValidatorTestCase.php | 6 +- .../Constraints/ExpressionValidatorTest.php | 4 +- .../Tests/Constraints/FileValidatorTest.php | 16 +-- ...ontainerConstraintValidatorFactoryTest.php | 2 +- .../Tests/Mapping/Cache/AbstractCacheTest.php | 6 +- .../LazyLoadingMetadataFactoryTest.php | 6 +- .../Tests/Mapping/Loader/LoaderChainTest.php | 8 +- .../Tests/Validator/AbstractTest.php | 4 +- .../Component/Workflow/Tests/RegistryTest.php | 4 +- 198 files changed, 1225 insertions(+), 1227 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index 8cc2c0a05bd61..8523be670698e 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -18,8 +18,6 @@ return PhpCsFixer\Config::create() 'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced'], // Part of future @Symfony ruleset in PHP-CS-Fixer To be removed from the config file once upgrading 'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'], - // Part of @Symfony:risky in PHP-CS-Fixer 2.15.0. Incompatible with PHPUnit 4 that is required for Symfony 3.4 - 'php_unit_mock_short_will_return' => false, ]) ->setRiskyAllowed(true) ->setFinder( diff --git a/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php b/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php index 186610820c085..32b4aa730cad3 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php @@ -166,20 +166,20 @@ private function createCollector($queries) ->getMock(); $connection->expects($this->any()) ->method('getDatabasePlatform') - ->will($this->returnValue(new MySqlPlatform())); + ->willReturn(new MySqlPlatform()); $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock(); $registry ->expects($this->any()) ->method('getConnectionNames') - ->will($this->returnValue(['default' => 'doctrine.dbal.default_connection'])); + ->willReturn(['default' => 'doctrine.dbal.default_connection']); $registry ->expects($this->any()) ->method('getManagerNames') - ->will($this->returnValue(['default' => 'doctrine.orm.default_entity_manager'])); + ->willReturn(['default' => 'doctrine.orm.default_entity_manager']); $registry->expects($this->any()) ->method('getConnection') - ->will($this->returnValue($connection)); + ->willReturn($connection); $logger = $this->getMockBuilder('Doctrine\DBAL\Logging\DebugStack')->getMock(); $logger->queries = $queries; diff --git a/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php index 0f53d0952c14b..fb9becd072943 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php @@ -44,9 +44,9 @@ protected function setUp() $this->extension->expects($this->any()) ->method('getObjectManagerElementName') - ->will($this->returnCallback(function ($name) { + ->willReturnCallback(function ($name) { return 'doctrine.orm.'.$name; - })); + }); } /** diff --git a/src/Symfony/Bridge/Doctrine/Tests/ExpressionLanguage/DoctrineParserCacheTest.php b/src/Symfony/Bridge/Doctrine/Tests/ExpressionLanguage/DoctrineParserCacheTest.php index 394b1b0dfe9a2..e376f0a422368 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/ExpressionLanguage/DoctrineParserCacheTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/ExpressionLanguage/DoctrineParserCacheTest.php @@ -26,7 +26,7 @@ public function testFetch() $doctrineCacheMock->expects($this->once()) ->method('fetch') - ->will($this->returnValue('bar')); + ->willReturn('bar'); $result = $parserCache->fetch('foo'); @@ -41,7 +41,7 @@ public function testFetchUnexisting() $doctrineCacheMock ->expects($this->once()) ->method('fetch') - ->will($this->returnValue(false)); + ->willReturn(false); $this->assertNull($parserCache->fetch('')); } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php index c323385ff1929..d2e101b4cdc58 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php @@ -34,47 +34,47 @@ public function requiredProvider() // Simple field, not nullable $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); $classMetadata->fieldMappings['field'] = true; - $classMetadata->expects($this->once())->method('isNullable')->with('field')->will($this->returnValue(false)); + $classMetadata->expects($this->once())->method('isNullable')->with('field')->willReturn(false); $return[] = [$classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)]; // Simple field, nullable $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); $classMetadata->fieldMappings['field'] = true; - $classMetadata->expects($this->once())->method('isNullable')->with('field')->will($this->returnValue(true)); + $classMetadata->expects($this->once())->method('isNullable')->with('field')->willReturn(true); $return[] = [$classMetadata, new ValueGuess(false, Guess::MEDIUM_CONFIDENCE)]; // One-to-one, nullable (by default) $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); - $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(true)); + $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(true); $mapping = ['joinColumns' => [[]]]; - $classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->will($this->returnValue($mapping)); + $classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->willReturn($mapping); $return[] = [$classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE)]; // One-to-one, nullable (explicit) $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); - $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(true)); + $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(true); $mapping = ['joinColumns' => [['nullable' => true]]]; - $classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->will($this->returnValue($mapping)); + $classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->willReturn($mapping); $return[] = [$classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE)]; // One-to-one, not nullable $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); - $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(true)); + $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(true); $mapping = ['joinColumns' => [['nullable' => false]]]; - $classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->will($this->returnValue($mapping)); + $classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->willReturn($mapping); $return[] = [$classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)]; // One-to-many, no clue $classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); - $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(false)); + $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(false); $return[] = [$classMetadata, null]; @@ -84,10 +84,10 @@ public function requiredProvider() private function getGuesser(ClassMetadata $classMetadata) { $em = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock(); - $em->expects($this->once())->method('getClassMetaData')->with('TestEntity')->will($this->returnValue($classMetadata)); + $em->expects($this->once())->method('getClassMetaData')->with('TestEntity')->willReturn($classMetadata); $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock(); - $registry->expects($this->once())->method('getManagers')->will($this->returnValue([$em])); + $registry->expects($this->once())->method('getManagers')->willReturn([$em]); return new DoctrineOrmTypeGuesser($registry); } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php index 5012171542f7b..5dc184fb91009 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php @@ -38,11 +38,11 @@ protected function getExtensions() $manager->expects($this->any()) ->method('getManager') - ->will($this->returnValue($this->em)); + ->willReturn($this->em); $manager->expects($this->any()) ->method('getManagerForClass') - ->will($this->returnValue($this->em)); + ->willReturn($this->em); return [ new CoreExtension(), diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php index 1cb59c38436ef..7a806d76cd7fa 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php @@ -1087,7 +1087,7 @@ public function testGetManagerForClassIfNoEm() $this->emRegistry->expects($this->once()) ->method('getManagerForClass') ->with(self::SINGLE_IDENT_CLASS) - ->will($this->returnValue($this->em)); + ->willReturn($this->em); $this->factory->createNamed('name', static::TESTED_TYPE, null, [ 'class' => self::SINGLE_IDENT_CLASS, @@ -1237,7 +1237,7 @@ protected function createRegistryMock($name, $em) $registry->expects($this->any()) ->method('getManager') ->with($this->equalTo($name)) - ->will($this->returnValue($em)); + ->willReturn($em); return $registry; } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php index 7188a3abc1a75..e88a0a715c391 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php @@ -188,7 +188,7 @@ private function getManager($em, $name = null) $manager->expects($this->any()) ->method('getManager') ->with($this->equalTo($name)) - ->will($this->returnValue($em)); + ->willReturn($em); return $manager; } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php index 60007eb8a3ba8..24a7f555f4f67 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php @@ -82,7 +82,7 @@ protected function createRegistryMock(ObjectManager $em = null) $registry->expects($this->any()) ->method('getManager') ->with($this->equalTo(self::EM_NAME)) - ->will($this->returnValue($em)); + ->willReturn($em); return $registry; } @@ -104,14 +104,14 @@ protected function createEntityManagerMock($repositoryMock) ; $em->expects($this->any()) ->method('getRepository') - ->will($this->returnValue($repositoryMock)) + ->willReturn($repositoryMock) ; $classMetadata = $this->getMockBuilder('Doctrine\Common\Persistence\Mapping\ClassMetadata')->getMock(); $classMetadata ->expects($this->any()) ->method('hasField') - ->will($this->returnValue(true)) + ->willReturn(true) ; $reflParser = $this->getMockBuilder('Doctrine\Common\Reflection\StaticReflectionParser') ->disableOriginalConstructor() @@ -125,12 +125,12 @@ protected function createEntityManagerMock($repositoryMock) $refl ->expects($this->any()) ->method('getValue') - ->will($this->returnValue(true)) + ->willReturn(true) ; $classMetadata->reflFields = ['name' => $refl]; $em->expects($this->any()) ->method('getClassMetadata') - ->will($this->returnValue($classMetadata)) + ->willReturn($classMetadata) ; return $em; @@ -366,7 +366,7 @@ public function testValidateUniquenessUsingCustomRepositoryMethod() $repository = $this->createRepositoryMock(); $repository->expects($this->once()) ->method('findByCustom') - ->will($this->returnValue([])) + ->willReturn([]) ; $this->em = $this->createEntityManagerMock($repository); $this->registry = $this->createRegistryMock($this->em); @@ -394,15 +394,15 @@ public function testValidateUniquenessWithUnrewoundArray() $repository = $this->createRepositoryMock(); $repository->expects($this->once()) ->method('findByCustom') - ->will( - $this->returnCallback(function () use ($entity) { + ->willReturnCallback( + function () use ($entity) { $returnValue = [ $entity, ]; next($returnValue); return $returnValue; - }) + } ) ; $this->em = $this->createEntityManagerMock($repository); @@ -430,7 +430,7 @@ public function testValidateResultTypes($entity1, $result) $repository = $this->createRepositoryMock(); $repository->expects($this->once()) ->method('findByCustom') - ->will($this->returnValue($result)) + ->willReturn($result) ; $this->em = $this->createEntityManagerMock($repository); $this->registry = $this->createRegistryMock($this->em); @@ -564,7 +564,7 @@ public function testValidateUniquenessWithArrayValue() $repository->expects($this->once()) ->method('findByCustom') - ->will($this->returnValue([$entity1])) + ->willReturn([$entity1]) ; $this->em->persist($entity1); @@ -635,7 +635,7 @@ public function testValidateUniquenessOnNullResult() $repository = $this->createRepositoryMock(); $repository ->method('find') - ->will($this->returnValue(null)) + ->willReturn(null) ; $this->em = $this->createEntityManagerMock($repository); diff --git a/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php b/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php index 0f042a90ae862..45a32dea84da4 100644 --- a/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php +++ b/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php @@ -50,7 +50,7 @@ public function testVerbosityMapping($verbosity, $level, $isHandling, array $map $output ->expects($this->atLeastOnce()) ->method('getVerbosity') - ->will($this->returnValue($verbosity)) + ->willReturn($verbosity) ; $handler = new ConsoleHandler($output, true, $map); $this->assertSame($isHandling, $handler->isHandling(['level' => $level]), @@ -114,12 +114,12 @@ public function testVerbosityChanged() $output ->expects($this->at(0)) ->method('getVerbosity') - ->will($this->returnValue(OutputInterface::VERBOSITY_QUIET)) + ->willReturn(OutputInterface::VERBOSITY_QUIET) ; $output ->expects($this->at(1)) ->method('getVerbosity') - ->will($this->returnValue(OutputInterface::VERBOSITY_DEBUG)) + ->willReturn(OutputInterface::VERBOSITY_DEBUG) ; $handler = new ConsoleHandler($output); $this->assertFalse($handler->isHandling(['level' => Logger::NOTICE]), @@ -144,7 +144,7 @@ public function testWritingAndFormatting() $output ->expects($this->any()) ->method('getVerbosity') - ->will($this->returnValue(OutputInterface::VERBOSITY_DEBUG)) + ->willReturn(OutputInterface::VERBOSITY_DEBUG) ; $output ->expects($this->once()) diff --git a/src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php b/src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php index 4da83aa7d6d2c..a69ab75620364 100644 --- a/src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php +++ b/src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php @@ -95,10 +95,10 @@ private function createRequestEvent($additionalServerParameters = []) ->getMock(); $event->expects($this->any()) ->method('isMasterRequest') - ->will($this->returnValue(true)); + ->willReturn(true); $event->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)); + ->willReturn($request); return [$event, $server]; } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php index 9fe36b40c9063..22084ec1ae616 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php @@ -62,7 +62,7 @@ public function testUnknownFragmentRenderer() protected function getFragmentHandler($return) { $strategy = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Fragment\\FragmentRendererInterface')->getMock(); - $strategy->expects($this->once())->method('getName')->will($this->returnValue('inline')); + $strategy->expects($this->once())->method('getName')->willReturn('inline'); $strategy->expects($this->once())->method('render')->will($return); $context = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\RequestStack') @@ -70,7 +70,7 @@ protected function getFragmentHandler($return) ->getMock() ; - $context->expects($this->any())->method('getCurrentRequest')->will($this->returnValue(Request::create('/'))); + $context->expects($this->any())->method('getCurrentRequest')->willReturn(Request::create('/')); return new FragmentHandler($context, [$strategy], false); } @@ -82,9 +82,9 @@ protected function renderTemplate(FragmentHandler $renderer, $template = '{{ ren $twig->addExtension(new HttpKernelExtension()); $loader = $this->getMockBuilder('Twig\RuntimeLoader\RuntimeLoaderInterface')->getMock(); - $loader->expects($this->any())->method('load')->will($this->returnValueMap([ + $loader->expects($this->any())->method('load')->willReturnMap([ ['Symfony\Bridge\Twig\Extension\HttpKernelRuntime', new HttpKernelRuntime($renderer)], - ])); + ]); $twig->addRuntimeLoader($loader); return $twig->render('index'); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplateFinderTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplateFinderTest.php index 94b5432c3ab9b..c1b49c34f992c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplateFinderTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplateFinderTest.php @@ -34,7 +34,7 @@ public function testFindAllTemplates() $kernel ->expects($this->once()) ->method('getBundles') - ->will($this->returnValue(['BaseBundle' => new BaseBundle()])) + ->willReturn(['BaseBundle' => new BaseBundle()]) ; $parser = new TemplateFilenameParser(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php index 30d0242663723..b63c746eb60ca 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php @@ -68,13 +68,13 @@ public function testWarmUp() $this->templateFinder ->expects($this->once()) ->method('findAllTemplates') - ->will($this->returnValue([$template])); + ->willReturn([$template]); $this->fileLocator ->expects($this->once()) ->method('locate') ->with($template->getPath()) - ->will($this->returnValue(\dirname($this->tmpDir).'/path/to/template.html.twig')); + ->willReturn(\dirname($this->tmpDir).'/path/to/template.html.twig'); $warmer = new TemplatePathsCacheWarmer($this->templateFinder, $this->templateLocator); $warmer->warmUp($this->tmpDir); @@ -87,7 +87,7 @@ public function testWarmUpEmpty() $this->templateFinder ->expects($this->once()) ->method('findAllTemplates') - ->will($this->returnValue([])); + ->willReturn([]); $this->fileLocator ->expects($this->never()) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterDebugCommandTest.php index 35a9e4ac0cb28..4790f271de3ff 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterDebugCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterDebugCommandTest.php @@ -82,7 +82,7 @@ private function getRouter() $router ->expects($this->any()) ->method('getRouteCollection') - ->will($this->returnValue($routeCollection)); + ->willReturn($routeCollection); return $router; } @@ -93,13 +93,13 @@ private function getKernel() $container ->expects($this->atLeastOnce()) ->method('has') - ->will($this->returnCallback(function ($id) { + ->willReturnCallback(function ($id) { if ('console.command_loader' === $id) { return false; } return true; - })) + }) ; $container ->expects($this->any()) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterMatchCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterMatchCommandTest.php index a04ef46a90f38..e0bc2de0eb9f4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterMatchCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterMatchCommandTest.php @@ -80,11 +80,11 @@ private function getRouter() $router ->expects($this->any()) ->method('getRouteCollection') - ->will($this->returnValue($routeCollection)); + ->willReturn($routeCollection); $router ->expects($this->any()) ->method('getContext') - ->will($this->returnValue($requestContext)); + ->willReturn($requestContext); return $router; } @@ -95,9 +95,9 @@ private function getKernel() $container ->expects($this->atLeastOnce()) ->method('has') - ->will($this->returnCallback(function ($id) { + ->willReturnCallback(function ($id) { return 'console.command_loader' !== $id; - })) + }) ; $container ->expects($this->any()) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php index 622033e897d90..cfa6e3b8a877e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php @@ -136,26 +136,26 @@ private function createCommandTester($extractedMessages = [], $loadedMessages = $translator ->expects($this->any()) ->method('getFallbackLocales') - ->will($this->returnValue(['en'])); + ->willReturn(['en']); $extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock(); $extractor ->expects($this->any()) ->method('extract') - ->will( - $this->returnCallback(function ($path, $catalogue) use ($extractedMessages) { + ->willReturnCallback( + function ($path, $catalogue) use ($extractedMessages) { $catalogue->add($extractedMessages); - }) + } ); $loader = $this->getMockBuilder('Symfony\Component\Translation\Reader\TranslationReader')->getMock(); $loader ->expects($this->any()) ->method('read') - ->will( - $this->returnCallback(function ($path, $catalogue) use ($loadedMessages) { + ->willReturnCallback( + function ($path, $catalogue) use ($loadedMessages) { $catalogue->add($loadedMessages); - }) + } ); if (null === $kernel) { @@ -173,23 +173,23 @@ private function createCommandTester($extractedMessages = [], $loadedMessages = $kernel ->expects($this->any()) ->method('getBundle') - ->will($this->returnValueMap($returnValues)); + ->willReturnMap($returnValues); } $kernel ->expects($this->any()) ->method('getRootDir') - ->will($this->returnValue($this->translationDir)); + ->willReturn($this->translationDir); $kernel ->expects($this->any()) ->method('getBundles') - ->will($this->returnValue([])); + ->willReturn([]); $kernel ->expects($this->any()) ->method('getContainer') - ->will($this->returnValue($this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock())); + ->willReturn($this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock()); $command = new TranslationDebugCommand($translator, $loader, $extractor, $this->translationDir.'/translations', $this->translationDir.'/templates'); @@ -214,23 +214,23 @@ public function testLegacyDebugCommand() $kernel ->expects($this->any()) ->method('getBundles') - ->will($this->returnValue([])); + ->willReturn([]); $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container ->expects($this->any()) ->method('get') - ->will($this->returnValueMap([ + ->willReturnMap([ ['translation.extractor', 1, $extractor], ['translation.reader', 1, $loader], ['translator', 1, $translator], ['kernel', 1, $kernel], - ])); + ]); $kernel ->expects($this->any()) ->method('getContainer') - ->will($this->returnValue($container)); + ->willReturn($container); $command = new TranslationDebugCommand(); $command->setContainer($container); @@ -250,7 +250,7 @@ private function getBundle($path) $bundle ->expects($this->any()) ->method('getPath') - ->will($this->returnValue($path)) + ->willReturn($path) ; return $bundle; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php index 87bc6c09e2eb9..7e487ff527113 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php @@ -114,36 +114,36 @@ private function createCommandTester($extractedMessages = [], $loadedMessages = $translator ->expects($this->any()) ->method('getFallbackLocales') - ->will($this->returnValue(['en'])); + ->willReturn(['en']); $extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock(); $extractor ->expects($this->any()) ->method('extract') - ->will( - $this->returnCallback(function ($path, $catalogue) use ($extractedMessages) { + ->willReturnCallback( + function ($path, $catalogue) use ($extractedMessages) { foreach ($extractedMessages as $domain => $messages) { $catalogue->add($messages, $domain); } - }) + } ); $loader = $this->getMockBuilder('Symfony\Component\Translation\Reader\TranslationReader')->getMock(); $loader ->expects($this->any()) ->method('read') - ->will( - $this->returnCallback(function ($path, $catalogue) use ($loadedMessages) { + ->willReturnCallback( + function ($path, $catalogue) use ($loadedMessages) { $catalogue->add($loadedMessages); - }) + } ); $writer = $this->getMockBuilder('Symfony\Component\Translation\Writer\TranslationWriter')->getMock(); $writer ->expects($this->any()) ->method('getFormats') - ->will( - $this->returnValue(['xlf', 'yml', 'yaml']) + ->willReturn( + ['xlf', 'yml', 'yaml'] ); if (null === $kernel) { @@ -161,23 +161,23 @@ private function createCommandTester($extractedMessages = [], $loadedMessages = $kernel ->expects($this->any()) ->method('getBundle') - ->will($this->returnValueMap($returnValues)); + ->willReturnMap($returnValues); } $kernel ->expects($this->any()) ->method('getRootDir') - ->will($this->returnValue($this->translationDir)); + ->willReturn($this->translationDir); $kernel ->expects($this->any()) ->method('getBundles') - ->will($this->returnValue([])); + ->willReturn([]); $kernel ->expects($this->any()) ->method('getContainer') - ->will($this->returnValue($this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock())); + ->willReturn($this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock()); $command = new TranslationUpdateCommand($writer, $loader, $extractor, 'en', $this->translationDir.'/translations', $this->translationDir.'/templates'); @@ -203,24 +203,24 @@ public function testLegacyUpdateCommand() $kernel ->expects($this->any()) ->method('getBundles') - ->will($this->returnValue([])); + ->willReturn([]); $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container ->expects($this->any()) ->method('get') - ->will($this->returnValueMap([ + ->willReturnMap([ ['translation.extractor', 1, $extractor], ['translation.reader', 1, $loader], ['translation.writer', 1, $writer], ['translator', 1, $translator], ['kernel', 1, $kernel], - ])); + ]); $kernel ->expects($this->any()) ->method('getContainer') - ->will($this->returnValue($container)); + ->willReturn($container); $command = new TranslationUpdateCommand(); $command->setContainer($container); @@ -240,7 +240,7 @@ private function getBundle($path) $bundle ->expects($this->any()) ->method('getPath') - ->will($this->returnValue($path)) + ->willReturn($path) ; return $bundle; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php index 8c25ef9672f45..fbc5a77339311 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php @@ -206,7 +206,7 @@ private function getKernel(array $bundles, $useDispatcher = false) ->expects($this->atLeastOnce()) ->method('get') ->with($this->equalTo('event_dispatcher')) - ->will($this->returnValue($dispatcher)); + ->willReturn($dispatcher); } $container @@ -226,12 +226,12 @@ private function getKernel(array $bundles, $useDispatcher = false) $kernel ->expects($this->any()) ->method('getBundles') - ->will($this->returnValue($bundles)) + ->willReturn($bundles) ; $kernel ->expects($this->any()) ->method('getContainer') - ->will($this->returnValue($container)) + ->willReturn($container) ; return $kernel; @@ -243,9 +243,9 @@ private function createBundleMock(array $commands) $bundle ->expects($this->once()) ->method('registerCommands') - ->will($this->returnCallback(function (Application $application) use ($commands) { + ->willReturnCallback(function (Application $application) use ($commands) { $application->addCommands($commands); - })) + }) ; return $bundle; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerNameParserTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerNameParserTest.php index 66729f5fa4ea0..91a72821e9539 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerNameParserTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerNameParserTest.php @@ -156,13 +156,13 @@ private function createParser() $kernel ->expects($this->any()) ->method('getBundle') - ->will($this->returnCallback(function ($bundle) use ($bundles) { + ->willReturnCallback(function ($bundle) use ($bundles) { if (!isset($bundles[$bundle])) { throw new \InvalidArgumentException(sprintf('Invalid bundle name "%s"', $bundle)); } return $bundles[$bundle]; - })) + }) ; $bundles = [ @@ -175,7 +175,7 @@ private function createParser() $kernel ->expects($this->any()) ->method('getBundles') - ->will($this->returnValue($bundles)) + ->willReturn($bundles) ; return new ControllerNameParser($kernel); @@ -184,8 +184,8 @@ private function createParser() private function getBundle($namespace, $name) { $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock(); - $bundle->expects($this->any())->method('getName')->will($this->returnValue($name)); - $bundle->expects($this->any())->method('getNamespace')->will($this->returnValue($namespace)); + $bundle->expects($this->any())->method('getName')->willReturn($name); + $bundle->expects($this->any())->method('getNamespace')->willReturn($namespace); return $bundle; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php index 93ce1527ba238..6af19862e6e83 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php @@ -55,7 +55,7 @@ public function testGetControllerWithBundleNotation() $parser->expects($this->once()) ->method('parse') ->with($shortName) - ->will($this->returnValue('Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController::testAction')) + ->willReturn('Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController::testAction') ; $resolver = $this->createControllerResolver(null, null, $parser); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php index e72c558b7edc4..da950ce0c8041 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php @@ -43,9 +43,9 @@ public function testForward() $requestStack->push($request); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); - $kernel->expects($this->once())->method('handle')->will($this->returnCallback(function (Request $request) { + $kernel->expects($this->once())->method('handle')->willReturnCallback(function (Request $request) { return new Response($request->getRequestFormat().'--'.$request->getLocale()); - })); + }); $container = new Container(); $container->set('request_stack', $requestStack); @@ -110,7 +110,7 @@ private function getContainerWithTokenStorage($token = null) $tokenStorage ->expects($this->once()) ->method('getToken') - ->will($this->returnValue($token)); + ->willReturn($token); $container = new Container(); $container->set('security.token_storage', $tokenStorage); @@ -137,7 +137,7 @@ public function testJsonWithSerializer() ->expects($this->once()) ->method('serialize') ->with([], 'json', ['json_encode_options' => JsonResponse::DEFAULT_ENCODING_OPTIONS]) - ->will($this->returnValue('[]')); + ->willReturn('[]'); $container->set('serializer', $serializer); @@ -158,7 +158,7 @@ public function testJsonWithSerializerContextOverride() ->expects($this->once()) ->method('serialize') ->with([], 'json', ['json_encode_options' => 0, 'other' => 'context']) - ->will($this->returnValue('[]')); + ->willReturn('[]'); $container->set('serializer', $serializer); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php index 076912d6e2d68..4bd0212e6953d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php @@ -72,7 +72,7 @@ public function testRoute($permanent, $ignoreAttributes, $expectedCode, $expecte ->expects($this->once()) ->method('generate') ->with($this->equalTo($route), $this->equalTo($expectedAttributes)) - ->will($this->returnValue($url)); + ->willReturn($url); $controller = new RedirectController($router); @@ -250,23 +250,23 @@ private function createRequestObject($scheme, $host, $port, $baseUrl, $queryStri $request ->expects($this->any()) ->method('getScheme') - ->will($this->returnValue($scheme)); + ->willReturn($scheme); $request ->expects($this->any()) ->method('getHost') - ->will($this->returnValue($host)); + ->willReturn($host); $request ->expects($this->any()) ->method('getPort') - ->will($this->returnValue($port)); + ->willReturn($port); $request ->expects($this->any()) ->method('getBaseUrl') - ->will($this->returnValue($baseUrl)); + ->willReturn($baseUrl); $request ->expects($this->any()) ->method('getQueryString') - ->will($this->returnValue($queryString)); + ->willReturn($queryString); return $request; } @@ -288,24 +288,24 @@ private function createLegacyRedirectController($httpPort = null, $httpsPort = n ->expects($this->once()) ->method('hasParameter') ->with($this->equalTo('request_listener.http_port')) - ->will($this->returnValue(true)); + ->willReturn(true); $container ->expects($this->once()) ->method('getParameter') ->with($this->equalTo('request_listener.http_port')) - ->will($this->returnValue($httpPort)); + ->willReturn($httpPort); } if (null !== $httpsPort) { $container ->expects($this->once()) ->method('hasParameter') ->with($this->equalTo('request_listener.https_port')) - ->will($this->returnValue(true)); + ->willReturn(true); $container ->expects($this->once()) ->method('getParameter') ->with($this->equalTo('request_listener.https_port')) - ->will($this->returnValue($httpsPort)); + ->willReturn($httpsPort); } $controller = new RedirectController(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php index 497c112eedb5f..9dba1c05a2bcb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php @@ -49,9 +49,9 @@ public function testLegacyTwig() $twig->expects($this->once())->method('render')->willReturn('bar'); $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); - $container->expects($this->at(0))->method('has')->will($this->returnValue(false)); - $container->expects($this->at(1))->method('has')->will($this->returnValue(true)); - $container->expects($this->at(2))->method('get')->will($this->returnValue($twig)); + $container->expects($this->at(0))->method('has')->willReturn(false); + $container->expects($this->at(1))->method('has')->willReturn(true); + $container->expects($this->at(2))->method('get')->willReturn($twig); $controller = new TemplateController(); $controller->setContainer($container); @@ -69,7 +69,7 @@ public function testLegacyTemplating() $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); $container->expects($this->at(0))->method('has')->willReturn(true); - $container->expects($this->at(1))->method('get')->will($this->returnValue($templating)); + $container->expects($this->at(1))->method('get')->willReturn($templating); $controller = new TemplateController(); $controller->setContainer($container); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php index 8309090809759..9fe45527cffe8 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php @@ -248,7 +248,7 @@ private function getServiceContainer(RouteCollection $routes) $loader ->expects($this->any()) ->method('load') - ->will($this->returnValue($routes)) + ->willReturn($routes) ; $sc = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Container')->setMethods(['get'])->getMock(); @@ -256,7 +256,7 @@ private function getServiceContainer(RouteCollection $routes) $sc ->expects($this->once()) ->method('get') - ->will($this->returnValue($loader)) + ->willReturn($loader) ; return $sc; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php index 73983e47ce363..1fae0526d5d1b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php @@ -67,7 +67,7 @@ public function testRenderResponseWithFrameworkEngine() $engine->expects($this->once()) ->method('renderResponse') ->with('template.php', ['foo' => 'bar']) - ->will($this->returnValue($response)); + ->willReturn($response); $container = $this->getContainerMock(['engine' => $engine]); $delegatingEngine = new DelegatingEngine($container, ['engine']); @@ -91,7 +91,7 @@ private function getEngineMock($template, $supports) $engine->expects($this->once()) ->method('supports') ->with($template) - ->will($this->returnValue($supports)); + ->willReturn($supports); return $engine; } @@ -103,7 +103,7 @@ private function getFrameworkEngineMock($template, $supports) $engine->expects($this->once()) ->method('supports') ->with($template) - ->will($this->returnValue($supports)); + ->willReturn($supports); return $engine; } @@ -117,7 +117,7 @@ private function getContainerMock($services) $container->expects($this->at($i++)) ->method('get') ->with($id) - ->will($this->returnValue($service)); + ->willReturn($service); } return $container; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php index d6c6b299ebc62..46a581b9442e4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php @@ -47,7 +47,7 @@ public function testGetToken() $tokenStorage ->expects($this->once()) ->method('getToken') - ->will($this->returnValue('token')); + ->willReturn('token'); $this->assertSame('token', $this->globals->getToken()); } @@ -77,12 +77,12 @@ public function testGetUser($user, $expectedUser) $token ->expects($this->once()) ->method('getUser') - ->will($this->returnValue($user)); + ->willReturn($user); $tokenStorage ->expects($this->once()) ->method('getToken') - ->will($this->returnValue($token)); + ->willReturn($token); $this->assertSame($expectedUser, $this->globals->getUser()); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php index 3317b15d90914..c78b7e5b2910f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php @@ -27,7 +27,7 @@ public function testLocateATemplate() ->expects($this->once()) ->method('locate') ->with($template->getPath()) - ->will($this->returnValue('/path/to/template')) + ->willReturn('/path/to/template') ; $locator = new TemplateLocator($fileLocator); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php index 85e4917548db0..4460d2ac2b525 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php @@ -26,13 +26,13 @@ protected function setUp() $kernel ->expects($this->any()) ->method('getBundle') - ->will($this->returnCallback(function ($bundle) { + ->willReturnCallback(function ($bundle) { if (\in_array($bundle, ['SensioFooBundle', 'SensioCmsFooBundle', 'FooBundle'])) { return true; } throw new \InvalidArgumentException(); - })) + }) ; $this->parser = new TemplateNameParser($kernel); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php index bd02809dc0173..f3684529f24c4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php @@ -31,7 +31,7 @@ public function testThatRenderLogsTime() $stopwatch->expects($this->once()) ->method('start') ->with('template.php (index.php)', 'template') - ->will($this->returnValue($stopwatchEvent)); + ->willReturn($stopwatchEvent); $stopwatchEvent->expects($this->once())->method('stop'); @@ -56,7 +56,7 @@ private function getTemplateNameParser() $templateNameParser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); $templateNameParser->expects($this->any()) ->method('parse') - ->will($this->returnValue($templateReference)); + ->willReturn($templateReference); return $templateNameParser; } @@ -91,7 +91,7 @@ private function getLoader($storage) $loader = $this->getMockForAbstractClass('Symfony\Component\Templating\Loader\Loader'); $loader->expects($this->once()) ->method('load') - ->will($this->returnValue($storage)); + ->willReturn($storage); return $loader; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php index aff109368b234..9dfd861dbeac0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php @@ -147,7 +147,7 @@ public function testGetDefaultLocaleOmittingLocale() ->expects($this->once()) ->method('getParameter') ->with('kernel.default_locale') - ->will($this->returnValue('en')) + ->willReturn('en') ; $translator = new Translator($container, new MessageFormatter()); @@ -357,53 +357,53 @@ protected function getLoader() $loader ->expects($this->at(0)) ->method('load') - ->will($this->returnValue($this->getCatalogue('fr', [ + ->willReturn($this->getCatalogue('fr', [ 'foo' => 'foo (FR)', - ]))) + ])) ; $loader ->expects($this->at(1)) ->method('load') - ->will($this->returnValue($this->getCatalogue('en', [ + ->willReturn($this->getCatalogue('en', [ 'foo' => 'foo (EN)', 'bar' => 'bar (EN)', 'choice' => '{0} choice 0 (EN)|{1} choice 1 (EN)|]1,Inf] choice inf (EN)', - ]))) + ])) ; $loader ->expects($this->at(2)) ->method('load') - ->will($this->returnValue($this->getCatalogue('es', [ + ->willReturn($this->getCatalogue('es', [ 'foobar' => 'foobar (ES)', - ]))) + ])) ; $loader ->expects($this->at(3)) ->method('load') - ->will($this->returnValue($this->getCatalogue('pt-PT', [ + ->willReturn($this->getCatalogue('pt-PT', [ 'foobarfoo' => 'foobarfoo (PT-PT)', - ]))) + ])) ; $loader ->expects($this->at(4)) ->method('load') - ->will($this->returnValue($this->getCatalogue('pt_BR', [ + ->willReturn($this->getCatalogue('pt_BR', [ 'other choice' => '{0} other choice 0 (PT-BR)|{1} other choice 1 (PT-BR)|]1,Inf] other choice inf (PT-BR)', - ]))) + ])) ; $loader ->expects($this->at(5)) ->method('load') - ->will($this->returnValue($this->getCatalogue('fr.UTF-8', [ + ->willReturn($this->getCatalogue('fr.UTF-8', [ 'foobarbaz' => 'foobarbaz (fr.UTF-8)', - ]))) + ])) ; $loader ->expects($this->at(6)) ->method('load') - ->will($this->returnValue($this->getCatalogue('sr@latin', [ + ->willReturn($this->getCatalogue('sr@latin', [ 'foobarbax' => 'foobarbax (sr@latin)', - ]))) + ])) ; return $loader; @@ -415,7 +415,7 @@ protected function getContainer($loader) $container ->expects($this->any()) ->method('get') - ->will($this->returnValue($loader)) + ->willReturn($loader) ; return $container; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Validator/ConstraintValidatorFactoryTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Validator/ConstraintValidatorFactoryTest.php index 864bd3c3bab75..8afe604c3a46d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Validator/ConstraintValidatorFactoryTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Validator/ConstraintValidatorFactoryTest.php @@ -68,7 +68,7 @@ public function testGetInstanceInvalidValidatorClass() $constraint ->expects($this->exactly(2)) ->method('validatedBy') - ->will($this->returnValue('Fully\\Qualified\\ConstraintValidator\\Class\\Name')); + ->willReturn('Fully\\Qualified\\ConstraintValidator\\Class\\Name'); $factory = new ConstraintValidatorFactory(new Container()); $factory->getInstance($constraint); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/AbstractFactoryTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/AbstractFactoryTest.php index ca82e805c3cd1..9eb9a08177700 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/AbstractFactoryTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/AbstractFactoryTest.php @@ -132,17 +132,17 @@ protected function callFactory($id, $config, $userProviderId, $defaultEntryPoint $factory ->expects($this->once()) ->method('createAuthProvider') - ->will($this->returnValue('auth_provider')) + ->willReturn('auth_provider') ; $factory ->expects($this->atLeastOnce()) ->method('getListenerId') - ->will($this->returnValue('abstract_listener')) + ->willReturn('abstract_listener') ; $factory ->expects($this->any()) ->method('getKey') - ->will($this->returnValue('abstract_factory')) + ->willReturn('abstract_factory') ; $container = new ContainerBuilder(); diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php index 1ca5015a49fcd..ae740e1ab2f20 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php @@ -44,7 +44,7 @@ public function testForwardRequestToConfiguredController() }), $this->equalTo(HttpKernelInterface::SUB_REQUEST) ) - ->will($this->returnValue($response)); + ->willReturn($response); $controller = new PreviewErrorController($kernel, $logicalControllerName); diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php index a73921a8c7687..906a0bc10806c 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php @@ -24,7 +24,7 @@ public function testGetSourceContext() $locator ->expects($this->once()) ->method('locate') - ->will($this->returnValue(__DIR__.'/../DependencyInjection/Fixtures/Resources/views/layout.html.twig')) + ->willReturn(__DIR__.'/../DependencyInjection/Fixtures/Resources/views/layout.html.twig') ; $loader = new FilesystemLoader($locator, $parser); $loader->addPath(__DIR__.'/../DependencyInjection/Fixtures/Resources/views', 'namespace'); @@ -44,7 +44,7 @@ public function testExists() $locator ->expects($this->once()) ->method('locate') - ->will($this->returnValue($template = __DIR__.'/../DependencyInjection/Fixtures/Resources/views/layout.html.twig')) + ->willReturn($template = __DIR__.'/../DependencyInjection/Fixtures/Resources/views/layout.html.twig') ; $loader = new FilesystemLoader($locator, $parser); @@ -61,7 +61,7 @@ public function testTwigErrorIfLocatorThrowsInvalid() ->expects($this->once()) ->method('parse') ->with('name.format.engine') - ->will($this->returnValue(new TemplateReference('', '', 'name', 'format', 'engine'))) + ->willReturn(new TemplateReference('', '', 'name', 'format', 'engine')) ; $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); @@ -85,14 +85,14 @@ public function testTwigErrorIfLocatorReturnsFalse() ->expects($this->once()) ->method('parse') ->with('name.format.engine') - ->will($this->returnValue(new TemplateReference('', '', 'name', 'format', 'engine'))) + ->willReturn(new TemplateReference('', '', 'name', 'format', 'engine')) ; $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); $locator ->expects($this->once()) ->method('locate') - ->will($this->returnValue(false)) + ->willReturn(false) ; $loader = new FilesystemLoader($locator, $parser); diff --git a/src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php b/src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php index 33a873dba88d7..b9092af3ebd0c 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php @@ -18,13 +18,13 @@ class TemplateIteratorTest extends TestCase public function testGetIterator() { $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock(); - $bundle->expects($this->any())->method('getName')->will($this->returnValue('BarBundle')); - $bundle->expects($this->any())->method('getPath')->will($this->returnValue(__DIR__.'/Fixtures/templates/BarBundle')); + $bundle->expects($this->any())->method('getName')->willReturn('BarBundle'); + $bundle->expects($this->any())->method('getPath')->willReturn(__DIR__.'/Fixtures/templates/BarBundle'); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Kernel')->disableOriginalConstructor()->getMock(); - $kernel->expects($this->any())->method('getBundles')->will($this->returnValue([ + $kernel->expects($this->any())->method('getBundles')->willReturn([ $bundle, - ])); + ]); $iterator = new TemplateIterator($kernel, __DIR__.'/Fixtures/templates', [__DIR__.'/Fixtures/templates/Foo' => 'Foo'], __DIR__.'/DependencyInjection/Fixtures/templates'); $sorted = iterator_to_array($iterator); diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php index a507d36cf08a6..a1e23041f8aac 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php @@ -97,11 +97,11 @@ public function testReturns404onTokenNotFound($withCsp) $profiler ->expects($this->exactly(2)) ->method('loadProfile') - ->will($this->returnCallback(function ($token) { + ->willReturnCallback(function ($token) { if ('found' == $token) { return new Profile($token); } - })) + }) ; $controller = $this->createController($profiler, $twig, $withCsp); @@ -149,7 +149,7 @@ public function testSearchResult($withCsp) $profiler ->expects($this->once()) ->method('find') - ->will($this->returnValue($tokens)); + ->willReturn($tokens); $request = Request::create('/_profiler/empty/search/results', 'GET', [ 'limit' => 2, diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Csp/ContentSecurityPolicyHandlerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Csp/ContentSecurityPolicyHandlerTest.php index bbf96c3b2b344..acccc7cbfb6d2 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Csp/ContentSecurityPolicyHandlerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Csp/ContentSecurityPolicyHandlerTest.php @@ -200,7 +200,7 @@ private function mockNonceGenerator($value) $generator->expects($this->any()) ->method('generate') - ->will($this->returnValue($value)); + ->willReturn($value); return $generator; } diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php index 1260886f8df13..f8255f3894de3 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php @@ -244,7 +244,7 @@ public function testXDebugUrlHeader() ->expects($this->once()) ->method('generate') ->with('_profiler', ['token' => 'xxxxxxxx'], UrlGeneratorInterface::ABSOLUTE_URL) - ->will($this->returnValue('http://mydomain.com/_profiler/xxxxxxxx')) + ->willReturn('http://mydomain.com/_profiler/xxxxxxxx') ; $event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); @@ -302,10 +302,10 @@ protected function getRequestMock($isXmlHttpRequest = false, $requestFormat = 'h $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->setMethods(['getSession', 'isXmlHttpRequest', 'getRequestFormat'])->disableOriginalConstructor()->getMock(); $request->expects($this->any()) ->method('isXmlHttpRequest') - ->will($this->returnValue($isXmlHttpRequest)); + ->willReturn($isXmlHttpRequest); $request->expects($this->any()) ->method('getRequestFormat') - ->will($this->returnValue($requestFormat)); + ->willReturn($requestFormat); $request->headers = new HeaderBag(); @@ -313,7 +313,7 @@ protected function getRequestMock($isXmlHttpRequest = false, $requestFormat = 'h $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')->disableOriginalConstructor()->getMock(); $request->expects($this->any()) ->method('getSession') - ->will($this->returnValue($session)); + ->willReturn($session); } return $request; @@ -324,7 +324,7 @@ protected function getTwigMock($render = 'WDT') $templating = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); $templating->expects($this->any()) ->method('render') - ->will($this->returnValue($render)); + ->willReturn($render); return $templating; } diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php index 18d4cc44b4021..c6bc1cdba36ed 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php @@ -69,7 +69,7 @@ public function testGetNameValidTemplate() $this->profiler->expects($this->any()) ->method('has') ->withAnyParameters() - ->will($this->returnCallback([$this, 'profilerHasCallback'])); + ->willReturnCallback([$this, 'profilerHasCallback']); $this->assertEquals('FooBundle:Collector:foo.html.twig', $this->templateManager->getName(new ProfileDummy(), 'foo')); } @@ -83,7 +83,7 @@ public function testGetTemplates() $this->profiler->expects($this->any()) ->method('has') ->withAnyParameters() - ->will($this->returnCallback([$this, 'profileHasCollectorCallback'])); + ->willReturnCallback([$this, 'profileHasCollectorCallback']); $result = $this->templateManager->getTemplates(new ProfileDummy()); $this->assertArrayHasKey('foo', $result); @@ -124,14 +124,14 @@ protected function mockTwigEnvironment() $this->twigEnvironment->expects($this->any()) ->method('loadTemplate') - ->will($this->returnValue('loadedTemplate')); + ->willReturn('loadedTemplate'); if (interface_exists('Twig\Loader\SourceContextLoaderInterface')) { $loader = $this->getMockBuilder('Twig\Loader\SourceContextLoaderInterface')->getMock(); } else { $loader = $this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock(); } - $this->twigEnvironment->expects($this->any())->method('getLoader')->will($this->returnValue($loader)); + $this->twigEnvironment->expects($this->any())->method('getLoader')->willReturn($loader); return $this->twigEnvironment; } diff --git a/src/Symfony/Component/Asset/Tests/PathPackageTest.php b/src/Symfony/Component/Asset/Tests/PathPackageTest.php index c6edc8de61a7d..d00cc76c2a943 100644 --- a/src/Symfony/Component/Asset/Tests/PathPackageTest.php +++ b/src/Symfony/Component/Asset/Tests/PathPackageTest.php @@ -89,7 +89,7 @@ public function testVersionStrategyGivesAbsoluteURL() private function getContext($basePath) { $context = $this->getMockBuilder('Symfony\Component\Asset\Context\ContextInterface')->getMock(); - $context->expects($this->any())->method('getBasePath')->will($this->returnValue($basePath)); + $context->expects($this->any())->method('getBasePath')->willReturn($basePath); return $context; } diff --git a/src/Symfony/Component/Asset/Tests/UrlPackageTest.php b/src/Symfony/Component/Asset/Tests/UrlPackageTest.php index 9b71d45bf31d7..a68c59a1249c1 100644 --- a/src/Symfony/Component/Asset/Tests/UrlPackageTest.php +++ b/src/Symfony/Component/Asset/Tests/UrlPackageTest.php @@ -107,7 +107,7 @@ public function testWrongBaseUrl() private function getContext($secure) { $context = $this->getMockBuilder('Symfony\Component\Asset\Context\ContextInterface')->getMock(); - $context->expects($this->any())->method('isSecure')->will($this->returnValue($secure)); + $context->expects($this->any())->method('isSecure')->willReturn($secure); return $context; } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php index 010f68b973e35..3b42697fe1385 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php @@ -80,7 +80,7 @@ private function getPruneableMock() $pruneable ->expects($this->atLeastOnce()) ->method('prune') - ->will($this->returnValue(true)); + ->willReturn(true); return $pruneable; } @@ -97,7 +97,7 @@ private function getFailingPruneableMock() $pruneable ->expects($this->atLeastOnce()) ->method('prune') - ->will($this->returnValue(false)); + ->willReturn(false); return $pruneable; } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php index d0a1e5daf77be..488127cc950ad 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php @@ -173,7 +173,7 @@ private function getPruneableMock() $pruneable ->expects($this->atLeastOnce()) ->method('prune') - ->will($this->returnValue(true)); + ->willReturn(true); return $pruneable; } @@ -190,7 +190,7 @@ private function getFailingPruneableMock() $pruneable ->expects($this->atLeastOnce()) ->method('prune') - ->will($this->returnValue(false)); + ->willReturn(false); return $pruneable; } diff --git a/src/Symfony/Component/Cache/Tests/Simple/ChainCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/ChainCacheTest.php index e6f7c7cc63229..aa77887919b74 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/ChainCacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/ChainCacheTest.php @@ -78,7 +78,7 @@ private function getPruneableMock() $pruneable ->expects($this->atLeastOnce()) ->method('prune') - ->will($this->returnValue(true)); + ->willReturn(true); return $pruneable; } @@ -95,7 +95,7 @@ private function getFailingPruneableMock() $pruneable ->expects($this->atLeastOnce()) ->method('prune') - ->will($this->returnValue(false)); + ->willReturn(false); return $pruneable; } diff --git a/src/Symfony/Component/Config/Tests/Loader/DelegatingLoaderTest.php b/src/Symfony/Component/Config/Tests/Loader/DelegatingLoaderTest.php index 6e2a6ba2229d7..6556962d1f15c 100644 --- a/src/Symfony/Component/Config/Tests/Loader/DelegatingLoaderTest.php +++ b/src/Symfony/Component/Config/Tests/Loader/DelegatingLoaderTest.php @@ -35,12 +35,12 @@ public function testGetSetResolver() public function testSupports() { $loader1 = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); - $loader1->expects($this->once())->method('supports')->will($this->returnValue(true)); + $loader1->expects($this->once())->method('supports')->willReturn(true); $loader = new DelegatingLoader(new LoaderResolver([$loader1])); $this->assertTrue($loader->supports('foo.xml'), '->supports() returns true if the resource is loadable'); $loader1 = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); - $loader1->expects($this->once())->method('supports')->will($this->returnValue(false)); + $loader1->expects($this->once())->method('supports')->willReturn(false); $loader = new DelegatingLoader(new LoaderResolver([$loader1])); $this->assertFalse($loader->supports('foo.foo'), '->supports() returns false if the resource is not loadable'); } @@ -48,7 +48,7 @@ public function testSupports() public function testLoad() { $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); - $loader->expects($this->once())->method('supports')->will($this->returnValue(true)); + $loader->expects($this->once())->method('supports')->willReturn(true); $loader->expects($this->once())->method('load'); $resolver = new LoaderResolver([$loader]); $loader = new DelegatingLoader($resolver); @@ -62,7 +62,7 @@ public function testLoad() public function testLoadThrowsAnExceptionIfTheResourceCannotBeLoaded() { $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); - $loader->expects($this->once())->method('supports')->will($this->returnValue(false)); + $loader->expects($this->once())->method('supports')->willReturn(false); $resolver = new LoaderResolver([$loader]); $loader = new DelegatingLoader($resolver); diff --git a/src/Symfony/Component/Config/Tests/Loader/LoaderResolverTest.php b/src/Symfony/Component/Config/Tests/Loader/LoaderResolverTest.php index 487dc43adc310..aabc2a600d8dd 100644 --- a/src/Symfony/Component/Config/Tests/Loader/LoaderResolverTest.php +++ b/src/Symfony/Component/Config/Tests/Loader/LoaderResolverTest.php @@ -32,7 +32,7 @@ public function testResolve() $this->assertFalse($resolver->resolve('foo.foo'), '->resolve() returns false if no loader is able to load the resource'); $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); - $loader->expects($this->once())->method('supports')->will($this->returnValue(true)); + $loader->expects($this->once())->method('supports')->willReturn(true); $resolver = new LoaderResolver([$loader]); $this->assertEquals($loader, $resolver->resolve(function () {}), '->resolve() returns the loader for the given resource'); } diff --git a/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php b/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php index 30167e3836f85..0c6e3fc025d19 100644 --- a/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php +++ b/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php @@ -34,7 +34,7 @@ public function testResolve() $resolver->expects($this->once()) ->method('resolve') ->with('foo.xml') - ->will($this->returnValue($resolvedLoader)); + ->willReturn($resolvedLoader); $loader = new ProjectLoader1(); $loader->setResolver($resolver); @@ -52,7 +52,7 @@ public function testResolveWhenResolverCannotFindLoader() $resolver->expects($this->once()) ->method('resolve') ->with('FOOBAR') - ->will($this->returnValue(false)); + ->willReturn(false); $loader = new ProjectLoader1(); $loader->setResolver($resolver); @@ -66,13 +66,13 @@ public function testImport() $resolvedLoader->expects($this->once()) ->method('load') ->with('foo') - ->will($this->returnValue('yes')); + ->willReturn('yes'); $resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock(); $resolver->expects($this->once()) ->method('resolve') ->with('foo') - ->will($this->returnValue($resolvedLoader)); + ->willReturn($resolvedLoader); $loader = new ProjectLoader1(); $loader->setResolver($resolver); @@ -86,13 +86,13 @@ public function testImportWithType() $resolvedLoader->expects($this->once()) ->method('load') ->with('foo', 'bar') - ->will($this->returnValue('yes')); + ->willReturn('yes'); $resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock(); $resolver->expects($this->once()) ->method('resolve') ->with('foo', 'bar') - ->will($this->returnValue($resolvedLoader)); + ->willReturn($resolvedLoader); $loader = new ProjectLoader1(); $loader->setResolver($resolver); diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php index b920d211aaa8f..181e82593db76 100644 --- a/src/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php @@ -660,7 +660,7 @@ public function testFindNamespaceDoesNotFailOnDeepSimilarNamespaces() $application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(['getNamespaces'])->getMock(); $application->expects($this->once()) ->method('getNamespaces') - ->will($this->returnValue(['foo:sublong', 'bar:sub'])); + ->willReturn(['foo:sublong', 'bar:sub']); $this->assertEquals('foo:sublong', $application->findNamespace('f:sub')); } @@ -804,7 +804,7 @@ public function testRenderExceptionLineBreaks() $application->setAutoExit(false); $application->expects($this->any()) ->method('getTerminalWidth') - ->will($this->returnValue(120)); + ->willReturn(120); $application->register('foo')->setCode(function () { throw new \InvalidArgumentException("\n\nline 1 with extra spaces \nline 2\n\nline 4\n"); }); diff --git a/src/Symfony/Component/Console/Tests/Command/CommandTest.php b/src/Symfony/Component/Console/Tests/Command/CommandTest.php index b3ce402209a8e..9a135d325590a 100644 --- a/src/Symfony/Component/Console/Tests/Command/CommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/CommandTest.php @@ -321,7 +321,7 @@ public function testRunReturnsIntegerExitCode() $command = $this->getMockBuilder('TestCommand')->setMethods(['execute'])->getMock(); $command->expects($this->once()) ->method('execute') - ->will($this->returnValue('2.3')); + ->willReturn('2.3'); $exitCode = $command->run(new StringInput(''), new NullOutput()); $this->assertSame(2, $exitCode, '->run() returns integer exit code (casts numeric to int)'); } diff --git a/src/Symfony/Component/Console/Tests/Helper/AbstractQuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/AbstractQuestionHelperTest.php index 56dd65f6b456f..f12566dedd655 100644 --- a/src/Symfony/Component/Console/Tests/Helper/AbstractQuestionHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/AbstractQuestionHelperTest.php @@ -21,7 +21,7 @@ protected function createStreamableInputInterfaceMock($stream = null, $interacti $mock = $this->getMockBuilder(StreamableInputInterface::class)->getMock(); $mock->expects($this->any()) ->method('isInteractive') - ->will($this->returnValue($interactive)); + ->willReturn($interactive); if ($stream) { $mock->expects($this->any()) diff --git a/src/Symfony/Component/Console/Tests/Helper/HelperSetTest.php b/src/Symfony/Component/Console/Tests/Helper/HelperSetTest.php index 826bc51dcd62b..ffb12b3421f9a 100644 --- a/src/Symfony/Component/Console/Tests/Helper/HelperSetTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/HelperSetTest.php @@ -114,7 +114,7 @@ private function getGenericMockHelper($name, HelperSet $helperset = null) $mock_helper = $this->getMockBuilder('\Symfony\Component\Console\Helper\HelperInterface')->getMock(); $mock_helper->expects($this->any()) ->method('getName') - ->will($this->returnValue($name)); + ->willReturn($name); if ($helperset) { $mock_helper->expects($this->any()) diff --git a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php index 3c030e04983d9..53819e4be70ed 100644 --- a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php @@ -1068,7 +1068,7 @@ protected function createInputInterfaceMock($interactive = true) $mock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock(); $mock->expects($this->any()) ->method('isInteractive') - ->will($this->returnValue($interactive)); + ->willReturn($interactive); return $mock; } diff --git a/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php index cf7a78c34ecda..6f621db95448a 100644 --- a/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php @@ -154,7 +154,7 @@ protected function createInputInterfaceMock($interactive = true) $mock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock(); $mock->expects($this->any()) ->method('isInteractive') - ->will($this->returnValue($interactive)); + ->willReturn($interactive); return $mock; } diff --git a/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php b/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php index efeec4234e952..c99eb839b7f31 100644 --- a/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php +++ b/src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php @@ -166,7 +166,7 @@ public function testObjectCastToString() } else { $dummy = $this->getMock('Symfony\Component\Console\Tests\Logger\DummyTest', ['__toString']); } - $dummy->method('__toString')->will($this->returnValue('DUMMY')); + $dummy->method('__toString')->willReturn('DUMMY'); $this->getLogger()->warning($dummy); diff --git a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php index 15de37c7b7808..bb82c63328b19 100644 --- a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php @@ -234,7 +234,7 @@ public function testHandleError() $logger ->expects($this->once()) ->method('log') - ->will($this->returnCallback($warnArgCheck)) + ->willReturnCallback($warnArgCheck) ; $handler = ErrorHandler::register(); @@ -262,7 +262,7 @@ public function testHandleError() $logger ->expects($this->once()) ->method('log') - ->will($this->returnCallback($logArgCheck)) + ->willReturnCallback($logArgCheck) ; $handler = ErrorHandler::register(); @@ -318,7 +318,7 @@ public function testHandleDeprecation() $logger ->expects($this->once()) ->method('log') - ->will($this->returnCallback($logArgCheck)) + ->willReturnCallback($logArgCheck) ; $handler = new ErrorHandler(); @@ -349,7 +349,7 @@ public function testHandleException() $logger ->expects($this->exactly(2)) ->method('log') - ->will($this->returnCallback($logArgCheck)) + ->willReturnCallback($logArgCheck) ; $handler->setDefaultLogger($logger, E_ERROR); @@ -503,7 +503,7 @@ public function testHandleFatalError() $logger ->expects($this->once()) ->method('log') - ->will($this->returnCallback($logArgCheck)) + ->willReturnCallback($logArgCheck) ; $handler->setDefaultLogger($logger, E_PARSE); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowireExceptionPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowireExceptionPassTest.php index 5bcb1234223a9..c5ba149aebea2 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowireExceptionPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowireExceptionPassTest.php @@ -31,13 +31,13 @@ public function testThrowsException() $autowireException = new AutowiringFailedException('foo_service_id', 'An autowiring exception message'); $autowirePass->expects($this->any()) ->method('getAutowiringExceptions') - ->will($this->returnValue([$autowireException])); + ->willReturn([$autowireException]); $inlinePass = $this->getMockBuilder(InlineServiceDefinitionsPass::class) ->getMock(); $inlinePass->expects($this->any()) ->method('getInlinedServiceIds') - ->will($this->returnValue([])); + ->willReturn([]); $container = new ContainerBuilder(); $container->register('foo_service_id'); @@ -60,18 +60,18 @@ public function testThrowExceptionIfServiceInlined() $autowireException = new AutowiringFailedException('a_service', 'An autowiring exception message'); $autowirePass->expects($this->any()) ->method('getAutowiringExceptions') - ->will($this->returnValue([$autowireException])); + ->willReturn([$autowireException]); $inlinePass = $this->getMockBuilder(InlineServiceDefinitionsPass::class) ->getMock(); $inlinePass->expects($this->any()) ->method('getInlinedServiceIds') - ->will($this->returnValue([ + ->willReturn([ // a_service inlined into b_service 'a_service' => ['b_service'], // b_service inlined into c_service 'b_service' => ['c_service'], - ])); + ]); $container = new ContainerBuilder(); // ONLY register c_service in the final container @@ -95,18 +95,18 @@ public function testDoNotThrowExceptionIfServiceInlinedButRemoved() $autowireException = new AutowiringFailedException('a_service', 'An autowiring exception message'); $autowirePass->expects($this->any()) ->method('getAutowiringExceptions') - ->will($this->returnValue([$autowireException])); + ->willReturn([$autowireException]); $inlinePass = $this->getMockBuilder(InlineServiceDefinitionsPass::class) ->getMock(); $inlinePass->expects($this->any()) ->method('getInlinedServiceIds') - ->will($this->returnValue([ + ->willReturn([ // a_service inlined into b_service 'a_service' => ['b_service'], // b_service inlined into c_service 'b_service' => ['c_service'], - ])); + ]); // do NOT register c_service in the container $container = new ContainerBuilder(); @@ -126,13 +126,13 @@ public function testNoExceptionIfServiceRemoved() $autowireException = new AutowiringFailedException('non_existent_service'); $autowirePass->expects($this->any()) ->method('getAutowiringExceptions') - ->will($this->returnValue([$autowireException])); + ->willReturn([$autowireException]); $inlinePass = $this->getMockBuilder(InlineServiceDefinitionsPass::class) ->getMock(); $inlinePass->expects($this->any()) ->method('getInlinedServiceIds') - ->will($this->returnValue([])); + ->willReturn([]); $container = new ContainerBuilder(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php index 667ae388648ae..1bef795f2b523 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php @@ -30,18 +30,18 @@ public function testExpressionLanguageProviderForwarding() $extension = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface')->getMock(); $extension->expects($this->any()) ->method('getXsdValidationBasePath') - ->will($this->returnValue(false)); + ->willReturn(false); $extension->expects($this->any()) ->method('getNamespace') - ->will($this->returnValue('http://example.org/schema/dic/foo')); + ->willReturn('http://example.org/schema/dic/foo'); $extension->expects($this->any()) ->method('getAlias') - ->will($this->returnValue('foo')); + ->willReturn('foo'); $extension->expects($this->once()) ->method('load') - ->will($this->returnCallback(function (array $config, ContainerBuilder $container) use (&$tmpProviders) { + ->willReturnCallback(function (array $config, ContainerBuilder $container) use (&$tmpProviders) { $tmpProviders = $container->getExpressionLanguageProviders(); - })); + }); $provider = $this->getMockBuilder('Symfony\\Component\\ExpressionLanguage\\ExpressionFunctionProviderInterface')->getMock(); $container = new ContainerBuilder(new ParameterBag()); @@ -76,7 +76,7 @@ public function testExtensionConfigurationIsTrackedByDefault() $extension = $this->getMockBuilder(FooExtension::class)->setMethods(['getConfiguration'])->getMock(); $extension->expects($this->exactly(2)) ->method('getConfiguration') - ->will($this->returnValue(new FooConfiguration())); + ->willReturn(new FooConfiguration()); $container = new ContainerBuilder(new ParameterBag()); $container->registerExtension($extension); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Config/ContainerParametersResourceCheckerTest.php b/src/Symfony/Component/DependencyInjection/Tests/Config/ContainerParametersResourceCheckerTest.php index fc2d85ecf9560..eb5fc5a99d2e1 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Config/ContainerParametersResourceCheckerTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Config/ContainerParametersResourceCheckerTest.php @@ -67,10 +67,10 @@ public function isFreshProvider() [$this->equalTo('locales')], [$this->equalTo('default_locale')] ) - ->will($this->returnValueMap([ + ->willReturnMap([ ['locales', ['fr', 'en']], ['default_locale', 'fr'], - ])) + ]) ; }, true]; } diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php index 73cb670cdb121..b3bea30b749b9 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php @@ -1059,7 +1059,7 @@ public function testExtension() public function testRegisteredButNotLoadedExtension() { $extension = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface')->getMock(); - $extension->expects($this->once())->method('getAlias')->will($this->returnValue('project')); + $extension->expects($this->once())->method('getAlias')->willReturn('project'); $extension->expects($this->never())->method('load'); $container = new ContainerBuilder(); @@ -1071,7 +1071,7 @@ public function testRegisteredButNotLoadedExtension() public function testRegisteredAndLoadedExtension() { $extension = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface')->getMock(); - $extension->expects($this->exactly(2))->method('getAlias')->will($this->returnValue('project')); + $extension->expects($this->exactly(2))->method('getAlias')->willReturn('project'); $extension->expects($this->once())->method('load')->with([['foo' => 'bar']]); $container = new ContainerBuilder(); diff --git a/src/Symfony/Component/DomCrawler/Tests/FormTest.php b/src/Symfony/Component/DomCrawler/Tests/FormTest.php index 2778fd075e3a5..2c0ee22c1fc45 100644 --- a/src/Symfony/Component/DomCrawler/Tests/FormTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/FormTest.php @@ -862,13 +862,13 @@ protected function getFormFieldMock($name, $value = null) $field ->expects($this->any()) ->method('getName') - ->will($this->returnValue($name)) + ->willReturn($name) ; $field ->expects($this->any()) ->method('getValue') - ->will($this->returnValue($value)) + ->willReturn($value) ; return $field; diff --git a/src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php index 04f2861e33193..c52fefe509ae9 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php @@ -43,7 +43,7 @@ public function testDispatchDelegates() $this->innerDispatcher->expects($this->once()) ->method('dispatch') ->with('event', $event) - ->will($this->returnValue('result')); + ->willReturn('result'); $this->assertSame('result', $this->dispatcher->dispatch('event', $event)); } @@ -53,7 +53,7 @@ public function testGetListenersDelegates() $this->innerDispatcher->expects($this->once()) ->method('getListeners') ->with('event') - ->will($this->returnValue('result')); + ->willReturn('result'); $this->assertSame('result', $this->dispatcher->getListeners('event')); } @@ -63,7 +63,7 @@ public function testHasListenersDelegates() $this->innerDispatcher->expects($this->once()) ->method('hasListeners') ->with('event') - ->will($this->returnValue('result')); + ->willReturn('result'); $this->assertSame('result', $this->dispatcher->hasListeners('event')); } diff --git a/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php b/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php index d2a660286da14..83b608b2b9956 100644 --- a/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php +++ b/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php @@ -36,18 +36,18 @@ public function testCachedParse() $cacheItemMock ->expects($this->exactly(2)) ->method('get') - ->will($this->returnCallback(function () use (&$savedParsedExpression) { + ->willReturnCallback(function () use (&$savedParsedExpression) { return $savedParsedExpression; - })) + }) ; $cacheItemMock ->expects($this->exactly(1)) ->method('set') ->with($this->isInstanceOf(ParsedExpression::class)) - ->will($this->returnCallback(function ($parsedExpression) use (&$savedParsedExpression) { + ->willReturnCallback(function ($parsedExpression) use (&$savedParsedExpression) { $savedParsedExpression = $parsedExpression; - })) + }) ; $cacheMock @@ -85,9 +85,9 @@ public function testCachedParseWithDeprecatedParserCacheInterface() ->expects($this->exactly(1)) ->method('save') ->with('1%20%2B%201%2F%2F', $this->isInstanceOf(ParsedExpression::class)) - ->will($this->returnCallback(function ($key, $expression) use (&$savedParsedExpression) { + ->willReturnCallback(function ($key, $expression) use (&$savedParsedExpression) { $savedParsedExpression = $expression; - })) + }) ; $parsedExpression = $expressionLanguage->parse('1 + 1', []); @@ -213,18 +213,18 @@ public function testCachingWithDifferentNamesOrder() $cacheItemMock ->expects($this->exactly(2)) ->method('get') - ->will($this->returnCallback(function () use (&$savedParsedExpression) { + ->willReturnCallback(function () use (&$savedParsedExpression) { return $savedParsedExpression; - })) + }) ; $cacheItemMock ->expects($this->exactly(1)) ->method('set') ->with($this->isInstanceOf(ParsedExpression::class)) - ->will($this->returnCallback(function ($parsedExpression) use (&$savedParsedExpression) { + ->willReturnCallback(function ($parsedExpression) use (&$savedParsedExpression) { $savedParsedExpression = $parsedExpression; - })) + }) ; $cacheMock diff --git a/src/Symfony/Component/Finder/Tests/Iterator/FilterIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/FilterIteratorTest.php index b26f7ba6bdd28..181b1464fcd9a 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/FilterIteratorTest.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/FilterIteratorTest.php @@ -26,9 +26,9 @@ public function testFilterFilesystemIterators() $i = $this->getMockForAbstractClass('Symfony\Component\Finder\Iterator\FilterIterator', [$i]); $i->expects($this->any()) ->method('accept') - ->will($this->returnCallback(function () use ($i) { + ->willReturnCallback(function () use ($i) { return (bool) preg_match('/\.php/', (string) $i->current()); - }) + } ); $c = 0; diff --git a/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php index ab8444974959d..fe0d3e6629b26 100644 --- a/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php @@ -473,7 +473,7 @@ public function testCsrf() { $this->csrfTokenManager->expects($this->any()) ->method('getToken') - ->will($this->returnValue(new CsrfToken('token_id', 'foo&bar'))); + ->willReturn(new CsrfToken('token_id', 'foo&bar')); $form = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType') ->add($this->factory diff --git a/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php b/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php index b470769344bb2..f2ee71b3424cd 100644 --- a/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php @@ -312,10 +312,10 @@ public function testAddFormErrorIfPostMaxSizeExceeded($contentLength, $iniMax, $ { $this->serverParams->expects($this->once()) ->method('getContentLength') - ->will($this->returnValue($contentLength)); + ->willReturn($contentLength); $this->serverParams->expects($this->any()) ->method('getNormalizedIniPostMaxSize') - ->will($this->returnValue($iniMax)); + ->willReturn($iniMax); $options = ['post_max_size_message' => 'Max {{ max }}!']; $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, $options); diff --git a/src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php index 6c09ba8ead456..7cc68bd83d268 100644 --- a/src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php @@ -339,7 +339,7 @@ public function testCsrf() { $this->csrfTokenManager->expects($this->any()) ->method('getToken') - ->will($this->returnValue(new CsrfToken('token_id', 'foo&bar'))); + ->willReturn(new CsrfToken('token_id', 'foo&bar')); $form = $this->factory->createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType') ->add($this->factory diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php index ca5b67c817f2e..7277d49780d65 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php @@ -42,7 +42,7 @@ public function testCreateFromChoicesEmpty() $this->decoratedFactory->expects($this->once()) ->method('createListFromChoices') ->with([]) - ->will($this->returnValue($list)); + ->willReturn($list); $this->assertSame($list, $this->factory->createListFromChoices([])); $this->assertSame($list, $this->factory->createListFromChoices([])); @@ -58,7 +58,7 @@ public function testCreateFromChoicesComparesTraversableChoicesAsArray() $this->decoratedFactory->expects($this->once()) ->method('createListFromChoices') ->with($choices2) - ->will($this->returnValue($list)); + ->willReturn($list); $this->assertSame($list, $this->factory->createListFromChoices($choices1)); $this->assertSame($list, $this->factory->createListFromChoices($choices2)); @@ -74,11 +74,11 @@ public function testCreateFromChoicesGroupedChoices() $this->decoratedFactory->expects($this->at(0)) ->method('createListFromChoices') ->with($choices1) - ->will($this->returnValue($list1)); + ->willReturn($list1); $this->decoratedFactory->expects($this->at(1)) ->method('createListFromChoices') ->with($choices2) - ->will($this->returnValue($list2)); + ->willReturn($list2); $this->assertSame($list1, $this->factory->createListFromChoices($choices1)); $this->assertSame($list2, $this->factory->createListFromChoices($choices2)); @@ -96,7 +96,7 @@ public function testCreateFromChoicesSameChoices($choice1, $choice2) $this->decoratedFactory->expects($this->once()) ->method('createListFromChoices') ->with($choices1) - ->will($this->returnValue($list)); + ->willReturn($list); $this->assertSame($list, $this->factory->createListFromChoices($choices1)); $this->assertSame($list, $this->factory->createListFromChoices($choices2)); @@ -115,11 +115,11 @@ public function testCreateFromChoicesDifferentChoices($choice1, $choice2) $this->decoratedFactory->expects($this->at(0)) ->method('createListFromChoices') ->with($choices1) - ->will($this->returnValue($list1)); + ->willReturn($list1); $this->decoratedFactory->expects($this->at(1)) ->method('createListFromChoices') ->with($choices2) - ->will($this->returnValue($list2)); + ->willReturn($list2); $this->assertSame($list1, $this->factory->createListFromChoices($choices1)); $this->assertSame($list2, $this->factory->createListFromChoices($choices2)); @@ -134,7 +134,7 @@ public function testCreateFromChoicesSameValueClosure() $this->decoratedFactory->expects($this->once()) ->method('createListFromChoices') ->with($choices, $closure) - ->will($this->returnValue($list)); + ->willReturn($list); $this->assertSame($list, $this->factory->createListFromChoices($choices, $closure)); $this->assertSame($list, $this->factory->createListFromChoices($choices, $closure)); @@ -151,11 +151,11 @@ public function testCreateFromChoicesDifferentValueClosure() $this->decoratedFactory->expects($this->at(0)) ->method('createListFromChoices') ->with($choices, $closure1) - ->will($this->returnValue($list1)); + ->willReturn($list1); $this->decoratedFactory->expects($this->at(1)) ->method('createListFromChoices') ->with($choices, $closure2) - ->will($this->returnValue($list2)); + ->willReturn($list2); $this->assertSame($list1, $this->factory->createListFromChoices($choices, $closure1)); $this->assertSame($list2, $this->factory->createListFromChoices($choices, $closure2)); @@ -169,7 +169,7 @@ public function testCreateFromLoaderSameLoader() $this->decoratedFactory->expects($this->once()) ->method('createListFromLoader') ->with($loader) - ->will($this->returnValue($list)); + ->willReturn($list); $this->assertSame($list, $this->factory->createListFromLoader($loader)); $this->assertSame($list, $this->factory->createListFromLoader($loader)); @@ -185,11 +185,11 @@ public function testCreateFromLoaderDifferentLoader() $this->decoratedFactory->expects($this->at(0)) ->method('createListFromLoader') ->with($loader1) - ->will($this->returnValue($list1)); + ->willReturn($list1); $this->decoratedFactory->expects($this->at(1)) ->method('createListFromLoader') ->with($loader2) - ->will($this->returnValue($list2)); + ->willReturn($list2); $this->assertSame($list1, $this->factory->createListFromLoader($loader1)); $this->assertSame($list2, $this->factory->createListFromLoader($loader2)); @@ -204,7 +204,7 @@ public function testCreateFromLoaderSameValueClosure() $this->decoratedFactory->expects($this->once()) ->method('createListFromLoader') ->with($loader, $closure) - ->will($this->returnValue($list)); + ->willReturn($list); $this->assertSame($list, $this->factory->createListFromLoader($loader, $closure)); $this->assertSame($list, $this->factory->createListFromLoader($loader, $closure)); @@ -221,11 +221,11 @@ public function testCreateFromLoaderDifferentValueClosure() $this->decoratedFactory->expects($this->at(0)) ->method('createListFromLoader') ->with($loader, $closure1) - ->will($this->returnValue($list1)); + ->willReturn($list1); $this->decoratedFactory->expects($this->at(1)) ->method('createListFromLoader') ->with($loader, $closure2) - ->will($this->returnValue($list2)); + ->willReturn($list2); $this->assertSame($list1, $this->factory->createListFromLoader($loader, $closure1)); $this->assertSame($list2, $this->factory->createListFromLoader($loader, $closure2)); @@ -240,7 +240,7 @@ public function testCreateViewSamePreferredChoices() $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, $preferred) - ->will($this->returnValue($view)); + ->willReturn($view); $this->assertSame($view, $this->factory->createView($list, $preferred)); $this->assertSame($view, $this->factory->createView($list, $preferred)); @@ -257,11 +257,11 @@ public function testCreateViewDifferentPreferredChoices() $this->decoratedFactory->expects($this->at(0)) ->method('createView') ->with($list, $preferred1) - ->will($this->returnValue($view1)); + ->willReturn($view1); $this->decoratedFactory->expects($this->at(1)) ->method('createView') ->with($list, $preferred2) - ->will($this->returnValue($view2)); + ->willReturn($view2); $this->assertSame($view1, $this->factory->createView($list, $preferred1)); $this->assertSame($view2, $this->factory->createView($list, $preferred2)); @@ -276,7 +276,7 @@ public function testCreateViewSamePreferredChoicesClosure() $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, $preferred) - ->will($this->returnValue($view)); + ->willReturn($view); $this->assertSame($view, $this->factory->createView($list, $preferred)); $this->assertSame($view, $this->factory->createView($list, $preferred)); @@ -293,11 +293,11 @@ public function testCreateViewDifferentPreferredChoicesClosure() $this->decoratedFactory->expects($this->at(0)) ->method('createView') ->with($list, $preferred1) - ->will($this->returnValue($view1)); + ->willReturn($view1); $this->decoratedFactory->expects($this->at(1)) ->method('createView') ->with($list, $preferred2) - ->will($this->returnValue($view2)); + ->willReturn($view2); $this->assertSame($view1, $this->factory->createView($list, $preferred1)); $this->assertSame($view2, $this->factory->createView($list, $preferred2)); @@ -312,7 +312,7 @@ public function testCreateViewSameLabelClosure() $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, null, $labels) - ->will($this->returnValue($view)); + ->willReturn($view); $this->assertSame($view, $this->factory->createView($list, null, $labels)); $this->assertSame($view, $this->factory->createView($list, null, $labels)); @@ -329,11 +329,11 @@ public function testCreateViewDifferentLabelClosure() $this->decoratedFactory->expects($this->at(0)) ->method('createView') ->with($list, null, $labels1) - ->will($this->returnValue($view1)); + ->willReturn($view1); $this->decoratedFactory->expects($this->at(1)) ->method('createView') ->with($list, null, $labels2) - ->will($this->returnValue($view2)); + ->willReturn($view2); $this->assertSame($view1, $this->factory->createView($list, null, $labels1)); $this->assertSame($view2, $this->factory->createView($list, null, $labels2)); @@ -348,7 +348,7 @@ public function testCreateViewSameIndexClosure() $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, null, null, $index) - ->will($this->returnValue($view)); + ->willReturn($view); $this->assertSame($view, $this->factory->createView($list, null, null, $index)); $this->assertSame($view, $this->factory->createView($list, null, null, $index)); @@ -365,11 +365,11 @@ public function testCreateViewDifferentIndexClosure() $this->decoratedFactory->expects($this->at(0)) ->method('createView') ->with($list, null, null, $index1) - ->will($this->returnValue($view1)); + ->willReturn($view1); $this->decoratedFactory->expects($this->at(1)) ->method('createView') ->with($list, null, null, $index2) - ->will($this->returnValue($view2)); + ->willReturn($view2); $this->assertSame($view1, $this->factory->createView($list, null, null, $index1)); $this->assertSame($view2, $this->factory->createView($list, null, null, $index2)); @@ -384,7 +384,7 @@ public function testCreateViewSameGroupByClosure() $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, null, null, null, $groupBy) - ->will($this->returnValue($view)); + ->willReturn($view); $this->assertSame($view, $this->factory->createView($list, null, null, null, $groupBy)); $this->assertSame($view, $this->factory->createView($list, null, null, null, $groupBy)); @@ -401,11 +401,11 @@ public function testCreateViewDifferentGroupByClosure() $this->decoratedFactory->expects($this->at(0)) ->method('createView') ->with($list, null, null, null, $groupBy1) - ->will($this->returnValue($view1)); + ->willReturn($view1); $this->decoratedFactory->expects($this->at(1)) ->method('createView') ->with($list, null, null, null, $groupBy2) - ->will($this->returnValue($view2)); + ->willReturn($view2); $this->assertSame($view1, $this->factory->createView($list, null, null, null, $groupBy1)); $this->assertSame($view2, $this->factory->createView($list, null, null, null, $groupBy2)); @@ -420,7 +420,7 @@ public function testCreateViewSameAttributes() $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, null, null, null, null, $attr) - ->will($this->returnValue($view)); + ->willReturn($view); $this->assertSame($view, $this->factory->createView($list, null, null, null, null, $attr)); $this->assertSame($view, $this->factory->createView($list, null, null, null, null, $attr)); @@ -437,11 +437,11 @@ public function testCreateViewDifferentAttributes() $this->decoratedFactory->expects($this->at(0)) ->method('createView') ->with($list, null, null, null, null, $attr1) - ->will($this->returnValue($view1)); + ->willReturn($view1); $this->decoratedFactory->expects($this->at(1)) ->method('createView') ->with($list, null, null, null, null, $attr2) - ->will($this->returnValue($view2)); + ->willReturn($view2); $this->assertSame($view1, $this->factory->createView($list, null, null, null, null, $attr1)); $this->assertSame($view2, $this->factory->createView($list, null, null, null, null, $attr2)); @@ -456,7 +456,7 @@ public function testCreateViewSameAttributesClosure() $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, null, null, null, null, $attr) - ->will($this->returnValue($view)); + ->willReturn($view); $this->assertSame($view, $this->factory->createView($list, null, null, null, null, $attr)); $this->assertSame($view, $this->factory->createView($list, null, null, null, null, $attr)); @@ -473,11 +473,11 @@ public function testCreateViewDifferentAttributesClosure() $this->decoratedFactory->expects($this->at(0)) ->method('createView') ->with($list, null, null, null, null, $attr1) - ->will($this->returnValue($view1)); + ->willReturn($view1); $this->decoratedFactory->expects($this->at(1)) ->method('createView') ->with($list, null, null, null, null, $attr2) - ->will($this->returnValue($view2)); + ->willReturn($view2); $this->assertSame($view1, $this->factory->createView($list, null, null, null, null, $attr1)); $this->assertSame($view2, $this->factory->createView($list, null, null, null, null, $attr2)); diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php index 1b943e81c1ec9..42893696db622 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php @@ -43,9 +43,9 @@ public function testCreateFromChoicesPropertyPath() $this->decoratedFactory->expects($this->once()) ->method('createListFromChoices') ->with($choices, $this->isInstanceOf('\Closure')) - ->will($this->returnCallback(function ($choices, $callback) { + ->willReturnCallback(function ($choices, $callback) { return array_map($callback, $choices); - })); + }); $this->assertSame(['value'], $this->factory->createListFromChoices($choices, 'property')); } @@ -57,9 +57,9 @@ public function testCreateFromChoicesPropertyPathInstance() $this->decoratedFactory->expects($this->once()) ->method('createListFromChoices') ->with($choices, $this->isInstanceOf('\Closure')) - ->will($this->returnCallback(function ($choices, $callback) { + ->willReturnCallback(function ($choices, $callback) { return array_map($callback, $choices); - })); + }); $this->assertSame(['value'], $this->factory->createListFromChoices($choices, new PropertyPath('property'))); } @@ -86,9 +86,9 @@ public function testCreateFromLoaderPropertyPath() $this->decoratedFactory->expects($this->once()) ->method('createListFromLoader') ->with($loader, $this->isInstanceOf('\Closure')) - ->will($this->returnCallback(function ($loader, $callback) { + ->willReturnCallback(function ($loader, $callback) { return $callback((object) ['property' => 'value']); - })); + }); $this->assertSame('value', $this->factory->createListFromLoader($loader, 'property')); } @@ -116,9 +116,9 @@ public function testCreateFromChoicesAssumeNullIfValuePropertyPathUnreadable() $this->decoratedFactory->expects($this->once()) ->method('createListFromChoices') ->with($choices, $this->isInstanceOf('\Closure')) - ->will($this->returnCallback(function ($choices, $callback) { + ->willReturnCallback(function ($choices, $callback) { return array_map($callback, $choices); - })); + }); $this->assertSame([null], $this->factory->createListFromChoices($choices, 'property')); } @@ -131,9 +131,9 @@ public function testCreateFromChoiceLoaderAssumeNullIfValuePropertyPathUnreadabl $this->decoratedFactory->expects($this->once()) ->method('createListFromLoader') ->with($loader, $this->isInstanceOf('\Closure')) - ->will($this->returnCallback(function ($loader, $callback) { + ->willReturnCallback(function ($loader, $callback) { return $callback(null); - })); + }); $this->assertNull($this->factory->createListFromLoader($loader, 'property')); } @@ -145,9 +145,9 @@ public function testCreateFromLoaderPropertyPathInstance() $this->decoratedFactory->expects($this->once()) ->method('createListFromLoader') ->with($loader, $this->isInstanceOf('\Closure')) - ->will($this->returnCallback(function ($loader, $callback) { + ->willReturnCallback(function ($loader, $callback) { return $callback((object) ['property' => 'value']); - })); + }); $this->assertSame('value', $this->factory->createListFromLoader($loader, new PropertyPath('property'))); } @@ -159,9 +159,9 @@ public function testCreateViewPreferredChoicesAsPropertyPath() $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, $this->isInstanceOf('\Closure')) - ->will($this->returnCallback(function ($list, $preferred) { + ->willReturnCallback(function ($list, $preferred) { return $preferred((object) ['property' => true]); - })); + }); $this->assertTrue($this->factory->createView( $list, @@ -194,9 +194,9 @@ public function testCreateViewPreferredChoicesAsPropertyPathInstance() $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, $this->isInstanceOf('\Closure')) - ->will($this->returnCallback(function ($list, $preferred) { + ->willReturnCallback(function ($list, $preferred) { return $preferred((object) ['property' => true]); - })); + }); $this->assertTrue($this->factory->createView( $list, @@ -212,9 +212,9 @@ public function testCreateViewAssumeNullIfPreferredChoicesPropertyPathUnreadable $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, $this->isInstanceOf('\Closure')) - ->will($this->returnCallback(function ($list, $preferred) { + ->willReturnCallback(function ($list, $preferred) { return $preferred((object) ['category' => null]); - })); + }); $this->assertFalse($this->factory->createView( $list, @@ -229,9 +229,9 @@ public function testCreateViewLabelsAsPropertyPath() $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, null, $this->isInstanceOf('\Closure')) - ->will($this->returnCallback(function ($list, $preferred, $label) { + ->willReturnCallback(function ($list, $preferred, $label) { return $label((object) ['property' => 'label']); - })); + }); $this->assertSame('label', $this->factory->createView( $list, @@ -266,9 +266,9 @@ public function testCreateViewLabelsAsPropertyPathInstance() $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, null, $this->isInstanceOf('\Closure')) - ->will($this->returnCallback(function ($list, $preferred, $label) { + ->willReturnCallback(function ($list, $preferred, $label) { return $label((object) ['property' => 'label']); - })); + }); $this->assertSame('label', $this->factory->createView( $list, @@ -284,9 +284,9 @@ public function testCreateViewIndicesAsPropertyPath() $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, null, null, $this->isInstanceOf('\Closure')) - ->will($this->returnCallback(function ($list, $preferred, $label, $index) { + ->willReturnCallback(function ($list, $preferred, $label, $index) { return $index((object) ['property' => 'index']); - })); + }); $this->assertSame('index', $this->factory->createView( $list, @@ -323,9 +323,9 @@ public function testCreateViewIndicesAsPropertyPathInstance() $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, null, null, $this->isInstanceOf('\Closure')) - ->will($this->returnCallback(function ($list, $preferred, $label, $index) { + ->willReturnCallback(function ($list, $preferred, $label, $index) { return $index((object) ['property' => 'index']); - })); + }); $this->assertSame('index', $this->factory->createView( $list, @@ -342,9 +342,9 @@ public function testCreateViewGroupsAsPropertyPath() $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, null, null, null, $this->isInstanceOf('\Closure')) - ->will($this->returnCallback(function ($list, $preferred, $label, $index, $groupBy) { + ->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy) { return $groupBy((object) ['property' => 'group']); - })); + }); $this->assertSame('group', $this->factory->createView( $list, @@ -383,9 +383,9 @@ public function testCreateViewGroupsAsPropertyPathInstance() $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, null, null, null, $this->isInstanceOf('\Closure')) - ->will($this->returnCallback(function ($list, $preferred, $label, $index, $groupBy) { + ->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy) { return $groupBy((object) ['property' => 'group']); - })); + }); $this->assertSame('group', $this->factory->createView( $list, @@ -404,9 +404,9 @@ public function testCreateViewAssumeNullIfGroupsPropertyPathUnreadable() $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, null, null, null, $this->isInstanceOf('\Closure')) - ->will($this->returnCallback(function ($list, $preferred, $label, $index, $groupBy) { + ->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy) { return $groupBy((object) ['group' => null]); - })); + }); $this->assertNull($this->factory->createView( $list, @@ -424,9 +424,9 @@ public function testCreateViewAttrAsPropertyPath() $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, null, null, null, null, $this->isInstanceOf('\Closure')) - ->will($this->returnCallback(function ($list, $preferred, $label, $index, $groupBy, $attr) { + ->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy, $attr) { return $attr((object) ['property' => 'attr']); - })); + }); $this->assertSame('attr', $this->factory->createView( $list, @@ -467,9 +467,9 @@ public function testCreateViewAttrAsPropertyPathInstance() $this->decoratedFactory->expects($this->once()) ->method('createView') ->with($list, null, null, null, null, $this->isInstanceOf('\Closure')) - ->will($this->returnCallback(function ($list, $preferred, $label, $index, $groupBy, $attr) { + ->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy, $attr) { return $attr((object) ['property' => 'attr']); - })); + }); $this->assertSame('attr', $this->factory->createView( $list, diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php index 60795c4aae1d5..6854c43ef733f 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php @@ -50,12 +50,12 @@ public function testGetChoiceLoadersLoadsLoadedListOnFirstCall() $this->loader->expects($this->exactly(2)) ->method('loadChoiceList') ->with($this->value) - ->will($this->returnValue($this->loadedList)); + ->willReturn($this->loadedList); // The same list is returned by the loader $this->loadedList->expects($this->exactly(2)) ->method('getChoices') - ->will($this->returnValue('RESULT')); + ->willReturn('RESULT'); $this->assertSame('RESULT', $this->list->getChoices()); $this->assertSame('RESULT', $this->list->getChoices()); @@ -79,7 +79,7 @@ public function testGetChoicesUsesLoadedListWhenLoaderDoesNotCacheChoiceListOnFi // The same list is returned by the lazy choice list $this->loadedList->expects($this->exactly(2)) ->method('getChoices') - ->will($this->returnValue('RESULT')); + ->willReturn('RESULT'); $this->assertSame('RESULT', $this->list->getChoices()); $this->assertSame('RESULT', $this->list->getChoices()); @@ -90,12 +90,12 @@ public function testGetValuesLoadsLoadedListOnFirstCall() $this->loader->expects($this->exactly(2)) ->method('loadChoiceList') ->with($this->value) - ->will($this->returnValue($this->loadedList)); + ->willReturn($this->loadedList); // The same list is returned by the loader $this->loadedList->expects($this->exactly(2)) ->method('getValues') - ->will($this->returnValue('RESULT')); + ->willReturn('RESULT'); $this->assertSame('RESULT', $this->list->getValues()); $this->assertSame('RESULT', $this->list->getValues()); @@ -106,12 +106,12 @@ public function testGetStructuredValuesLoadsLoadedListOnFirstCall() $this->loader->expects($this->exactly(2)) ->method('loadChoiceList') ->with($this->value) - ->will($this->returnValue($this->loadedList)); + ->willReturn($this->loadedList); // The same list is returned by the loader $this->loadedList->expects($this->exactly(2)) ->method('getStructuredValues') - ->will($this->returnValue('RESULT')); + ->willReturn('RESULT'); $this->assertSame('RESULT', $this->list->getStructuredValues()); $this->assertSame('RESULT', $this->list->getStructuredValues()); @@ -122,12 +122,12 @@ public function testGetOriginalKeysLoadsLoadedListOnFirstCall() $this->loader->expects($this->exactly(2)) ->method('loadChoiceList') ->with($this->value) - ->will($this->returnValue($this->loadedList)); + ->willReturn($this->loadedList); // The same list is returned by the loader $this->loadedList->expects($this->exactly(2)) ->method('getOriginalKeys') - ->will($this->returnValue('RESULT')); + ->willReturn('RESULT'); $this->assertSame('RESULT', $this->list->getOriginalKeys()); $this->assertSame('RESULT', $this->list->getOriginalKeys()); @@ -138,7 +138,7 @@ public function testGetChoicesForValuesForwardsCallIfListNotLoaded() $this->loader->expects($this->exactly(2)) ->method('loadChoicesForValues') ->with(['a', 'b']) - ->will($this->returnValue('RESULT')); + ->willReturn('RESULT'); $this->assertSame('RESULT', $this->list->getChoicesForValues(['a', 'b'])); $this->assertSame('RESULT', $this->list->getChoicesForValues(['a', 'b'])); @@ -151,7 +151,7 @@ public function testGetChoicesForValuesUsesLoadedList() ->with($this->value) // For BC, the same choice loaded list is returned 3 times // It should only twice in 4.0 - ->will($this->returnValue($this->loadedList)); + ->willReturn($this->loadedList); $this->loader->expects($this->never()) ->method('loadChoicesForValues'); @@ -159,7 +159,7 @@ public function testGetChoicesForValuesUsesLoadedList() $this->loadedList->expects($this->exactly(2)) ->method('getChoicesForValues') ->with(['a', 'b']) - ->will($this->returnValue('RESULT')); + ->willReturn('RESULT'); // load choice list $this->list->getChoices(); @@ -176,7 +176,7 @@ public function testGetValuesForChoicesForwardsCallIfListNotLoaded() $this->loader->expects($this->exactly(2)) ->method('loadValuesForChoices') ->with(['a', 'b']) - ->will($this->returnValue('RESULT')); + ->willReturn('RESULT'); $this->assertSame('RESULT', $this->list->getValuesForChoices(['a', 'b'])); $this->assertSame('RESULT', $this->list->getValuesForChoices(['a', 'b'])); @@ -189,7 +189,7 @@ public function testGetValuesForChoicesUsesLoadedList() ->with($this->value) // For BC, the same choice loaded list is returned 3 times // It should only twice in 4.0 - ->will($this->returnValue($this->loadedList)); + ->willReturn($this->loadedList); $this->loader->expects($this->never()) ->method('loadValuesForChoices'); @@ -197,7 +197,7 @@ public function testGetValuesForChoicesUsesLoadedList() $this->loadedList->expects($this->exactly(2)) ->method('getValuesForChoices') ->with(['a', 'b']) - ->will($this->returnValue('RESULT')); + ->willReturn('RESULT'); // load choice list $this->list->getChoices(); diff --git a/src/Symfony/Component/Form/Tests/CompoundFormTest.php b/src/Symfony/Component/Form/Tests/CompoundFormTest.php index edc3aeda14b2c..7657056b7ada1 100644 --- a/src/Symfony/Component/Form/Tests/CompoundFormTest.php +++ b/src/Symfony/Component/Form/Tests/CompoundFormTest.php @@ -179,7 +179,7 @@ public function testAddUsingNameAndType() 'bar' => 'baz', 'auto_initialize' => false, ]) - ->will($this->returnValue($child)); + ->willReturn($child); $this->form->add('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType', ['bar' => 'baz']); @@ -198,7 +198,7 @@ public function testAddUsingIntegerNameAndType() 'bar' => 'baz', 'auto_initialize' => false, ]) - ->will($this->returnValue($child)); + ->willReturn($child); // in order to make casting unnecessary $this->form->add(0, 'Symfony\Component\Form\Extension\Core\Type\TextType', ['bar' => 'baz']); @@ -215,7 +215,7 @@ public function testAddWithoutType() $this->factory->expects($this->once()) ->method('createNamed') ->with('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType') - ->will($this->returnValue($child)); + ->willReturn($child); $this->form->add('foo'); @@ -236,7 +236,7 @@ public function testAddUsingNameButNoType() $this->factory->expects($this->once()) ->method('createForProperty') ->with('\stdClass', 'foo') - ->will($this->returnValue($child)); + ->willReturn($child); $this->form->add('foo'); @@ -260,7 +260,7 @@ public function testAddUsingNameButNoTypeAndOptions() 'bar' => 'baz', 'auto_initialize' => false, ]) - ->will($this->returnValue($child)); + ->willReturn($child); $this->form->add('foo', null, ['bar' => 'baz']); @@ -352,10 +352,10 @@ public function testAddMapsViewDataToFormIfInitialized() $mapper->expects($this->once()) ->method('mapDataToForms') ->with('bar', $this->isInstanceOf('\RecursiveIteratorIterator')) - ->will($this->returnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child) { + ->willReturnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child) { $this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator()); $this->assertSame([$child->getName() => $child], iterator_to_array($iterator)); - })); + }); $form->initialize(); $form->add($child); @@ -442,10 +442,10 @@ public function testSetDataMapsViewDataToChildren() $mapper->expects($this->once()) ->method('mapDataToForms') ->with('bar', $this->isInstanceOf('\RecursiveIteratorIterator')) - ->will($this->returnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child1, $child2) { + ->willReturnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child1, $child2) { $this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator()); $this->assertSame(['firstName' => $child1, 'lastName' => $child2], iterator_to_array($iterator)); - })); + }); $form->setData('foo'); } @@ -517,12 +517,12 @@ public function testSubmitMapsSubmittedChildrenOntoExistingViewData() $mapper->expects($this->once()) ->method('mapFormsToData') ->with($this->isInstanceOf('\RecursiveIteratorIterator'), 'bar') - ->will($this->returnCallback(function (\RecursiveIteratorIterator $iterator) use ($child1, $child2) { + ->willReturnCallback(function (\RecursiveIteratorIterator $iterator) use ($child1, $child2) { $this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator()); $this->assertSame(['firstName' => $child1, 'lastName' => $child2], iterator_to_array($iterator)); $this->assertEquals('Bernhard', $child1->getData()); $this->assertEquals('Schussek', $child2->getData()); - })); + }); $form->submit([ 'firstName' => 'Bernhard', @@ -589,10 +589,10 @@ public function testSubmitMapsSubmittedChildrenOntoEmptyData() $mapper->expects($this->once()) ->method('mapFormsToData') ->with($this->isInstanceOf('\RecursiveIteratorIterator'), $object) - ->will($this->returnCallback(function (\RecursiveIteratorIterator $iterator) use ($child) { + ->willReturnCallback(function (\RecursiveIteratorIterator $iterator) use ($child) { $this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator()); $this->assertSame(['name' => $child], iterator_to_array($iterator)); - })); + }); $form->submit([ 'name' => 'Bernhard', @@ -912,11 +912,11 @@ public function testCreateViewWithChildren() $field1View = new FormView(); $type1 ->method('createView') - ->will($this->returnValue($field1View)); + ->willReturn($field1View); $field2View = new FormView(); $type2 ->method('createView') - ->will($this->returnValue($field2View)); + ->willReturn($field2View); $this->form = $this->getBuilder('form', null, null, $options) ->setCompound(true) @@ -935,13 +935,13 @@ public function testCreateViewWithChildren() // First create the view $type->expects($this->once()) ->method('createView') - ->will($this->returnValue($view)); + ->willReturn($view); // Then build it for the form itself $type->expects($this->once()) ->method('buildView') ->with($view, $this->form, $options) - ->will($this->returnCallback($assertChildViewsEqual([]))); + ->willReturnCallback($assertChildViewsEqual([])); $this->assertSame($view, $this->form->createView()); $this->assertSame(['foo' => $field1View, 'bar' => $field2View], $view->children); @@ -961,7 +961,7 @@ public function testNoClickedButton() $button->expects($this->any()) ->method('isClicked') - ->will($this->returnValue(false)); + ->willReturn(false); $parentForm = $this->getBuilder('parent')->getForm(); $nestedForm = $this->getBuilder('nested')->getForm(); @@ -983,7 +983,7 @@ public function testClickedButton() $button->expects($this->any()) ->method('isClicked') - ->will($this->returnValue(true)); + ->willReturn(true); $this->form->add($button); $this->form->submit([]); @@ -1002,7 +1002,7 @@ public function testClickedButtonFromNestedForm() $nestedForm->expects($this->any()) ->method('getClickedButton') - ->will($this->returnValue($button)); + ->willReturn($button); $this->form->add($nestedForm); $this->form->submit([]); @@ -1021,7 +1021,7 @@ public function testClickedButtonFromParentForm() $parentForm->expects($this->any()) ->method('getClickedButton') - ->will($this->returnValue($button)); + ->willReturn($button); $this->form->setParent($parentForm); $this->form->submit([]); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php index f62d3c52110f1..2c685a4197a95 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php @@ -22,12 +22,12 @@ public function testTransform() $transformer1->expects($this->once()) ->method('transform') ->with($this->identicalTo('foo')) - ->will($this->returnValue('bar')); + ->willReturn('bar'); $transformer2 = $this->getMockBuilder('Symfony\Component\Form\DataTransformerInterface')->getMock(); $transformer2->expects($this->once()) ->method('transform') ->with($this->identicalTo('bar')) - ->will($this->returnValue('baz')); + ->willReturn('baz'); $chain = new DataTransformerChain([$transformer1, $transformer2]); @@ -40,12 +40,12 @@ public function testReverseTransform() $transformer2->expects($this->once()) ->method('reverseTransform') ->with($this->identicalTo('foo')) - ->will($this->returnValue('bar')); + ->willReturn('bar'); $transformer1 = $this->getMockBuilder('Symfony\Component\Form\DataTransformerInterface')->getMock(); $transformer1->expects($this->once()) ->method('reverseTransform') ->with($this->identicalTo('bar')) - ->will($this->returnValue('baz')); + ->willReturn('baz'); $chain = new DataTransformerChain([$transformer1, $transformer2]); diff --git a/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php index 083f1c956792d..665b700479735 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php @@ -122,7 +122,7 @@ public function testGenerateCsrfToken() $this->tokenManager->expects($this->once()) ->method('getToken') ->with('TOKEN_ID') - ->will($this->returnValue(new CsrfToken('TOKEN_ID', 'token'))); + ->willReturn(new CsrfToken('TOKEN_ID', 'token')); $view = $this->factory ->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [ @@ -141,7 +141,7 @@ public function testGenerateCsrfTokenUsesFormNameAsIntentionByDefault() $this->tokenManager->expects($this->once()) ->method('getToken') ->with('FORM_NAME') - ->will($this->returnValue('token')); + ->willReturn('token'); $view = $this->factory ->createNamed('FORM_NAME', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, [ @@ -159,7 +159,7 @@ public function testGenerateCsrfTokenUsesTypeClassAsIntentionIfEmptyFormName() $this->tokenManager->expects($this->once()) ->method('getToken') ->with('Symfony\Component\Form\Extension\Core\Type\FormType') - ->will($this->returnValue('token')); + ->willReturn('token'); $view = $this->factory ->createNamed('', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, [ @@ -188,7 +188,7 @@ public function testValidateTokenOnSubmitIfRootAndCompound($valid) $this->tokenManager->expects($this->once()) ->method('isTokenValid') ->with(new CsrfToken('TOKEN_ID', 'token')) - ->will($this->returnValue($valid)); + ->willReturn($valid); $form = $this->factory ->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, [ @@ -220,7 +220,7 @@ public function testValidateTokenOnSubmitIfRootAndCompoundUsesFormNameAsIntentio $this->tokenManager->expects($this->once()) ->method('isTokenValid') ->with(new CsrfToken('FORM_NAME', 'token')) - ->will($this->returnValue($valid)); + ->willReturn($valid); $form = $this->factory ->createNamedBuilder('FORM_NAME', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, [ @@ -251,7 +251,7 @@ public function testValidateTokenOnSubmitIfRootAndCompoundUsesTypeClassAsIntenti $this->tokenManager->expects($this->once()) ->method('isTokenValid') ->with(new CsrfToken('Symfony\Component\Form\Extension\Core\Type\FormType', 'token')) - ->will($this->returnValue($valid)); + ->willReturn($valid); $form = $this->factory ->createNamedBuilder('', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, [ @@ -366,12 +366,12 @@ public function testsTranslateCustomErrorMessage() $this->tokenManager->expects($this->once()) ->method('isTokenValid') ->with(new CsrfToken('TOKEN_ID', 'token')) - ->will($this->returnValue(false)); + ->willReturn(false); $this->translator->expects($this->once()) ->method('trans') ->with('Foobar') - ->will($this->returnValue('[trans]Foobar[/trans]')); + ->willReturn('[trans]Foobar[/trans]'); $form = $this->factory ->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, [ diff --git a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php index 2ca0f95f3c6e3..83d44167d5cf4 100644 --- a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php @@ -84,29 +84,29 @@ public function testBuildPreliminaryFormTree() $this->dataExtractor->expects($this->at(0)) ->method('extractConfiguration') ->with($this->form) - ->will($this->returnValue(['config' => 'foo'])); + ->willReturn(['config' => 'foo']); $this->dataExtractor->expects($this->at(1)) ->method('extractConfiguration') ->with($this->childForm) - ->will($this->returnValue(['config' => 'bar'])); + ->willReturn(['config' => 'bar']); $this->dataExtractor->expects($this->at(2)) ->method('extractDefaultData') ->with($this->form) - ->will($this->returnValue(['default_data' => 'foo'])); + ->willReturn(['default_data' => 'foo']); $this->dataExtractor->expects($this->at(3)) ->method('extractDefaultData') ->with($this->childForm) - ->will($this->returnValue(['default_data' => 'bar'])); + ->willReturn(['default_data' => 'bar']); $this->dataExtractor->expects($this->at(4)) ->method('extractSubmittedData') ->with($this->form) - ->will($this->returnValue(['submitted_data' => 'foo'])); + ->willReturn(['submitted_data' => 'foo']); $this->dataExtractor->expects($this->at(5)) ->method('extractSubmittedData') ->with($this->childForm) - ->will($this->returnValue(['submitted_data' => 'bar'])); + ->willReturn(['submitted_data' => 'bar']); $this->dataCollector->collectConfiguration($this->form); $this->dataCollector->collectDefaultData($this->form); @@ -150,11 +150,11 @@ public function testBuildMultiplePreliminaryFormTrees() $this->dataExtractor->expects($this->at(0)) ->method('extractConfiguration') ->with($form1) - ->will($this->returnValue(['config' => 'foo'])); + ->willReturn(['config' => 'foo']); $this->dataExtractor->expects($this->at(1)) ->method('extractConfiguration') ->with($form2) - ->will($this->returnValue(['config' => 'bar'])); + ->willReturn(['config' => 'bar']); $this->dataCollector->collectConfiguration($form1); $this->dataCollector->collectConfiguration($form2); @@ -200,12 +200,12 @@ public function testBuildSamePreliminaryFormTreeMultipleTimes() $this->dataExtractor->expects($this->at(0)) ->method('extractConfiguration') ->with($this->form) - ->will($this->returnValue(['config' => 'foo'])); + ->willReturn(['config' => 'foo']); $this->dataExtractor->expects($this->at(1)) ->method('extractDefaultData') ->with($this->form) - ->will($this->returnValue(['default_data' => 'foo'])); + ->willReturn(['default_data' => 'foo']); $this->dataCollector->collectConfiguration($this->form); $this->dataCollector->buildPreliminaryFormTree($this->form); @@ -272,39 +272,39 @@ public function testBuildFinalFormTree() $this->dataExtractor->expects($this->at(0)) ->method('extractConfiguration') ->with($this->form) - ->will($this->returnValue(['config' => 'foo'])); + ->willReturn(['config' => 'foo']); $this->dataExtractor->expects($this->at(1)) ->method('extractConfiguration') ->with($this->childForm) - ->will($this->returnValue(['config' => 'bar'])); + ->willReturn(['config' => 'bar']); $this->dataExtractor->expects($this->at(2)) ->method('extractDefaultData') ->with($this->form) - ->will($this->returnValue(['default_data' => 'foo'])); + ->willReturn(['default_data' => 'foo']); $this->dataExtractor->expects($this->at(3)) ->method('extractDefaultData') ->with($this->childForm) - ->will($this->returnValue(['default_data' => 'bar'])); + ->willReturn(['default_data' => 'bar']); $this->dataExtractor->expects($this->at(4)) ->method('extractSubmittedData') ->with($this->form) - ->will($this->returnValue(['submitted_data' => 'foo'])); + ->willReturn(['submitted_data' => 'foo']); $this->dataExtractor->expects($this->at(5)) ->method('extractSubmittedData') ->with($this->childForm) - ->will($this->returnValue(['submitted_data' => 'bar'])); + ->willReturn(['submitted_data' => 'bar']); $this->dataExtractor->expects($this->at(6)) ->method('extractViewVariables') ->with($this->view) - ->will($this->returnValue(['view_vars' => 'foo'])); + ->willReturn(['view_vars' => 'foo']); $this->dataExtractor->expects($this->at(7)) ->method('extractViewVariables') ->with($this->childView) - ->will($this->returnValue(['view_vars' => 'bar'])); + ->willReturn(['view_vars' => 'bar']); $this->dataCollector->collectConfiguration($this->form); $this->dataCollector->collectDefaultData($this->form); @@ -365,76 +365,76 @@ public function testSerializeWithFormAddedMultipleTimes() $this->dataExtractor->expects($this->at(0)) ->method('extractConfiguration') ->with($form1) - ->will($this->returnValue(['config' => 'foo'])); + ->willReturn(['config' => 'foo']); $this->dataExtractor->expects($this->at(1)) ->method('extractConfiguration') ->with($child1) - ->will($this->returnValue(['config' => 'bar'])); + ->willReturn(['config' => 'bar']); $this->dataExtractor->expects($this->at(2)) ->method('extractDefaultData') ->with($form1) - ->will($this->returnValue(['default_data' => 'foo'])); + ->willReturn(['default_data' => 'foo']); $this->dataExtractor->expects($this->at(3)) ->method('extractDefaultData') ->with($child1) - ->will($this->returnValue(['default_data' => 'bar'])); + ->willReturn(['default_data' => 'bar']); $this->dataExtractor->expects($this->at(4)) ->method('extractSubmittedData') ->with($form1) - ->will($this->returnValue(['submitted_data' => 'foo'])); + ->willReturn(['submitted_data' => 'foo']); $this->dataExtractor->expects($this->at(5)) ->method('extractSubmittedData') ->with($child1) - ->will($this->returnValue(['submitted_data' => 'bar'])); + ->willReturn(['submitted_data' => 'bar']); $this->dataExtractor->expects($this->at(6)) ->method('extractViewVariables') ->with($form1View) - ->will($this->returnValue(['view_vars' => 'foo'])); + ->willReturn(['view_vars' => 'foo']); $this->dataExtractor->expects($this->at(7)) ->method('extractViewVariables') ->with($child1View) - ->will($this->returnValue(['view_vars' => $child1View->vars])); + ->willReturn(['view_vars' => $child1View->vars]); $this->dataExtractor->expects($this->at(8)) ->method('extractConfiguration') ->with($form2) - ->will($this->returnValue(['config' => 'foo'])); + ->willReturn(['config' => 'foo']); $this->dataExtractor->expects($this->at(9)) ->method('extractConfiguration') ->with($child1) - ->will($this->returnValue(['config' => 'bar'])); + ->willReturn(['config' => 'bar']); $this->dataExtractor->expects($this->at(10)) ->method('extractDefaultData') ->with($form2) - ->will($this->returnValue(['default_data' => 'foo'])); + ->willReturn(['default_data' => 'foo']); $this->dataExtractor->expects($this->at(11)) ->method('extractDefaultData') ->with($child1) - ->will($this->returnValue(['default_data' => 'bar'])); + ->willReturn(['default_data' => 'bar']); $this->dataExtractor->expects($this->at(12)) ->method('extractSubmittedData') ->with($form2) - ->will($this->returnValue(['submitted_data' => 'foo'])); + ->willReturn(['submitted_data' => 'foo']); $this->dataExtractor->expects($this->at(13)) ->method('extractSubmittedData') ->with($child1) - ->will($this->returnValue(['submitted_data' => 'bar'])); + ->willReturn(['submitted_data' => 'bar']); $this->dataExtractor->expects($this->at(14)) ->method('extractViewVariables') ->with($form2View) - ->will($this->returnValue(['view_vars' => 'foo'])); + ->willReturn(['view_vars' => 'foo']); $this->dataExtractor->expects($this->at(15)) ->method('extractViewVariables') ->with($child1View) - ->will($this->returnValue(['view_vars' => $child1View->vars])); + ->willReturn(['view_vars' => $child1View->vars]); $this->dataCollector->collectConfiguration($form1); $this->dataCollector->collectDefaultData($form1); @@ -518,11 +518,11 @@ public function testChildViewsCanBeWithoutCorrespondingChildForms() $this->dataExtractor->expects($this->at(0)) ->method('extractConfiguration') ->with($this->form) - ->will($this->returnValue(['config' => 'foo'])); + ->willReturn(['config' => 'foo']); $this->dataExtractor->expects($this->at(1)) ->method('extractConfiguration') ->with($this->childForm) - ->will($this->returnValue(['config' => 'bar'])); + ->willReturn(['config' => 'bar']); // explicitly call collectConfiguration(), since $this->childForm is not // contained in the form tree @@ -566,11 +566,11 @@ public function testChildViewsWithoutCorrespondingChildFormsMayBeExplicitlyAssoc $this->dataExtractor->expects($this->at(0)) ->method('extractConfiguration') ->with($this->form) - ->will($this->returnValue(['config' => 'foo'])); + ->willReturn(['config' => 'foo']); $this->dataExtractor->expects($this->at(1)) ->method('extractConfiguration') ->with($this->childForm) - ->will($this->returnValue(['config' => 'bar'])); + ->willReturn(['config' => 'bar']); // explicitly call collectConfiguration(), since $this->childForm is not // contained in the form tree @@ -611,22 +611,22 @@ public function testCollectSubmittedDataCountsErrors() $form1->add($childForm1); $this->dataExtractor ->method('extractConfiguration') - ->will($this->returnValue([])); + ->willReturn([]); $this->dataExtractor ->method('extractDefaultData') - ->will($this->returnValue([])); + ->willReturn([]); $this->dataExtractor->expects($this->at(4)) ->method('extractSubmittedData') ->with($form1) - ->will($this->returnValue(['errors' => ['foo']])); + ->willReturn(['errors' => ['foo']]); $this->dataExtractor->expects($this->at(5)) ->method('extractSubmittedData') ->with($childForm1) - ->will($this->returnValue(['errors' => ['bar', 'bam']])); + ->willReturn(['errors' => ['bar', 'bam']]); $this->dataExtractor->expects($this->at(8)) ->method('extractSubmittedData') ->with($form2) - ->will($this->returnValue(['errors' => ['baz']])); + ->willReturn(['errors' => ['baz']]); $this->dataCollector->collectSubmittedData($form1); @@ -653,30 +653,30 @@ public function testCollectSubmittedDataExpandedFormsErrors() $this->dataExtractor ->method('extractConfiguration') - ->will($this->returnValue([])); + ->willReturn([]); $this->dataExtractor ->method('extractDefaultData') - ->will($this->returnValue([])); + ->willReturn([]); $this->dataExtractor->expects($this->at(10)) ->method('extractSubmittedData') ->with($this->form) - ->will($this->returnValue(['errors' => []])); + ->willReturn(['errors' => []]); $this->dataExtractor->expects($this->at(11)) ->method('extractSubmittedData') ->with($child1Form) - ->will($this->returnValue(['errors' => []])); + ->willReturn(['errors' => []]); $this->dataExtractor->expects($this->at(12)) ->method('extractSubmittedData') ->with($child11Form) - ->will($this->returnValue(['errors' => ['foo']])); + ->willReturn(['errors' => ['foo']]); $this->dataExtractor->expects($this->at(13)) ->method('extractSubmittedData') ->with($child2Form) - ->will($this->returnValue(['errors' => []])); + ->willReturn(['errors' => []]); $this->dataExtractor->expects($this->at(14)) ->method('extractSubmittedData') ->with($child21Form) - ->will($this->returnValue(['errors' => []])); + ->willReturn(['errors' => []]); $this->dataCollector->collectSubmittedData($this->form); $this->dataCollector->buildPreliminaryFormTree($this->form); @@ -701,14 +701,14 @@ public function testReset() $this->dataExtractor->expects($this->any()) ->method('extractConfiguration') - ->will($this->returnValue([])); + ->willReturn([]); $this->dataExtractor->expects($this->any()) ->method('extractDefaultData') - ->will($this->returnValue([])); + ->willReturn([]); $this->dataExtractor->expects($this->any()) ->method('extractSubmittedData') ->with($form) - ->will($this->returnValue(['errors' => ['baz']])); + ->willReturn(['errors' => ['baz']]); $this->dataCollector->buildPreliminaryFormTree($form); $this->dataCollector->collectSubmittedData($form); diff --git a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php index 9bbfb0f4f11ee..860a96abcddfa 100644 --- a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php @@ -56,7 +56,7 @@ public function testExtractConfiguration() $type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); $type->expects($this->any()) ->method('getInnerType') - ->will($this->returnValue(new \stdClass())); + ->willReturn(new \stdClass()); $form = $this->createBuilder('name') ->setType($type) @@ -77,7 +77,7 @@ public function testExtractConfigurationSortsPassedOptions() $type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); $type->expects($this->any()) ->method('getInnerType') - ->will($this->returnValue(new \stdClass())); + ->willReturn(new \stdClass()); $options = [ 'b' => 'foo', @@ -111,7 +111,7 @@ public function testExtractConfigurationSortsResolvedOptions() $type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); $type->expects($this->any()) ->method('getInnerType') - ->will($this->returnValue(new \stdClass())); + ->willReturn(new \stdClass()); $options = [ 'b' => 'foo', @@ -142,7 +142,7 @@ public function testExtractConfigurationBuildsIdRecursively() $type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock(); $type->expects($this->any()) ->method('getInnerType') - ->will($this->returnValue(new \stdClass())); + ->willReturn(new \stdClass()); $grandParent = $this->createBuilder('grandParent') ->setCompound(true) diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php index 53d29a19112c7..57f92b6574e3b 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php @@ -42,7 +42,7 @@ public function testSubmitValidatesData() $this->validator->expects($this->once()) ->method('validate') ->with($this->equalTo($form)) - ->will($this->returnValue(new ConstraintViolationList())); + ->willReturn(new ConstraintViolationList()); // specific data is irrelevant $form->submit([]); diff --git a/src/Symfony/Component/Form/Tests/FormBuilderTest.php b/src/Symfony/Component/Form/Tests/FormBuilderTest.php index ecab2bb5d91ef..1247a80bbda30 100644 --- a/src/Symfony/Component/Form/Tests/FormBuilderTest.php +++ b/src/Symfony/Component/Form/Tests/FormBuilderTest.php @@ -91,7 +91,7 @@ public function testAll() $this->factory->expects($this->once()) ->method('createNamedBuilder') ->with('foo', 'Symfony\Component\Form\Extension\Core\Type\TextType') - ->will($this->returnValue(new FormBuilder('foo', null, $this->dispatcher, $this->factory))); + ->willReturn(new FormBuilder('foo', null, $this->dispatcher, $this->factory)); $this->assertCount(0, $this->builder->all()); $this->assertFalse($this->builder->has('foo')); @@ -186,7 +186,7 @@ public function testGetExplicitType() $this->factory->expects($this->once()) ->method('createNamedBuilder') ->with($expectedName, $expectedType, null, $expectedOptions) - ->will($this->returnValue($this->getFormBuilder())); + ->willReturn($this->getFormBuilder()); $this->builder->add($expectedName, $expectedType, $expectedOptions); $builder = $this->builder->get($expectedName); @@ -202,7 +202,7 @@ public function testGetGuessedType() $this->factory->expects($this->once()) ->method('createBuilderForProperty') ->with('stdClass', $expectedName, null, $expectedOptions) - ->will($this->returnValue($this->getFormBuilder())); + ->willReturn($this->getFormBuilder()); $this->builder = new FormBuilder('name', 'stdClass', $this->dispatcher, $this->factory); $this->builder->add($expectedName, null, $expectedOptions); @@ -236,7 +236,7 @@ private function getFormBuilder($name = 'name') $mock->expects($this->any()) ->method('getName') - ->will($this->returnValue($name)); + ->willReturn($name); return $mock; } diff --git a/src/Symfony/Component/Form/Tests/FormFactoryTest.php b/src/Symfony/Component/Form/Tests/FormFactoryTest.php index 27a5ca6e20f7c..4426310676538 100644 --- a/src/Symfony/Component/Form/Tests/FormFactoryTest.php +++ b/src/Symfony/Component/Form/Tests/FormFactoryTest.php @@ -58,10 +58,10 @@ protected function setUp() $this->registry->expects($this->any()) ->method('getTypeGuesser') - ->will($this->returnValue(new FormTypeGuesserChain([ + ->willReturn(new FormTypeGuesserChain([ $this->guesser1, $this->guesser2, - ]))); + ])); } public function testCreateNamedBuilderWithTypeName() @@ -73,16 +73,16 @@ public function testCreateNamedBuilderWithTypeName() $this->registry->expects($this->once()) ->method('getType') ->with('type') - ->will($this->returnValue($resolvedType)); + ->willReturn($resolvedType); $resolvedType->expects($this->once()) ->method('createBuilder') ->with($this->factory, 'name', $options) - ->will($this->returnValue($this->builder)); + ->willReturn($this->builder); $this->builder->expects($this->any()) ->method('getOptions') - ->will($this->returnValue($resolvedOptions)); + ->willReturn($resolvedOptions); $resolvedType->expects($this->once()) ->method('buildForm') @@ -101,16 +101,16 @@ public function testCreateNamedBuilderFillsDataOption() $this->registry->expects($this->once()) ->method('getType') ->with('type') - ->will($this->returnValue($resolvedType)); + ->willReturn($resolvedType); $resolvedType->expects($this->once()) ->method('createBuilder') ->with($this->factory, 'name', $expectedOptions) - ->will($this->returnValue($this->builder)); + ->willReturn($this->builder); $this->builder->expects($this->any()) ->method('getOptions') - ->will($this->returnValue($resolvedOptions)); + ->willReturn($resolvedOptions); $resolvedType->expects($this->once()) ->method('buildForm') @@ -128,16 +128,16 @@ public function testCreateNamedBuilderDoesNotOverrideExistingDataOption() $this->registry->expects($this->once()) ->method('getType') ->with('type') - ->will($this->returnValue($resolvedType)); + ->willReturn($resolvedType); $resolvedType->expects($this->once()) ->method('createBuilder') ->with($this->factory, 'name', $options) - ->will($this->returnValue($this->builder)); + ->willReturn($this->builder); $this->builder->expects($this->any()) ->method('getOptions') - ->will($this->returnValue($resolvedOptions)); + ->willReturn($resolvedOptions); $resolvedType->expects($this->once()) ->method('buildForm') @@ -181,16 +181,16 @@ public function testCreateUsesBlockPrefixIfTypeGivenAsString() $this->registry->expects($this->any()) ->method('getType') ->with('TYPE') - ->will($this->returnValue($resolvedType)); + ->willReturn($resolvedType); $resolvedType->expects($this->once()) ->method('createBuilder') ->with($this->factory, 'TYPE_PREFIX', $options) - ->will($this->returnValue($this->builder)); + ->willReturn($this->builder); $this->builder->expects($this->any()) ->method('getOptions') - ->will($this->returnValue($resolvedOptions)); + ->willReturn($resolvedOptions); $resolvedType->expects($this->once()) ->method('buildForm') @@ -198,7 +198,7 @@ public function testCreateUsesBlockPrefixIfTypeGivenAsString() $this->builder->expects($this->once()) ->method('getForm') - ->will($this->returnValue('FORM')); + ->willReturn('FORM'); $this->assertSame('FORM', $this->factory->create('TYPE', null, $options)); } @@ -212,16 +212,16 @@ public function testCreateNamed() $this->registry->expects($this->once()) ->method('getType') ->with('type') - ->will($this->returnValue($resolvedType)); + ->willReturn($resolvedType); $resolvedType->expects($this->once()) ->method('createBuilder') ->with($this->factory, 'name', $options) - ->will($this->returnValue($this->builder)); + ->willReturn($this->builder); $this->builder->expects($this->any()) ->method('getOptions') - ->will($this->returnValue($resolvedOptions)); + ->willReturn($resolvedOptions); $resolvedType->expects($this->once()) ->method('buildForm') @@ -229,7 +229,7 @@ public function testCreateNamed() $this->builder->expects($this->once()) ->method('getForm') - ->will($this->returnValue('FORM')); + ->willReturn('FORM'); $this->assertSame('FORM', $this->factory->createNamed('name', 'type', null, $options)); } @@ -245,7 +245,7 @@ public function testCreateBuilderForPropertyWithoutTypeGuesser() $factory->expects($this->once()) ->method('createNamedBuilder') ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, []) - ->will($this->returnValue('builderInstance')); + ->willReturn('builderInstance'); $this->builder = $factory->createBuilderForProperty('Application\Author', 'firstName'); @@ -257,27 +257,27 @@ public function testCreateBuilderForPropertyCreatesFormWithHighestConfidence() $this->guesser1->expects($this->once()) ->method('guessType') ->with('Application\Author', 'firstName') - ->will($this->returnValue(new TypeGuess( + ->willReturn(new TypeGuess( 'Symfony\Component\Form\Extension\Core\Type\TextType', ['attr' => ['maxlength' => 10]], Guess::MEDIUM_CONFIDENCE - ))); + )); $this->guesser2->expects($this->once()) ->method('guessType') ->with('Application\Author', 'firstName') - ->will($this->returnValue(new TypeGuess( + ->willReturn(new TypeGuess( 'Symfony\Component\Form\Extension\Core\Type\PasswordType', ['attr' => ['maxlength' => 7]], Guess::HIGH_CONFIDENCE - ))); + )); $factory = $this->getMockFactory(['createNamedBuilder']); $factory->expects($this->once()) ->method('createNamedBuilder') ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\PasswordType', null, ['attr' => ['maxlength' => 7]]) - ->will($this->returnValue('builderInstance')); + ->willReturn('builderInstance'); $this->builder = $factory->createBuilderForProperty('Application\Author', 'firstName'); @@ -289,14 +289,14 @@ public function testCreateBuilderCreatesTextFormIfNoGuess() $this->guesser1->expects($this->once()) ->method('guessType') ->with('Application\Author', 'firstName') - ->will($this->returnValue(null)); + ->willReturn(null); $factory = $this->getMockFactory(['createNamedBuilder']); $factory->expects($this->once()) ->method('createNamedBuilder') ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType') - ->will($this->returnValue('builderInstance')); + ->willReturn('builderInstance'); $this->builder = $factory->createBuilderForProperty('Application\Author', 'firstName'); @@ -308,18 +308,18 @@ public function testOptionsCanBeOverridden() $this->guesser1->expects($this->once()) ->method('guessType') ->with('Application\Author', 'firstName') - ->will($this->returnValue(new TypeGuess( + ->willReturn(new TypeGuess( 'Symfony\Component\Form\Extension\Core\Type\TextType', ['attr' => ['class' => 'foo', 'maxlength' => 10]], Guess::MEDIUM_CONFIDENCE - ))); + )); $factory = $this->getMockFactory(['createNamedBuilder']); $factory->expects($this->once()) ->method('createNamedBuilder') ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['attr' => ['class' => 'foo', 'maxlength' => 11]]) - ->will($this->returnValue('builderInstance')); + ->willReturn('builderInstance'); $this->builder = $factory->createBuilderForProperty( 'Application\Author', @@ -336,25 +336,25 @@ public function testCreateBuilderUsesMaxLengthIfFound() $this->guesser1->expects($this->once()) ->method('guessMaxLength') ->with('Application\Author', 'firstName') - ->will($this->returnValue(new ValueGuess( + ->willReturn(new ValueGuess( 15, Guess::MEDIUM_CONFIDENCE - ))); + )); $this->guesser2->expects($this->once()) ->method('guessMaxLength') ->with('Application\Author', 'firstName') - ->will($this->returnValue(new ValueGuess( + ->willReturn(new ValueGuess( 20, Guess::HIGH_CONFIDENCE - ))); + )); $factory = $this->getMockFactory(['createNamedBuilder']); $factory->expects($this->once()) ->method('createNamedBuilder') ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['attr' => ['maxlength' => 20]]) - ->will($this->returnValue('builderInstance')); + ->willReturn('builderInstance'); $this->builder = $factory->createBuilderForProperty( 'Application\Author', @@ -369,25 +369,25 @@ public function testCreateBuilderUsesMaxLengthAndPattern() $this->guesser1->expects($this->once()) ->method('guessMaxLength') ->with('Application\Author', 'firstName') - ->will($this->returnValue(new ValueGuess( + ->willReturn(new ValueGuess( 20, Guess::HIGH_CONFIDENCE - ))); + )); $this->guesser2->expects($this->once()) ->method('guessPattern') ->with('Application\Author', 'firstName') - ->will($this->returnValue(new ValueGuess( + ->willReturn(new ValueGuess( '.{5,}', Guess::HIGH_CONFIDENCE - ))); + )); $factory = $this->getMockFactory(['createNamedBuilder']); $factory->expects($this->once()) ->method('createNamedBuilder') ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['attr' => ['maxlength' => 20, 'pattern' => '.{5,}', 'class' => 'tinymce']]) - ->will($this->returnValue('builderInstance')); + ->willReturn('builderInstance'); $this->builder = $factory->createBuilderForProperty( 'Application\Author', @@ -404,25 +404,25 @@ public function testCreateBuilderUsesRequiredSettingWithHighestConfidence() $this->guesser1->expects($this->once()) ->method('guessRequired') ->with('Application\Author', 'firstName') - ->will($this->returnValue(new ValueGuess( + ->willReturn(new ValueGuess( true, Guess::MEDIUM_CONFIDENCE - ))); + )); $this->guesser2->expects($this->once()) ->method('guessRequired') ->with('Application\Author', 'firstName') - ->will($this->returnValue(new ValueGuess( + ->willReturn(new ValueGuess( false, Guess::HIGH_CONFIDENCE - ))); + )); $factory = $this->getMockFactory(['createNamedBuilder']); $factory->expects($this->once()) ->method('createNamedBuilder') ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['required' => false]) - ->will($this->returnValue('builderInstance')); + ->willReturn('builderInstance'); $this->builder = $factory->createBuilderForProperty( 'Application\Author', @@ -437,25 +437,25 @@ public function testCreateBuilderUsesPatternIfFound() $this->guesser1->expects($this->once()) ->method('guessPattern') ->with('Application\Author', 'firstName') - ->will($this->returnValue(new ValueGuess( + ->willReturn(new ValueGuess( '[a-z]', Guess::MEDIUM_CONFIDENCE - ))); + )); $this->guesser2->expects($this->once()) ->method('guessPattern') ->with('Application\Author', 'firstName') - ->will($this->returnValue(new ValueGuess( + ->willReturn(new ValueGuess( '[a-zA-Z]', Guess::HIGH_CONFIDENCE - ))); + )); $factory = $this->getMockFactory(['createNamedBuilder']); $factory->expects($this->once()) ->method('createNamedBuilder') ->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['attr' => ['pattern' => '[a-zA-Z]']]) - ->will($this->returnValue('builderInstance')); + ->willReturn('builderInstance'); $this->builder = $factory->createBuilderForProperty( 'Application\Author', diff --git a/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php b/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php index 32bb8bb788716..ba078ad1fd119 100644 --- a/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php +++ b/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php @@ -99,21 +99,21 @@ public function testGetOptionsResolver() // First the default options are generated for the super type $this->parentType->expects($this->once()) ->method('configureOptions') - ->will($this->returnCallback($assertIndexAndAddOption(0, 'a', 'a_default'))); + ->willReturnCallback($assertIndexAndAddOption(0, 'a', 'a_default')); // The form type itself $this->type->expects($this->once()) ->method('configureOptions') - ->will($this->returnCallback($assertIndexAndAddOption(1, 'b', 'b_default'))); + ->willReturnCallback($assertIndexAndAddOption(1, 'b', 'b_default')); // And its extensions $this->extension1->expects($this->once()) ->method('configureOptions') - ->will($this->returnCallback($assertIndexAndAddOption(2, 'c', 'c_default'))); + ->willReturnCallback($assertIndexAndAddOption(2, 'c', 'c_default')); $this->extension2->expects($this->once()) ->method('configureOptions') - ->will($this->returnCallback($assertIndexAndAddOption(3, 'd', 'd_default'))); + ->willReturnCallback($assertIndexAndAddOption(3, 'd', 'd_default')); $givenOptions = ['a' => 'a_custom', 'c' => 'c_custom']; $resolvedOptions = ['a' => 'a_custom', 'b' => 'b_default', 'c' => 'c_custom', 'd' => 'd_default']; @@ -136,12 +136,12 @@ public function testCreateBuilder() $this->resolvedType->expects($this->once()) ->method('getOptionsResolver') - ->will($this->returnValue($optionsResolver)); + ->willReturn($optionsResolver); $optionsResolver->expects($this->once()) ->method('resolve') ->with($givenOptions) - ->will($this->returnValue($resolvedOptions)); + ->willReturn($resolvedOptions); $factory = $this->getMockFormFactory(); $builder = $this->resolvedType->createBuilder($factory, 'name', $givenOptions); @@ -164,12 +164,12 @@ public function testCreateBuilderWithDataClassOption() $this->resolvedType->expects($this->once()) ->method('getOptionsResolver') - ->will($this->returnValue($optionsResolver)); + ->willReturn($optionsResolver); $optionsResolver->expects($this->once()) ->method('resolve') ->with($givenOptions) - ->will($this->returnValue($resolvedOptions)); + ->willReturn($resolvedOptions); $factory = $this->getMockFormFactory(); $builder = $this->resolvedType->createBuilder($factory, 'name', $givenOptions); @@ -198,24 +198,24 @@ public function testBuildForm() $this->parentType->expects($this->once()) ->method('buildForm') ->with($builder, $options) - ->will($this->returnCallback($assertIndex(0))); + ->willReturnCallback($assertIndex(0)); // Then the type itself $this->type->expects($this->once()) ->method('buildForm') ->with($builder, $options) - ->will($this->returnCallback($assertIndex(1))); + ->willReturnCallback($assertIndex(1)); // Then its extensions $this->extension1->expects($this->once()) ->method('buildForm') ->with($builder, $options) - ->will($this->returnCallback($assertIndex(2))); + ->willReturnCallback($assertIndex(2)); $this->extension2->expects($this->once()) ->method('buildForm') ->with($builder, $options) - ->will($this->returnCallback($assertIndex(3))); + ->willReturnCallback($assertIndex(3)); $this->resolvedType->buildForm($builder, $options); } @@ -261,24 +261,24 @@ public function testBuildView() $this->parentType->expects($this->once()) ->method('buildView') ->with($view, $form, $options) - ->will($this->returnCallback($assertIndex(0))); + ->willReturnCallback($assertIndex(0)); // Then the type itself $this->type->expects($this->once()) ->method('buildView') ->with($view, $form, $options) - ->will($this->returnCallback($assertIndex(1))); + ->willReturnCallback($assertIndex(1)); // Then its extensions $this->extension1->expects($this->once()) ->method('buildView') ->with($view, $form, $options) - ->will($this->returnCallback($assertIndex(2))); + ->willReturnCallback($assertIndex(2)); $this->extension2->expects($this->once()) ->method('buildView') ->with($view, $form, $options) - ->will($this->returnCallback($assertIndex(3))); + ->willReturnCallback($assertIndex(3)); $this->resolvedType->buildView($view, $form, $options); } @@ -303,24 +303,24 @@ public function testFinishView() $this->parentType->expects($this->once()) ->method('finishView') ->with($view, $form, $options) - ->will($this->returnCallback($assertIndex(0))); + ->willReturnCallback($assertIndex(0)); // Then the type itself $this->type->expects($this->once()) ->method('finishView') ->with($view, $form, $options) - ->will($this->returnCallback($assertIndex(1))); + ->willReturnCallback($assertIndex(1)); // Then its extensions $this->extension1->expects($this->once()) ->method('finishView') ->with($view, $form, $options) - ->will($this->returnCallback($assertIndex(2))); + ->willReturnCallback($assertIndex(2)); $this->extension2->expects($this->once()) ->method('finishView') ->with($view, $form, $options) - ->will($this->returnCallback($assertIndex(3))); + ->willReturnCallback($assertIndex(3)); $this->resolvedType->finishView($view, $form, $options); } diff --git a/src/Symfony/Component/Form/Tests/SimpleFormTest.php b/src/Symfony/Component/Form/Tests/SimpleFormTest.php index 32c21c8432b7a..f88902dc8ced6 100644 --- a/src/Symfony/Component/Form/Tests/SimpleFormTest.php +++ b/src/Symfony/Component/Form/Tests/SimpleFormTest.php @@ -731,7 +731,7 @@ public function testCreateView() $type->expects($this->once()) ->method('createView') ->with($form) - ->will($this->returnValue($view)); + ->willReturn($view); $this->assertSame($view, $form->createView()); } @@ -748,12 +748,12 @@ public function testCreateViewWithParent() $parentType->expects($this->once()) ->method('createView') - ->will($this->returnValue($parentView)); + ->willReturn($parentView); $type->expects($this->once()) ->method('createView') ->with($form, $parentView) - ->will($this->returnValue($view)); + ->willReturn($view); $this->assertSame($view, $form->createView()); } @@ -768,7 +768,7 @@ public function testCreateViewWithExplicitParent() $type->expects($this->once()) ->method('createView') ->with($form, $parentView) - ->will($this->returnValue($view)); + ->willReturn($view); $this->assertSame($view, $form->createView($parentView)); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/File/FileTest.php b/src/Symfony/Component/HttpFoundation/Tests/File/FileTest.php index fb82dae768b4f..caf2029927008 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/File/FileTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/File/FileTest.php @@ -172,7 +172,7 @@ protected function createMockGuesser($path, $mimeType) ->expects($this->once()) ->method('guess') ->with($this->equalTo($path)) - ->will($this->returnValue($mimeType)) + ->willReturn($mimeType) ; return $guesser; diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php index 68daa4e5cb595..d7a324fc205bc 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php @@ -79,7 +79,7 @@ public function testWriteSession() ->expects($this->once()) ->method('set') ->with(self::PREFIX.'id', 'data', 0, $this->equalTo(time() + self::TTL, 2)) - ->will($this->returnValue(true)) + ->willReturn(true) ; $this->assertTrue($this->storage->write('id', 'data')); @@ -91,7 +91,7 @@ public function testDestroySession() ->expects($this->once()) ->method('delete') ->with(self::PREFIX.'id') - ->will($this->returnValue(true)) + ->willReturn(true) ; $this->assertTrue($this->storage->destroy('id')); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php index 813337349f225..c3deb7aed8fb5 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php @@ -66,7 +66,7 @@ public function testCloseSession() $this->memcached ->expects($this->once()) ->method('quit') - ->will($this->returnValue(true)) + ->willReturn(true) ; $this->assertTrue($this->storage->close()); @@ -89,7 +89,7 @@ public function testWriteSession() ->expects($this->once()) ->method('set') ->with(self::PREFIX.'id', 'data', $this->equalTo(time() + self::TTL, 2)) - ->will($this->returnValue(true)) + ->willReturn(true) ; $this->assertTrue($this->storage->write('id', 'data')); @@ -101,7 +101,7 @@ public function testDestroySession() ->expects($this->once()) ->method('delete') ->with(self::PREFIX.'id') - ->will($this->returnValue(true)) + ->willReturn(true) ; $this->assertTrue($this->storage->destroy('id')); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php index 6f2742ca70e53..5ce6a9e5a6641 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php @@ -95,7 +95,7 @@ public function testRead() $this->mongo->expects($this->once()) ->method('selectCollection') ->with($this->options['database'], $this->options['collection']) - ->will($this->returnValue($collection)); + ->willReturn($collection); // defining the timeout before the actual method call // allows to test for "greater than" values in the $criteria @@ -103,7 +103,7 @@ public function testRead() $collection->expects($this->once()) ->method('findOne') - ->will($this->returnCallback(function ($criteria) use ($testTimeout) { + ->willReturnCallback(function ($criteria) use ($testTimeout) { $this->assertArrayHasKey($this->options['id_field'], $criteria); $this->assertEquals($criteria[$this->options['id_field']], 'foo'); @@ -131,7 +131,7 @@ public function testRead() } return $fields; - })); + }); $this->assertEquals('bar', $this->storage->read('foo')); } @@ -143,7 +143,7 @@ public function testWrite() $this->mongo->expects($this->once()) ->method('selectCollection') ->with($this->options['database'], $this->options['collection']) - ->will($this->returnValue($collection)); + ->willReturn($collection); $data = []; @@ -151,7 +151,7 @@ public function testWrite() $collection->expects($this->once()) ->method($methodName) - ->will($this->returnCallback(function ($criteria, $updateData, $options) use (&$data) { + ->willReturnCallback(function ($criteria, $updateData, $options) use (&$data) { $this->assertEquals([$this->options['id_field'] => 'foo'], $criteria); if (phpversion('mongodb')) { @@ -161,7 +161,7 @@ public function testWrite() } $data = $updateData['$set']; - })); + }); $expectedExpiry = time() + (int) ini_get('session.gc_maxlifetime'); $this->assertTrue($this->storage->write('foo', 'bar')); @@ -197,7 +197,7 @@ public function testWriteWhenUsingExpiresField() $this->mongo->expects($this->once()) ->method('selectCollection') ->with($this->options['database'], $this->options['collection']) - ->will($this->returnValue($collection)); + ->willReturn($collection); $data = []; @@ -205,7 +205,7 @@ public function testWriteWhenUsingExpiresField() $collection->expects($this->once()) ->method($methodName) - ->will($this->returnCallback(function ($criteria, $updateData, $options) use (&$data) { + ->willReturnCallback(function ($criteria, $updateData, $options) use (&$data) { $this->assertEquals([$this->options['id_field'] => 'foo'], $criteria); if (phpversion('mongodb')) { @@ -215,7 +215,7 @@ public function testWriteWhenUsingExpiresField() } $data = $updateData['$set']; - })); + }); $this->assertTrue($this->storage->write('foo', 'bar')); @@ -237,7 +237,7 @@ public function testReplaceSessionData() $this->mongo->expects($this->once()) ->method('selectCollection') ->with($this->options['database'], $this->options['collection']) - ->will($this->returnValue($collection)); + ->willReturn($collection); $data = []; @@ -245,9 +245,9 @@ public function testReplaceSessionData() $collection->expects($this->exactly(2)) ->method($methodName) - ->will($this->returnCallback(function ($criteria, $updateData, $options) use (&$data) { + ->willReturnCallback(function ($criteria, $updateData, $options) use (&$data) { $data = $updateData; - })); + }); $this->storage->write('foo', 'bar'); $this->storage->write('foo', 'foobar'); @@ -266,7 +266,7 @@ public function testDestroy() $this->mongo->expects($this->once()) ->method('selectCollection') ->with($this->options['database'], $this->options['collection']) - ->will($this->returnValue($collection)); + ->willReturn($collection); $methodName = phpversion('mongodb') ? 'deleteOne' : 'remove'; @@ -284,13 +284,13 @@ public function testGc() $this->mongo->expects($this->once()) ->method('selectCollection') ->with($this->options['database'], $this->options['collection']) - ->will($this->returnValue($collection)); + ->willReturn($collection); $methodName = phpversion('mongodb') ? 'deleteMany' : 'remove'; $collection->expects($this->once()) ->method($methodName) - ->will($this->returnCallback(function ($criteria) { + ->willReturnCallback(function ($criteria) { if (phpversion('mongodb')) { $this->assertInstanceOf('MongoDB\BSON\UTCDateTime', $criteria[$this->options['expiry_field']]['$lt']); $this->assertGreaterThanOrEqual(time() - 1, round((string) $criteria[$this->options['expiry_field']]['$lt'] / 1000)); @@ -298,7 +298,7 @@ public function testGc() $this->assertInstanceOf('MongoDate', $criteria[$this->options['expiry_field']]['$lt']); $this->assertGreaterThanOrEqual(time() - 1, $criteria[$this->options['expiry_field']]['$lt']->sec); } - })); + }); $this->assertTrue($this->storage->gc(1)); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php index 901078478b4db..f0914eb43d080 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php @@ -147,7 +147,7 @@ public function testReadConvertsStreamToString() $stream = $this->createStream($content); $pdo->prepareResult->expects($this->once())->method('fetchAll') - ->will($this->returnValue([[$stream, 42, time()]])); + ->willReturn([[$stream, 42, time()]]); $storage = new PdoSessionHandler($pdo); $result = $storage->read('foo'); @@ -177,14 +177,14 @@ public function testReadLockedConvertsStreamToString() $exception = null; $selectStmt->expects($this->atLeast(2))->method('fetchAll') - ->will($this->returnCallback(function () use (&$exception, $stream) { + ->willReturnCallback(function () use (&$exception, $stream) { return $exception ? [[$stream, 42, time()]] : []; - })); + }); $insertStmt->expects($this->once())->method('execute') - ->will($this->returnCallback(function () use (&$exception) { + ->willReturnCallback(function () use (&$exception) { throw $exception = new \PDOException('', '23'); - })); + }); $storage = new PdoSessionHandler($pdo); $result = $storage->read('foo'); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/WriteCheckSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/WriteCheckSessionHandlerTest.php index 898a7d11a5ae2..b89454f87f4e7 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/WriteCheckSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/WriteCheckSessionHandlerTest.php @@ -30,7 +30,7 @@ public function test() ->expects($this->once()) ->method('close') ->with() - ->will($this->returnValue(true)) + ->willReturn(true) ; $this->assertTrue($writeCheckSessionHandler->close()); @@ -45,7 +45,7 @@ public function testWrite() ->expects($this->once()) ->method('write') ->with('foo', 'bar') - ->will($this->returnValue(true)) + ->willReturn(true) ; $this->assertTrue($writeCheckSessionHandler->write('foo', 'bar')); @@ -60,7 +60,7 @@ public function testSkippedWrite() ->expects($this->once()) ->method('read') ->with('foo') - ->will($this->returnValue('bar')) + ->willReturn('bar') ; $wrappedSessionHandlerMock @@ -81,14 +81,14 @@ public function testNonSkippedWrite() ->expects($this->once()) ->method('read') ->with('foo') - ->will($this->returnValue('bar')) + ->willReturn('bar') ; $wrappedSessionHandlerMock ->expects($this->once()) ->method('write') ->with('foo', 'baZZZ') - ->will($this->returnValue(true)) + ->willReturn(true) ; $this->assertEquals('bar', $writeCheckSessionHandler->read('foo')); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php index 0459a8ce97d50..b6e0da99ddd67 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php @@ -50,7 +50,7 @@ public function testOpenTrue() { $this->mock->expects($this->once()) ->method('open') - ->will($this->returnValue(true)); + ->willReturn(true); $this->assertFalse($this->proxy->isActive()); $this->proxy->open('name', 'id'); @@ -61,7 +61,7 @@ public function testOpenFalse() { $this->mock->expects($this->once()) ->method('open') - ->will($this->returnValue(false)); + ->willReturn(false); $this->assertFalse($this->proxy->isActive()); $this->proxy->open('name', 'id'); @@ -72,7 +72,7 @@ public function testClose() { $this->mock->expects($this->once()) ->method('close') - ->will($this->returnValue(true)); + ->willReturn(true); $this->assertFalse($this->proxy->isActive()); $this->proxy->close(); @@ -83,7 +83,7 @@ public function testCloseFalse() { $this->mock->expects($this->once()) ->method('close') - ->will($this->returnValue(false)); + ->willReturn(false); $this->assertFalse($this->proxy->isActive()); $this->proxy->close(); diff --git a/src/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerAggregateTest.php b/src/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerAggregateTest.php index de15c6f30ce0b..41fe28507c8f9 100644 --- a/src/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerAggregateTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerAggregateTest.php @@ -87,7 +87,7 @@ public function testWarmupDoesNotCallWarmupOnOptionalWarmersWhenEnableOptionalWa $warmer ->expects($this->once()) ->method('isOptional') - ->will($this->returnValue(true)); + ->willReturn(true); $warmer ->expects($this->never()) ->method('warmUp'); diff --git a/src/Symfony/Component/HttpKernel/Tests/ClientTest.php b/src/Symfony/Component/HttpKernel/Tests/ClientTest.php index ac1c55ad54d35..86a51ce7651a2 100644 --- a/src/Symfony/Component/HttpKernel/Tests/ClientTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/ClientTest.php @@ -157,7 +157,7 @@ public function testUploadedFileWhenSizeExceedsUploadMaxFileSize() $file->expects($this->once()) ->method('getSize') - ->will($this->returnValue(INF)) + ->willReturn(INF) ; $client->request('POST', '/', [], [$file]); diff --git a/src/Symfony/Component/HttpKernel/Tests/Config/FileLocatorTest.php b/src/Symfony/Component/HttpKernel/Tests/Config/FileLocatorTest.php index 6265f0275560a..b20b12ab59ed6 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Config/FileLocatorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Config/FileLocatorTest.php @@ -23,7 +23,7 @@ public function testLocate() ->expects($this->atLeastOnce()) ->method('locateResource') ->with('@BundleName/some/path', null, true) - ->will($this->returnValue('/bundle-name/some/path')); + ->willReturn('/bundle-name/some/path'); $locator = new FileLocator($kernel); $this->assertEquals('/bundle-name/some/path', $locator->locate('@BundleName/some/path')); diff --git a/src/Symfony/Component/HttpKernel/Tests/Controller/ContainerControllerResolverTest.php b/src/Symfony/Component/HttpKernel/Tests/Controller/ContainerControllerResolverTest.php index 3f130db06500a..098b89f9e1255 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Controller/ContainerControllerResolverTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Controller/ContainerControllerResolverTest.php @@ -26,11 +26,11 @@ public function testGetControllerService() $container->expects($this->once()) ->method('has') ->with('foo') - ->will($this->returnValue(true)); + ->willReturn(true); $container->expects($this->once()) ->method('get') ->with('foo') - ->will($this->returnValue($this)) + ->willReturn($this) ; $resolver = $this->createControllerResolver(null, $container); @@ -51,12 +51,12 @@ public function testGetControllerInvokableService() $container->expects($this->once()) ->method('has') ->with('foo') - ->will($this->returnValue(true)) + ->willReturn(true) ; $container->expects($this->once()) ->method('get') ->with('foo') - ->will($this->returnValue($invokableController)) + ->willReturn($invokableController) ; $resolver = $this->createControllerResolver(null, $container); @@ -77,12 +77,12 @@ public function testGetControllerInvokableServiceWithClassNameAsName() $container->expects($this->once()) ->method('has') ->with($className) - ->will($this->returnValue(true)) + ->willReturn(true) ; $container->expects($this->once()) ->method('get') ->with($className) - ->will($this->returnValue($invokableController)) + ->willReturn($invokableController) ; $resolver = $this->createControllerResolver(null, $container); @@ -100,7 +100,7 @@ public function testNonInstantiableController() $container->expects($this->once()) ->method('has') ->with(NonInstantiableController::class) - ->will($this->returnValue(false)) + ->willReturn(false) ; $resolver = $this->createControllerResolver(null, $container); @@ -122,19 +122,19 @@ public function testNonConstructController() $container->expects($this->at(0)) ->method('has') ->with(ImpossibleConstructController::class) - ->will($this->returnValue(true)) + ->willReturn(true) ; $container->expects($this->at(1)) ->method('has') ->with(ImpossibleConstructController::class) - ->will($this->returnValue(false)) + ->willReturn(false) ; $container->expects($this->atLeastOnce()) ->method('getRemovedIds') ->with() - ->will($this->returnValue([ImpossibleConstructController::class => true])) + ->willReturn([ImpossibleConstructController::class => true]) ; $resolver = $this->createControllerResolver(null, $container); @@ -162,12 +162,12 @@ public function testNonInstantiableControllerWithCorrespondingService() $container->expects($this->atLeastOnce()) ->method('has') ->with(NonInstantiableController::class) - ->will($this->returnValue(true)) + ->willReturn(true) ; $container->expects($this->atLeastOnce()) ->method('get') ->with(NonInstantiableController::class) - ->will($this->returnValue($service)) + ->willReturn($service) ; $resolver = $this->createControllerResolver(null, $container); @@ -189,13 +189,13 @@ public function testExceptionWhenUsingRemovedControllerService() $container->expects($this->at(0)) ->method('has') ->with('app.my_controller') - ->will($this->returnValue(false)) + ->willReturn(false) ; $container->expects($this->atLeastOnce()) ->method('getRemovedIds') ->with() - ->will($this->returnValue(['app.my_controller' => true])) + ->willReturn(['app.my_controller' => true]) ; $resolver = $this->createControllerResolver(null, $container); @@ -215,12 +215,12 @@ public function testExceptionWhenUsingControllerWithoutAnInvokeMethod() $container->expects($this->once()) ->method('has') ->with('app.my_controller') - ->will($this->returnValue(true)) + ->willReturn(true) ; $container->expects($this->once()) ->method('get') ->with('app.my_controller') - ->will($this->returnValue(new ImpossibleConstructController('toto', 'controller'))) + ->willReturn(new ImpossibleConstructController('toto', 'controller')) ; $resolver = $this->createControllerResolver(null, $container); diff --git a/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php b/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php index 728382ad2b1ec..6a28eab26bb52 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php @@ -226,7 +226,7 @@ public function testGetVariadicArguments() public function testCreateControllerCanReturnAnyCallable() { $mock = $this->getMockBuilder('Symfony\Component\HttpKernel\Controller\ControllerResolver')->setMethods(['createController'])->getMock(); - $mock->expects($this->once())->method('createController')->will($this->returnValue('Symfony\Component\HttpKernel\Tests\Controller\some_controller_function')); + $mock->expects($this->once())->method('createController')->willReturn('Symfony\Component\HttpKernel\Tests\Controller\some_controller_function'); $request = Request::create('/'); $request->attributes->set('_controller', 'foobar'); diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php index 90151ae44afdf..ace4628e09f93 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php @@ -23,8 +23,8 @@ public function testCollectWithUnexpectedFormat() ->getMockBuilder('Symfony\Component\HttpKernel\Log\DebugLoggerInterface') ->setMethods(['countErrors', 'getLogs', 'clear']) ->getMock(); - $logger->expects($this->once())->method('countErrors')->will($this->returnValue('foo')); - $logger->expects($this->exactly(2))->method('getLogs')->will($this->returnValue([])); + $logger->expects($this->once())->method('countErrors')->willReturn('foo'); + $logger->expects($this->exactly(2))->method('getLogs')->willReturn([]); $c = new LoggerDataCollector($logger, __DIR__.'/'); $c->lateCollect(); @@ -50,8 +50,8 @@ public function testCollect($nb, $logs, $expectedLogs, $expectedDeprecationCount ->getMockBuilder('Symfony\Component\HttpKernel\Log\DebugLoggerInterface') ->setMethods(['countErrors', 'getLogs', 'clear']) ->getMock(); - $logger->expects($this->once())->method('countErrors')->will($this->returnValue($nb)); - $logger->expects($this->exactly(2))->method('getLogs')->will($this->returnValue($logs)); + $logger->expects($this->once())->method('countErrors')->willReturn($nb); + $logger->expects($this->exactly(2))->method('getLogs')->willReturn($logs); $c = new LoggerDataCollector($logger); $c->lateCollect(); diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php index 793fbd319f94d..6756f3de42647 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php @@ -44,7 +44,7 @@ public function testCollect() $this->assertEquals(0, $c->getStartTime()); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); - $kernel->expects($this->once())->method('getStartTime')->will($this->returnValue(123456)); + $kernel->expects($this->once())->method('getStartTime')->willReturn(123456); $c = new TimeDataCollector($kernel); $request = new Request(); diff --git a/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php b/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php index 8b8e91aeb474d..60ad1b89c4dfb 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php @@ -49,7 +49,7 @@ public function testStopwatchCheckControllerOnRequestEvent() ->getMock(); $stopwatch->expects($this->once()) ->method('isStarted') - ->will($this->returnValue(false)); + ->willReturn(false); $dispatcher = new TraceableEventDispatcher(new EventDispatcher(), $stopwatch); @@ -65,7 +65,7 @@ public function testStopwatchStopControllerOnRequestEvent() ->getMock(); $stopwatch->expects($this->once()) ->method('isStarted') - ->will($this->returnValue(true)); + ->willReturn(true); $stopwatch->expects($this->once()) ->method('stop'); $stopwatch->expects($this->once()) @@ -112,9 +112,9 @@ public function testListenerCanRemoveItselfWhenExecuted() protected function getHttpKernel($dispatcher, $controller) { $controllerResolver = $this->getMockBuilder('Symfony\Component\HttpKernel\Controller\ControllerResolverInterface')->getMock(); - $controllerResolver->expects($this->once())->method('getController')->will($this->returnValue($controller)); + $controllerResolver->expects($this->once())->method('getController')->willReturn($controller); $argumentResolver = $this->getMockBuilder('Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface')->getMock(); - $argumentResolver->expects($this->once())->method('getArguments')->will($this->returnValue([])); + $argumentResolver->expects($this->once())->method('getArguments')->willReturn([]); return new HttpKernel($dispatcher, $controllerResolver, new RequestStack(), $argumentResolver); } diff --git a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php index 95baaa54c133c..953dc65cdf735 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php @@ -25,14 +25,14 @@ class LazyLoadingFragmentHandlerTest extends TestCase public function testRenderWithLegacyMapping() { $renderer = $this->getMockBuilder('Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface')->getMock(); - $renderer->expects($this->once())->method('getName')->will($this->returnValue('foo')); - $renderer->expects($this->any())->method('render')->will($this->returnValue(new Response())); + $renderer->expects($this->once())->method('getName')->willReturn('foo'); + $renderer->expects($this->any())->method('render')->willReturn(new Response()); $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock(); - $requestStack->expects($this->any())->method('getCurrentRequest')->will($this->returnValue(Request::create('/'))); + $requestStack->expects($this->any())->method('getCurrentRequest')->willReturn(Request::create('/')); $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); - $container->expects($this->once())->method('get')->will($this->returnValue($renderer)); + $container->expects($this->once())->method('get')->willReturn($renderer); $handler = new LazyLoadingFragmentHandler($container, $requestStack, false); $handler->addRendererService('foo', 'foo'); @@ -46,15 +46,15 @@ public function testRenderWithLegacyMapping() public function testRender() { $renderer = $this->getMockBuilder('Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface')->getMock(); - $renderer->expects($this->once())->method('getName')->will($this->returnValue('foo')); - $renderer->expects($this->any())->method('render')->will($this->returnValue(new Response())); + $renderer->expects($this->once())->method('getName')->willReturn('foo'); + $renderer->expects($this->any())->method('render')->willReturn(new Response()); $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock(); - $requestStack->expects($this->any())->method('getCurrentRequest')->will($this->returnValue(Request::create('/'))); + $requestStack->expects($this->any())->method('getCurrentRequest')->willReturn(Request::create('/')); $container = $this->getMockBuilder('Psr\Container\ContainerInterface')->getMock(); $container->expects($this->once())->method('has')->with('foo')->willReturn(true); - $container->expects($this->once())->method('get')->will($this->returnValue($renderer)); + $container->expects($this->once())->method('get')->willReturn($renderer); $handler = new LazyLoadingFragmentHandler($container, $requestStack, false); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php index b4ea2f955bb53..4ab0a8fb1ea62 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php @@ -77,7 +77,7 @@ protected function getGetResponseEventMock(Request $request) $event->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)); + ->willReturn($request); return $event; } diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php index d9e261d35af5e..44af0149f738f 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php @@ -94,7 +94,7 @@ public function testConsoleEvent() $dispatcher = new EventDispatcher(); $listener = new DebugHandlersListener(null); $app = $this->getMockBuilder('Symfony\Component\Console\Application')->getMock(); - $app->expects($this->once())->method('getHelperSet')->will($this->returnValue(new HelperSet())); + $app->expects($this->once())->method('getHelperSet')->willReturn(new HelperSet()); $command = new Command(__FUNCTION__); $command->setApplication($app); $event = new ConsoleEvent($command, new ArgvInput(), new ConsoleOutput()); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php index c4e8cd505cbff..fca60f1927a27 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php @@ -112,9 +112,9 @@ public function testSubRequestFormat() $listener = new ExceptionListener('foo', $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock()); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); - $kernel->expects($this->once())->method('handle')->will($this->returnCallback(function (Request $request) { + $kernel->expects($this->once())->method('handle')->willReturnCallback(function (Request $request) { return new Response($request->getRequestFormat()); - })); + }); $request = Request::create('/'); $request->setRequestFormat('xml'); @@ -130,9 +130,9 @@ public function testCSPHeaderIsRemoved() { $dispatcher = new EventDispatcher(); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); - $kernel->expects($this->once())->method('handle')->will($this->returnCallback(function (Request $request) { + $kernel->expects($this->once())->method('handle')->willReturnCallback(function (Request $request) { return new Response($request->getRequestFormat()); - })); + }); $listener = new ExceptionListener('foo', $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(), true); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php index 1cf4b72c69d78..5f96f7f7c660b 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php @@ -55,7 +55,7 @@ public function testLocaleSetForRoutingContext() $context->expects($this->once())->method('setParameter')->with('_locale', 'es'); $router = $this->getMockBuilder('Symfony\Component\Routing\Router')->setMethods(['getContext'])->disableOriginalConstructor()->getMock(); - $router->expects($this->once())->method('getContext')->will($this->returnValue($context)); + $router->expects($this->once())->method('getContext')->willReturn($context); $request = Request::create('/'); @@ -71,12 +71,12 @@ public function testRouterResetWithParentRequestOnKernelFinishRequest() $context->expects($this->once())->method('setParameter')->with('_locale', 'es'); $router = $this->getMockBuilder('Symfony\Component\Routing\Router')->setMethods(['getContext'])->disableOriginalConstructor()->getMock(); - $router->expects($this->once())->method('getContext')->will($this->returnValue($context)); + $router->expects($this->once())->method('getContext')->willReturn($context); $parentRequest = Request::create('/'); $parentRequest->setLocale('es'); - $this->requestStack->expects($this->once())->method('getParentRequest')->will($this->returnValue($parentRequest)); + $this->requestStack->expects($this->once())->method('getParentRequest')->willReturn($parentRequest); $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\FinishRequestEvent')->disableOriginalConstructor()->getMock(); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php index 392aa2fc35816..7808578882fcd 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ProfilerListenerTest.php @@ -36,7 +36,7 @@ public function testKernelTerminate() $profiler->expects($this->once()) ->method('collect') - ->will($this->returnValue($profile)); + ->willReturn($profile); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php index 218af8d36e293..33f6ab9594a96 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php @@ -49,7 +49,7 @@ public function testPort($defaultHttpPort, $defaultHttpsPort, $uri, $expectedHtt $context->setHttpsPort($defaultHttpsPort); $urlMatcher->expects($this->any()) ->method('getContext') - ->will($this->returnValue($context)); + ->willReturn($context); $listener = new RouterListener($urlMatcher, $this->requestStack); $event = $this->createGetResponseEventForUri($uri); @@ -102,7 +102,7 @@ public function testRequestMatcher() $requestMatcher->expects($this->once()) ->method('matchRequest') ->with($this->isInstanceOf('Symfony\Component\HttpFoundation\Request')) - ->will($this->returnValue([])); + ->willReturn([]); $listener = new RouterListener($requestMatcher, $this->requestStack, new RequestContext()); $listener->onKernelRequest($event); @@ -118,7 +118,7 @@ public function testSubRequestWithDifferentMethod() $requestMatcher->expects($this->any()) ->method('matchRequest') ->with($this->isInstanceOf('Symfony\Component\HttpFoundation\Request')) - ->will($this->returnValue([])); + ->willReturn([]); $context = new RequestContext(); @@ -143,7 +143,7 @@ public function testLoggingParameter($parameter, $log, $parameters) $requestMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock(); $requestMatcher->expects($this->once()) ->method('matchRequest') - ->will($this->returnValue($parameter)); + ->willReturn($parameter); $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $logger->expects($this->once()) diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php index f261f2ed15a66..7187c7d1f6251 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php @@ -47,7 +47,7 @@ protected function setUp() $this->session = $this->getSession(); $this->listener->expects($this->any()) ->method('getSession') - ->will($this->returnValue($this->session)); + ->willReturn($this->session); } public function testShouldSaveMasterRequestSession() @@ -183,28 +183,28 @@ private function sessionHasBeenStarted() { $this->session->expects($this->once()) ->method('isStarted') - ->will($this->returnValue(true)); + ->willReturn(true); } private function sessionHasNotBeenStarted() { $this->session->expects($this->once()) ->method('isStarted') - ->will($this->returnValue(false)); + ->willReturn(false); } private function sessionIsEmpty() { $this->session->expects($this->once()) ->method('isEmpty') - ->will($this->returnValue(true)); + ->willReturn(true); } private function fixSessionId($sessionId) { $this->session->expects($this->any()) ->method('getId') - ->will($this->returnValue($sessionId)); + ->willReturn($sessionId); } private function getSession() @@ -214,7 +214,7 @@ private function getSession() ->getMock(); // set return value for getName() - $mock->expects($this->any())->method('getName')->will($this->returnValue('MOCKSESSID')); + $mock->expects($this->any())->method('getName')->willReturn('MOCKSESSID'); return $mock; } diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/TranslatorListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/TranslatorListenerTest.php index c1d56ec85d728..77c2c1c694529 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/TranslatorListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/TranslatorListenerTest.php @@ -113,6 +113,6 @@ private function setMasterRequest($request) $this->requestStack ->expects($this->any()) ->method('getParentRequest') - ->will($this->returnValue($request)); + ->willReturn($request); } } diff --git a/src/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php b/src/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php index 8829393ea4e5c..06ce785ea6094 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php @@ -32,7 +32,7 @@ protected function setUp() $this->requestStack ->expects($this->any()) ->method('getCurrentRequest') - ->will($this->returnValue(Request::create('/'))) + ->willReturn(Request::create('/')) ; } @@ -79,7 +79,7 @@ protected function getHandler($returnValue, $arguments = []) $renderer ->expects($this->any()) ->method('getName') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $e = $renderer ->expects($this->any()) diff --git a/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php b/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php index 11adf74c2931c..b2a2dcaef6305 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php @@ -64,9 +64,9 @@ public function testRenderWithObjectsAsAttributesPassedAsObjectsInTheControllerL $resolver ->expects($this->once()) ->method('getController') - ->will($this->returnValue(function (\stdClass $object, Bar $object1) { + ->willReturn(function (\stdClass $object, Bar $object1) { return new Response($object1->getBar()); - })) + }) ; $kernel = new HttpKernel(new EventDispatcher(), $resolver, new RequestStack()); @@ -85,9 +85,9 @@ public function testRenderWithObjectsAsAttributesPassedAsObjectsInTheController( $resolver ->expects($this->once()) ->method('getController') - ->will($this->returnValue(function (\stdClass $object, Bar $object1) { + ->willReturn(function (\stdClass $object, Bar $object1) { return new Response($object1->getBar()); - })) + }) ; $kernel = new HttpKernel(new EventDispatcher(), $resolver, new RequestStack(), new ArgumentResolver()); @@ -162,18 +162,18 @@ public function testExceptionInSubRequestsDoesNotMangleOutputBuffers() $controllerResolver ->expects($this->once()) ->method('getController') - ->will($this->returnValue(function () { + ->willReturn(function () { ob_start(); echo 'bar'; throw new \RuntimeException(); - })) + }) ; $argumentResolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ArgumentResolverInterface')->getMock(); $argumentResolver ->expects($this->once()) ->method('getArguments') - ->will($this->returnValue([])) + ->willReturn([]) ; $kernel = new HttpKernel(new EventDispatcher(), $controllerResolver, new RequestStack(), $argumentResolver); diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php index ccc3eecfaf8c2..1fc8da8e24530 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php @@ -229,7 +229,7 @@ protected function getCache($request, $response) $cache = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpCache\HttpCache')->setMethods(['getRequest', 'handle'])->disableOriginalConstructor()->getMock(); $cache->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; if (\is_array($response)) { $cache->expects($this->any()) @@ -239,7 +239,7 @@ protected function getCache($request, $response) } else { $cache->expects($this->any()) ->method('handle') - ->will($this->returnValue($response)) + ->willReturn($response) ; } diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/SsiTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/SsiTest.php index 2fc0bb9660dd1..79ed48cd00f7d 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/SsiTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/SsiTest.php @@ -196,7 +196,7 @@ protected function getCache($request, $response) $cache = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpCache\HttpCache')->setMethods(['getRequest', 'handle'])->disableOriginalConstructor()->getMock(); $cache->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; if (\is_array($response)) { $cache->expects($this->any()) @@ -206,7 +206,7 @@ protected function getCache($request, $response) } else { $cache->expects($this->any()) ->method('handle') - ->will($this->returnValue($response)) + ->willReturn($response) ; } diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php index 939ecc0446359..01e32898e2971 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php @@ -363,13 +363,13 @@ private function getHttpKernel(EventDispatcherInterface $eventDispatcher, $contr $controllerResolver ->expects($this->any()) ->method('getController') - ->will($this->returnValue($controller)); + ->willReturn($controller); $argumentResolver = $this->getMockBuilder(ArgumentResolverInterface::class)->getMock(); $argumentResolver ->expects($this->any()) ->method('getArguments') - ->will($this->returnValue($arguments)); + ->willReturn($arguments); return new HttpKernel($eventDispatcher, $controllerResolver, $requestStack, $argumentResolver); } diff --git a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php index 208e11e182d65..04d74ae0a3199 100644 --- a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php @@ -110,7 +110,7 @@ public function testBootSetsTheContainerToTheBundles() $kernel = $this->getKernel(['initializeBundles', 'initializeContainer', 'getBundles']); $kernel->expects($this->once()) ->method('getBundles') - ->will($this->returnValue([$bundle])); + ->willReturn([$bundle]); $kernel->boot(); } @@ -167,16 +167,16 @@ public function testEnvParametersResourceIsAdded() ->getMock(); $kernel->expects($this->any()) ->method('getContainerBuilder') - ->will($this->returnValue($container)); + ->willReturn($container); $kernel->expects($this->any()) ->method('prepareContainer') - ->will($this->returnValue(null)); + ->willReturn(null); $kernel->expects($this->any()) ->method('getCacheDir') - ->will($this->returnValue(sys_get_temp_dir())); + ->willReturn(sys_get_temp_dir()); $kernel->expects($this->any()) ->method('getLogDir') - ->will($this->returnValue(sys_get_temp_dir())); + ->willReturn(sys_get_temp_dir()); $reflection = new \ReflectionClass(\get_class($kernel)); $method = $reflection->getMethod('buildContainer'); @@ -226,7 +226,7 @@ public function testShutdownGivesNullContainerToAllBundles() $kernel = $this->getKernel(['getBundles']); $kernel->expects($this->any()) ->method('getBundles') - ->will($this->returnValue([$bundle])); + ->willReturn([$bundle]); $kernel->boot(); $kernel->shutdown(); @@ -249,7 +249,7 @@ public function testHandleCallsHandleOnHttpKernel() $kernel = $this->getKernel(['getHttpKernel']); $kernel->expects($this->once()) ->method('getHttpKernel') - ->will($this->returnValue($httpKernelMock)); + ->willReturn($httpKernelMock); $kernel->handle($request, $type, $catch); } @@ -267,7 +267,7 @@ public function testHandleBootsTheKernel() $kernel = $this->getKernel(['getHttpKernel', 'boot']); $kernel->expects($this->once()) ->method('getHttpKernel') - ->will($this->returnValue($httpKernelMock)); + ->willReturn($httpKernelMock); $kernel->expects($this->once()) ->method('boot'); @@ -421,7 +421,7 @@ public function testLocateResourceThrowsExceptionWhenResourceDoesNotExist() $kernel ->expects($this->once()) ->method('getBundle') - ->will($this->returnValue([$this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle')])) + ->willReturn([$this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle')]) ; $kernel->locateResource('@Bundle1Bundle/config/routing.xml'); @@ -433,7 +433,7 @@ public function testLocateResourceReturnsTheFirstThatMatches() $kernel ->expects($this->once()) ->method('getBundle') - ->will($this->returnValue([$this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle')])) + ->willReturn([$this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle')]) ; $this->assertEquals(__DIR__.'/Fixtures/Bundle1Bundle/foo.txt', $kernel->locateResource('@Bundle1Bundle/foo.txt')); @@ -451,7 +451,7 @@ public function testLocateResourceReturnsTheFirstThatMatchesWithParent() $kernel ->expects($this->exactly(2)) ->method('getBundle') - ->will($this->returnValue([$child, $parent])) + ->willReturn([$child, $parent]) ; $this->assertEquals(__DIR__.'/Fixtures/Bundle2Bundle/foo.txt', $kernel->locateResource('@ParentAABundle/foo.txt')); @@ -470,7 +470,7 @@ public function testLocateResourceReturnsAllMatches() $kernel ->expects($this->once()) ->method('getBundle') - ->will($this->returnValue([$child, $parent])) + ->willReturn([$child, $parent]) ; $this->assertEquals([ @@ -488,10 +488,10 @@ public function testLocateResourceReturnsAllMatchesBis() $kernel ->expects($this->once()) ->method('getBundle') - ->will($this->returnValue([ + ->willReturn([ $this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle'), $this->getBundle(__DIR__.'/Foobar'), - ])) + ]) ; $this->assertEquals( @@ -506,7 +506,7 @@ public function testLocateResourceIgnoresDirOnNonResource() $kernel ->expects($this->once()) ->method('getBundle') - ->will($this->returnValue([$this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle')])) + ->willReturn([$this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle')]) ; $this->assertEquals( @@ -521,7 +521,7 @@ public function testLocateResourceReturnsTheDirOneForResources() $kernel ->expects($this->once()) ->method('getBundle') - ->will($this->returnValue([$this->getBundle(__DIR__.'/Fixtures/FooBundle', null, null, 'FooBundle')])) + ->willReturn([$this->getBundle(__DIR__.'/Fixtures/FooBundle', null, null, 'FooBundle')]) ; $this->assertEquals( @@ -539,7 +539,7 @@ public function testLocateResourceReturnsTheDirOneForResourcesAndBundleOnes() $kernel ->expects($this->once()) ->method('getBundle') - ->will($this->returnValue([$this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle', null, null, 'Bundle1Bundle')])) + ->willReturn([$this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle', null, null, 'Bundle1Bundle')]) ; $this->assertEquals([ @@ -561,7 +561,7 @@ public function testLocateResourceOverrideBundleAndResourcesFolders() $kernel ->expects($this->exactly(4)) ->method('getBundle') - ->will($this->returnValue([$child, $parent])) + ->willReturn([$child, $parent]) ; $this->assertEquals([ @@ -596,7 +596,7 @@ public function testLocateResourceOnDirectories() $kernel ->expects($this->exactly(2)) ->method('getBundle') - ->will($this->returnValue([$this->getBundle(__DIR__.'/Fixtures/FooBundle', null, null, 'FooBundle')])) + ->willReturn([$this->getBundle(__DIR__.'/Fixtures/FooBundle', null, null, 'FooBundle')]) ; $this->assertEquals( @@ -612,7 +612,7 @@ public function testLocateResourceOnDirectories() $kernel ->expects($this->exactly(2)) ->method('getBundle') - ->will($this->returnValue([$this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle', null, null, 'Bundle1Bundle')])) + ->willReturn([$this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle', null, null, 'Bundle1Bundle')]) ; $this->assertEquals( @@ -638,7 +638,7 @@ public function testInitializeBundles() $kernel ->expects($this->once()) ->method('registerBundles') - ->will($this->returnValue([$parent, $child])) + ->willReturn([$parent, $child]) ; $kernel->boot(); @@ -660,7 +660,7 @@ public function testInitializeBundlesSupportInheritanceCascade() $kernel ->expects($this->once()) ->method('registerBundles') - ->will($this->returnValue([$grandparent, $parent, $child])) + ->willReturn([$grandparent, $parent, $child]) ; $kernel->boot(); @@ -696,7 +696,7 @@ public function testInitializeBundlesSupportsArbitraryBundleRegistrationOrder() $kernel ->expects($this->once()) ->method('registerBundles') - ->will($this->returnValue([$parent, $grandparent, $child])) + ->willReturn([$parent, $grandparent, $child]) ; $kernel->boot(); @@ -785,7 +785,7 @@ public function testTerminateDelegatesTerminationOnlyForTerminableInterface() $kernel = $this->getKernel(['getHttpKernel']); $kernel->expects($this->exactly(2)) ->method('getHttpKernel') - ->will($this->returnValue($httpKernelMock)); + ->willReturn($httpKernelMock); $kernel->boot(); $kernel->terminate(Request::create('/'), new Response()); @@ -938,19 +938,19 @@ protected function getBundle($dir = null, $parent = null, $className = null, $bu $bundle ->expects($this->any()) ->method('getName') - ->will($this->returnValue(null === $bundleName ? \get_class($bundle) : $bundleName)) + ->willReturn(null === $bundleName ? \get_class($bundle) : $bundleName) ; $bundle ->expects($this->any()) ->method('getPath') - ->will($this->returnValue($dir)) + ->willReturn($dir) ; $bundle ->expects($this->any()) ->method('getParent') - ->will($this->returnValue($parent)) + ->willReturn($parent) ; return $bundle; @@ -976,7 +976,7 @@ protected function getKernel(array $methods = [], array $bundles = []) ; $kernel->expects($this->any()) ->method('registerBundles') - ->will($this->returnValue($bundles)) + ->willReturn($bundles) ; $p = new \ReflectionProperty($kernel, 'rootDir'); $p->setAccessible(true); diff --git a/src/Symfony/Component/HttpKernel/Tests/Log/LoggerTest.php b/src/Symfony/Component/HttpKernel/Tests/Log/LoggerTest.php index 17865203f2c96..3a5a8ade54156 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Log/LoggerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Log/LoggerTest.php @@ -149,7 +149,7 @@ public function testObjectCastToString() } $dummy->expects($this->atLeastOnce()) ->method('__toString') - ->will($this->returnValue('DUMMY')); + ->willReturn('DUMMY'); $this->logger->warning($dummy); diff --git a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/BundleEntryReaderTest.php b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/BundleEntryReaderTest.php index 766611ed027d6..3357b039ea814 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/BundleEntryReaderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/BundleEntryReaderTest.php @@ -72,7 +72,7 @@ public function testForwardCallToRead() $this->readerImpl->expects($this->once()) ->method('read') ->with(self::RES_DIR, 'root') - ->will($this->returnValue(self::$data)); + ->willReturn(self::$data); $this->assertSame(self::$data, $this->reader->read(self::RES_DIR, 'root')); } @@ -82,12 +82,12 @@ public function testReadEntireDataFileIfNoIndicesGiven() $this->readerImpl->expects($this->at(0)) ->method('read') ->with(self::RES_DIR, 'en') - ->will($this->returnValue(self::$data)); + ->willReturn(self::$data); $this->readerImpl->expects($this->at(1)) ->method('read') ->with(self::RES_DIR, 'root') - ->will($this->returnValue(self::$fallbackData)); + ->willReturn(self::$fallbackData); $this->assertSame(self::$mergedData, $this->reader->readEntry(self::RES_DIR, 'en', [])); } @@ -97,7 +97,7 @@ public function testReadExistingEntry() $this->readerImpl->expects($this->once()) ->method('read') ->with(self::RES_DIR, 'root') - ->will($this->returnValue(self::$data)); + ->willReturn(self::$data); $this->assertSame('Bar', $this->reader->readEntry(self::RES_DIR, 'root', ['Entries', 'Foo'])); } @@ -110,7 +110,7 @@ public function testReadNonExistingEntry() $this->readerImpl->expects($this->once()) ->method('read') ->with(self::RES_DIR, 'root') - ->will($this->returnValue(self::$data)); + ->willReturn(self::$data); $this->reader->readEntry(self::RES_DIR, 'root', ['Entries', 'NonExisting']); } @@ -120,12 +120,12 @@ public function testFallbackIfEntryDoesNotExist() $this->readerImpl->expects($this->at(0)) ->method('read') ->with(self::RES_DIR, 'en_GB') - ->will($this->returnValue(self::$data)); + ->willReturn(self::$data); $this->readerImpl->expects($this->at(1)) ->method('read') ->with(self::RES_DIR, 'en') - ->will($this->returnValue(self::$fallbackData)); + ->willReturn(self::$fallbackData); $this->assertSame('Lah', $this->reader->readEntry(self::RES_DIR, 'en_GB', ['Entries', 'Bam'])); } @@ -138,7 +138,7 @@ public function testDontFallbackIfEntryDoesNotExistAndFallbackDisabled() $this->readerImpl->expects($this->once()) ->method('read') ->with(self::RES_DIR, 'en_GB') - ->will($this->returnValue(self::$data)); + ->willReturn(self::$data); $this->reader->readEntry(self::RES_DIR, 'en_GB', ['Entries', 'Bam'], false); } @@ -153,7 +153,7 @@ public function testFallbackIfLocaleDoesNotExist() $this->readerImpl->expects($this->at(1)) ->method('read') ->with(self::RES_DIR, 'en') - ->will($this->returnValue(self::$fallbackData)); + ->willReturn(self::$fallbackData); $this->assertSame('Lah', $this->reader->readEntry(self::RES_DIR, 'en_GB', ['Entries', 'Bam'])); } @@ -193,17 +193,17 @@ public function testMergeDataWithFallbackData($childData, $parentData, $result) $this->readerImpl->expects($this->at(0)) ->method('read') ->with(self::RES_DIR, 'en') - ->will($this->returnValue($childData)); + ->willReturn($childData); $this->readerImpl->expects($this->at(1)) ->method('read') ->with(self::RES_DIR, 'root') - ->will($this->returnValue($parentData)); + ->willReturn($parentData); } else { $this->readerImpl->expects($this->once()) ->method('read') ->with(self::RES_DIR, 'en') - ->will($this->returnValue($childData)); + ->willReturn($childData); } $this->assertSame($result, $this->reader->readEntry(self::RES_DIR, 'en', [], true)); @@ -217,7 +217,7 @@ public function testDontMergeDataIfFallbackDisabled($childData, $parentData, $re $this->readerImpl->expects($this->once()) ->method('read') ->with(self::RES_DIR, 'en_GB') - ->will($this->returnValue($childData)); + ->willReturn($childData); $this->assertSame($childData, $this->reader->readEntry(self::RES_DIR, 'en_GB', [], false)); } @@ -231,17 +231,17 @@ public function testMergeExistingEntryWithExistingFallbackEntry($childData, $par $this->readerImpl->expects($this->at(0)) ->method('read') ->with(self::RES_DIR, 'en') - ->will($this->returnValue(['Foo' => ['Bar' => $childData]])); + ->willReturn(['Foo' => ['Bar' => $childData]]); $this->readerImpl->expects($this->at(1)) ->method('read') ->with(self::RES_DIR, 'root') - ->will($this->returnValue(['Foo' => ['Bar' => $parentData]])); + ->willReturn(['Foo' => ['Bar' => $parentData]]); } else { $this->readerImpl->expects($this->once()) ->method('read') ->with(self::RES_DIR, 'en') - ->will($this->returnValue(['Foo' => ['Bar' => $childData]])); + ->willReturn(['Foo' => ['Bar' => $childData]]); } $this->assertSame($result, $this->reader->readEntry(self::RES_DIR, 'en', ['Foo', 'Bar'], true)); @@ -255,12 +255,12 @@ public function testMergeNonExistingEntryWithExistingFallbackEntry($childData, $ $this->readerImpl->expects($this->at(0)) ->method('read') ->with(self::RES_DIR, 'en_GB') - ->will($this->returnValue(['Foo' => 'Baz'])); + ->willReturn(['Foo' => 'Baz']); $this->readerImpl->expects($this->at(1)) ->method('read') ->with(self::RES_DIR, 'en') - ->will($this->returnValue(['Foo' => ['Bar' => $parentData]])); + ->willReturn(['Foo' => ['Bar' => $parentData]]); $this->assertSame($parentData, $this->reader->readEntry(self::RES_DIR, 'en_GB', ['Foo', 'Bar'], true)); } @@ -274,17 +274,17 @@ public function testMergeExistingEntryWithNonExistingFallbackEntry($childData, $ $this->readerImpl->expects($this->at(0)) ->method('read') ->with(self::RES_DIR, 'en_GB') - ->will($this->returnValue(['Foo' => ['Bar' => $childData]])); + ->willReturn(['Foo' => ['Bar' => $childData]]); $this->readerImpl->expects($this->at(1)) ->method('read') ->with(self::RES_DIR, 'en') - ->will($this->returnValue(['Foo' => 'Bar'])); + ->willReturn(['Foo' => 'Bar']); } else { $this->readerImpl->expects($this->once()) ->method('read') ->with(self::RES_DIR, 'en_GB') - ->will($this->returnValue(['Foo' => ['Bar' => $childData]])); + ->willReturn(['Foo' => ['Bar' => $childData]]); } $this->assertSame($childData, $this->reader->readEntry(self::RES_DIR, 'en_GB', ['Foo', 'Bar'], true)); @@ -298,12 +298,12 @@ public function testFailIfEntryFoundNeitherInParentNorChild() $this->readerImpl->expects($this->at(0)) ->method('read') ->with(self::RES_DIR, 'en_GB') - ->will($this->returnValue(['Foo' => 'Baz'])); + ->willReturn(['Foo' => 'Baz']); $this->readerImpl->expects($this->at(1)) ->method('read') ->with(self::RES_DIR, 'en') - ->will($this->returnValue(['Foo' => 'Bar'])); + ->willReturn(['Foo' => 'Bar']); $this->reader->readEntry(self::RES_DIR, 'en_GB', ['Foo', 'Bar'], true); } @@ -320,17 +320,17 @@ public function testMergeTraversables($childData, $parentData, $result) $this->readerImpl->expects($this->at(0)) ->method('read') ->with(self::RES_DIR, 'en_GB') - ->will($this->returnValue(['Foo' => ['Bar' => $childData]])); + ->willReturn(['Foo' => ['Bar' => $childData]]); $this->readerImpl->expects($this->at(1)) ->method('read') ->with(self::RES_DIR, 'en') - ->will($this->returnValue(['Foo' => ['Bar' => $parentData]])); + ->willReturn(['Foo' => ['Bar' => $parentData]]); } else { $this->readerImpl->expects($this->once()) ->method('read') ->with(self::RES_DIR, 'en_GB') - ->will($this->returnValue(['Foo' => ['Bar' => $childData]])); + ->willReturn(['Foo' => ['Bar' => $childData]]); } $this->assertSame($result, $this->reader->readEntry(self::RES_DIR, 'en_GB', ['Foo', 'Bar'], true)); @@ -347,18 +347,18 @@ public function testFollowLocaleAliases($childData, $parentData, $result) $this->readerImpl->expects($this->at(0)) ->method('read') ->with(self::RES_DIR, 'ro_MD') - ->will($this->returnValue(['Foo' => ['Bar' => $childData]])); + ->willReturn(['Foo' => ['Bar' => $childData]]); // Read fallback locale of aliased locale ("ro_MD" -> "ro") $this->readerImpl->expects($this->at(1)) ->method('read') ->with(self::RES_DIR, 'ro') - ->will($this->returnValue(['Foo' => ['Bar' => $parentData]])); + ->willReturn(['Foo' => ['Bar' => $parentData]]); } else { $this->readerImpl->expects($this->once()) ->method('read') ->with(self::RES_DIR, 'ro_MD') - ->will($this->returnValue(['Foo' => ['Bar' => $childData]])); + ->willReturn(['Foo' => ['Bar' => $childData]]); } $this->assertSame($result, $this->reader->readEntry(self::RES_DIR, 'mo', ['Foo', 'Bar'], true)); diff --git a/src/Symfony/Component/Ldap/Tests/LdapClientTest.php b/src/Symfony/Component/Ldap/Tests/LdapClientTest.php index 63b3379d25e13..95373e92b14e7 100644 --- a/src/Symfony/Component/Ldap/Tests/LdapClientTest.php +++ b/src/Symfony/Component/Ldap/Tests/LdapClientTest.php @@ -70,7 +70,7 @@ public function testLdapFind() $collection ->expects($this->once()) ->method('getIterator') - ->will($this->returnValue(new \ArrayIterator([ + ->willReturn(new \ArrayIterator([ new Entry('cn=qux,dc=foo,dc=com', [ 'cn' => ['qux'], 'dc' => ['com', 'foo'], @@ -81,13 +81,13 @@ public function testLdapFind() 'dc' => ['com', 'foo'], 'givenName' => ['Baz'], ]), - ]))) + ])) ; $query = $this->getMockBuilder(QueryInterface::class)->getMock(); $query ->expects($this->once()) ->method('execute') - ->will($this->returnValue($collection)) + ->willReturn($collection) ; $this->ldap ->expects($this->once()) diff --git a/src/Symfony/Component/Ldap/Tests/LdapTest.php b/src/Symfony/Component/Ldap/Tests/LdapTest.php index acc845222587a..0d6961c267ac1 100644 --- a/src/Symfony/Component/Ldap/Tests/LdapTest.php +++ b/src/Symfony/Component/Ldap/Tests/LdapTest.php @@ -42,7 +42,7 @@ public function testLdapBind() $this->adapter ->expects($this->once()) ->method('getConnection') - ->will($this->returnValue($connection)) + ->willReturn($connection) ; $this->ldap->bind('foo', 'bar'); } diff --git a/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php b/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php index 4b0376ff4ef5f..ff0ea508e50f0 100644 --- a/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php @@ -27,7 +27,7 @@ public function testProcessFailedExceptionThrowsException() $process = $this->getMockBuilder('Symfony\Component\Process\Process')->setMethods(['isSuccessful'])->setConstructorArgs(['php'])->getMock(); $process->expects($this->once()) ->method('isSuccessful') - ->will($this->returnValue(true)); + ->willReturn(true); if (method_exists($this, 'expectException')) { $this->expectException(\InvalidArgumentException::class); @@ -55,31 +55,31 @@ public function testProcessFailedExceptionPopulatesInformationFromProcessOutput( $process = $this->getMockBuilder('Symfony\Component\Process\Process')->setMethods(['isSuccessful', 'getOutput', 'getErrorOutput', 'getExitCode', 'getExitCodeText', 'isOutputDisabled', 'getWorkingDirectory'])->setConstructorArgs([$cmd])->getMock(); $process->expects($this->once()) ->method('isSuccessful') - ->will($this->returnValue(false)); + ->willReturn(false); $process->expects($this->once()) ->method('getOutput') - ->will($this->returnValue($output)); + ->willReturn($output); $process->expects($this->once()) ->method('getErrorOutput') - ->will($this->returnValue($errorOutput)); + ->willReturn($errorOutput); $process->expects($this->once()) ->method('getExitCode') - ->will($this->returnValue($exitCode)); + ->willReturn($exitCode); $process->expects($this->once()) ->method('getExitCodeText') - ->will($this->returnValue($exitText)); + ->willReturn($exitText); $process->expects($this->once()) ->method('isOutputDisabled') - ->will($this->returnValue(false)); + ->willReturn(false); $process->expects($this->once()) ->method('getWorkingDirectory') - ->will($this->returnValue($workingDirectory)); + ->willReturn($workingDirectory); $exception = new ProcessFailedException($process); @@ -103,7 +103,7 @@ public function testDisabledOutputInFailedExceptionDoesNotPopulateOutput() $process = $this->getMockBuilder('Symfony\Component\Process\Process')->setMethods(['isSuccessful', 'isOutputDisabled', 'getExitCode', 'getExitCodeText', 'getOutput', 'getErrorOutput', 'getWorkingDirectory'])->setConstructorArgs([$cmd])->getMock(); $process->expects($this->once()) ->method('isSuccessful') - ->will($this->returnValue(false)); + ->willReturn(false); $process->expects($this->never()) ->method('getOutput'); @@ -113,19 +113,19 @@ public function testDisabledOutputInFailedExceptionDoesNotPopulateOutput() $process->expects($this->once()) ->method('getExitCode') - ->will($this->returnValue($exitCode)); + ->willReturn($exitCode); $process->expects($this->once()) ->method('getExitCodeText') - ->will($this->returnValue($exitText)); + ->willReturn($exitText); $process->expects($this->once()) ->method('isOutputDisabled') - ->will($this->returnValue(true)); + ->willReturn(true); $process->expects($this->once()) ->method('getWorkingDirectory') - ->will($this->returnValue($workingDirectory)); + ->willReturn($workingDirectory); $exception = new ProcessFailedException($process); diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php index 1aee259a76c8f..b91d1e62ebb95 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php @@ -128,11 +128,11 @@ public function testSetValueCallsAdderAndRemoverForNestedCollections() $car->expects($this->any()) ->method('getStructure') - ->will($this->returnValue($structure)); + ->willReturn($structure); $structure->expects($this->at(0)) ->method('getAxes') - ->will($this->returnValue($axesBefore)); + ->willReturn($axesBefore); $structure->expects($this->at(1)) ->method('removeAxis') ->with('fourth'); @@ -158,7 +158,7 @@ public function testSetValueFailsIfNoAdderNorRemoverFound() $car->expects($this->any()) ->method('getAxes') - ->will($this->returnValue($axesBefore)); + ->willReturn($axesBefore); $this->propertyAccessor->setValue($car, 'axes', $axesAfter); } diff --git a/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php index 657f361b4035b..7726dc6fa89f1 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php @@ -119,7 +119,7 @@ public function testLoad($className, $routeData = [], $methodArgs = []) $this->reader ->expects($this->once()) ->method('getMethodAnnotations') - ->will($this->returnValue([$this->getAnnotatedRoute($routeData)])) + ->willReturn([$this->getAnnotatedRoute($routeData)]) ; $routeCollection = $this->loader->load($className); @@ -165,12 +165,12 @@ public function testClassRouteLoad() $this->reader ->expects($this->once()) ->method('getClassAnnotation') - ->will($this->returnValue($this->getAnnotatedRoute($classRouteData))) + ->willReturn($this->getAnnotatedRoute($classRouteData)) ; $this->reader ->expects($this->once()) ->method('getMethodAnnotations') - ->will($this->returnValue([$this->getAnnotatedRoute($methodRouteData)])) + ->willReturn([$this->getAnnotatedRoute($methodRouteData)]) ; $routeCollection = $this->loader->load('Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass'); @@ -193,12 +193,12 @@ public function testInvokableClassRouteLoadWithMethodAnnotation() $this->reader ->expects($this->exactly(1)) ->method('getClassAnnotations') - ->will($this->returnValue([$this->getAnnotatedRoute($classRouteData)])) + ->willReturn([$this->getAnnotatedRoute($classRouteData)]) ; $this->reader ->expects($this->once()) ->method('getMethodAnnotations') - ->will($this->returnValue([])) + ->willReturn([]) ; $routeCollection = $this->loader->load('Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BazClass'); @@ -221,19 +221,19 @@ public function testInvokableClassRouteLoadWithClassAnnotation() $this->reader ->expects($this->exactly(1)) ->method('getClassAnnotation') - ->will($this->returnValue($this->getAnnotatedRoute($classRouteData))) + ->willReturn($this->getAnnotatedRoute($classRouteData)) ; $this->reader ->expects($this->exactly(1)) ->method('getClassAnnotations') - ->will($this->returnValue([$this->getAnnotatedRoute($classRouteData)])) + ->willReturn([$this->getAnnotatedRoute($classRouteData)]) ; $this->reader ->expects($this->once()) ->method('getMethodAnnotations') - ->will($this->returnValue([])) + ->willReturn([]) ; $routeCollection = $this->loader->load('Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BazClass'); @@ -263,12 +263,12 @@ public function testInvokableClassMultipleRouteLoad() $this->reader ->expects($this->exactly(1)) ->method('getClassAnnotations') - ->will($this->returnValue([$this->getAnnotatedRoute($classRouteData1), $this->getAnnotatedRoute($classRouteData2)])) + ->willReturn([$this->getAnnotatedRoute($classRouteData1), $this->getAnnotatedRoute($classRouteData2)]) ; $this->reader ->expects($this->once()) ->method('getMethodAnnotations') - ->will($this->returnValue([])) + ->willReturn([]) ; $routeCollection = $this->loader->load('Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BazClass'); @@ -304,12 +304,12 @@ public function testInvokableClassWithMethodRouteLoad() $this->reader ->expects($this->once()) ->method('getClassAnnotation') - ->will($this->returnValue($this->getAnnotatedRoute($classRouteData))) + ->willReturn($this->getAnnotatedRoute($classRouteData)) ; $this->reader ->expects($this->once()) ->method('getMethodAnnotations') - ->will($this->returnValue([$this->getAnnotatedRoute($methodRouteData)])) + ->willReturn([$this->getAnnotatedRoute($methodRouteData)]) ; $routeCollection = $this->loader->load('Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BazClass'); @@ -336,7 +336,7 @@ public function testDefaultRouteName() $this->reader ->expects($this->once()) ->method('getMethodAnnotations') - ->will($this->returnValue([$this->getAnnotatedRoute($methodRouteData)])) + ->willReturn([$this->getAnnotatedRoute($methodRouteData)]) ; $routeCollection = $this->loader->load('Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\EncodingClass'); diff --git a/src/Symfony/Component/Routing/Tests/Loader/AnnotationDirectoryLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/AnnotationDirectoryLoaderTest.php index 9465ef05df23c..df96a679e40f9 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/AnnotationDirectoryLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/AnnotationDirectoryLoaderTest.php @@ -34,13 +34,13 @@ public function testLoad() $this->reader ->expects($this->any()) ->method('getMethodAnnotations') - ->will($this->returnValue([])) + ->willReturn([]) ; $this->reader ->expects($this->any()) ->method('getClassAnnotations') - ->will($this->returnValue([])) + ->willReturn([]) ; $this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses'); @@ -58,13 +58,13 @@ public function testLoadIgnoresHiddenDirectories() $this->reader ->expects($this->any()) ->method('getMethodAnnotations') - ->will($this->returnValue([])) + ->willReturn([]) ; $this->reader ->expects($this->any()) ->method('getClassAnnotations') - ->will($this->returnValue([])) + ->willReturn([]) ; $this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses'); @@ -93,7 +93,7 @@ public function testLoadFileIfLocatedResourceIsFile() $this->reader ->expects($this->any()) ->method('getMethodAnnotations') - ->will($this->returnValue([])) + ->willReturn([]) ; $this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/FooClass.php'); diff --git a/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php index 43eb44e48df9e..066b7c45f54e3 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php @@ -62,7 +62,7 @@ public function testLoadVariadic() $route = new Route(['path' => '/path/to/{id}']); $this->reader->expects($this->once())->method('getClassAnnotation'); $this->reader->expects($this->once())->method('getMethodAnnotations') - ->will($this->returnValue([$route])); + ->willReturn([$route]); $this->loader->load(__DIR__.'/../Fixtures/OtherAnnotatedClasses/VariadicClass.php'); } diff --git a/src/Symfony/Component/Routing/Tests/Loader/ObjectRouteLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/ObjectRouteLoaderTest.php index 89dcd5ba3f11d..774e1a1fe5752 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/ObjectRouteLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/ObjectRouteLoaderTest.php @@ -89,7 +89,7 @@ public function testExceptionOnMethodNotReturningCollection() ->getMock(); $service->expects($this->once()) ->method('loadRoutes') - ->will($this->returnValue('NOT_A_COLLECTION')); + ->willReturn('NOT_A_COLLECTION'); $loader = new ObjectRouteLoaderForTest(); $loader->loaderMap = ['my_service' => $service]; diff --git a/src/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php b/src/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php index e4336cdcac6c5..b14fe98d4d4d5 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php @@ -23,7 +23,7 @@ public function testMissingTrailingSlash() $coll->add('foo', new Route('/foo/')); $matcher = $this->getUrlMatcher($coll); - $matcher->expects($this->once())->method('redirect')->will($this->returnValue([])); + $matcher->expects($this->once())->method('redirect')->willReturn([]); $matcher->match('/foo'); } @@ -51,7 +51,7 @@ public function testSchemeRedirectRedirectsToFirstScheme() ->expects($this->once()) ->method('redirect') ->with('/foo', 'foo', 'ftp') - ->will($this->returnValue(['_route' => 'foo'])) + ->willReturn(['_route' => 'foo']) ; $matcher->match('/foo'); } @@ -78,7 +78,7 @@ public function testSchemeRedirectWithParams() ->expects($this->once()) ->method('redirect') ->with('/foo/baz', 'foo', 'https') - ->will($this->returnValue(['redirect' => 'value'])) + ->willReturn(['redirect' => 'value']) ; $this->assertEquals(['_route' => 'foo', 'bar' => 'baz', 'redirect' => 'value'], $matcher->match('/foo/baz')); } @@ -93,7 +93,7 @@ public function testSlashRedirectWithParams() ->expects($this->once()) ->method('redirect') ->with('/foo/baz/', 'foo', null) - ->will($this->returnValue(['redirect' => 'value'])) + ->willReturn(['redirect' => 'value']) ; $this->assertEquals(['_route' => 'foo', 'bar' => 'baz', 'redirect' => 'value'], $matcher->match('/foo/baz')); } @@ -124,7 +124,7 @@ public function testFallbackPage() $coll->add('bar', new Route('/{name}')); $matcher = $this->getUrlMatcher($coll); - $matcher->expects($this->once())->method('redirect')->with('/foo/')->will($this->returnValue(['_route' => 'foo'])); + $matcher->expects($this->once())->method('redirect')->with('/foo/')->willReturn(['_route' => 'foo']); $this->assertSame(['_route' => 'foo'], $matcher->match('/foo')); } diff --git a/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php b/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php index 20afdff484f8a..11d9453e09093 100644 --- a/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php +++ b/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php @@ -28,7 +28,7 @@ public function testImport() $resolver->expects($this->once()) ->method('resolve') ->with('admin_routing.yml', 'yaml') - ->will($this->returnValue($resolvedLoader)); + ->willReturn($resolvedLoader); $originalRoute = new Route('/foo/path'); $expectedCollection = new RouteCollection(); @@ -39,12 +39,12 @@ public function testImport() ->expects($this->once()) ->method('load') ->with('admin_routing.yml', 'yaml') - ->will($this->returnValue($expectedCollection)); + ->willReturn($expectedCollection); $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $loader->expects($this->any()) ->method('getResolver') - ->will($this->returnValue($resolver)); + ->willReturn($resolver); // import the file! $routes = new RouteCollectionBuilder($loader); @@ -107,11 +107,11 @@ public function testFlushOrdering() // make this loader able to do the import - keeps mocking simple $loader->expects($this->any()) ->method('supports') - ->will($this->returnValue(true)); + ->willReturn(true); $loader ->expects($this->once()) ->method('load') - ->will($this->returnValue($importedCollection)); + ->willReturn($importedCollection); $routes = new RouteCollectionBuilder($loader); @@ -296,11 +296,11 @@ public function testFlushSetsPrefixedWithMultipleLevels() // make this loader able to do the import - keeps mocking simple $loader->expects($this->any()) ->method('supports') - ->will($this->returnValue(true)); + ->willReturn(true); $loader ->expects($this->any()) ->method('load') - ->will($this->returnValue($importedCollection)); + ->willReturn($importedCollection); // import this from the /admin route builder $adminRoutes->import('admin.yml', '/imported'); @@ -347,11 +347,11 @@ public function testAddsThePrefixOnlyOnceWhenLoadingMultipleCollections() $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(); $loader->expects($this->any()) ->method('supports') - ->will($this->returnValue(true)); + ->willReturn(true); $loader ->expects($this->any()) ->method('load') - ->will($this->returnValue([$firstCollection, $secondCollection])); + ->willReturn([$firstCollection, $secondCollection]); $routeCollectionBuilder = new RouteCollectionBuilder($loader); $routeCollectionBuilder->import('/directory/recurse/*', '/other/', 'glob'); diff --git a/src/Symfony/Component/Routing/Tests/RouterTest.php b/src/Symfony/Component/Routing/Tests/RouterTest.php index 589ce5403ac2b..0f46e5317b68c 100644 --- a/src/Symfony/Component/Routing/Tests/RouterTest.php +++ b/src/Symfony/Component/Routing/Tests/RouterTest.php @@ -88,7 +88,7 @@ public function testThatRouteCollectionIsLoaded() $this->loader->expects($this->once()) ->method('load')->with('routing.yml', 'ResourceType') - ->will($this->returnValue($routeCollection)); + ->willReturn($routeCollection); $this->assertSame($routeCollection, $this->router->getRouteCollection()); } @@ -102,7 +102,7 @@ public function testMatcherIsCreatedIfCacheIsNotConfigured($option) $this->loader->expects($this->once()) ->method('load')->with('routing.yml', null) - ->will($this->returnValue(new RouteCollection())); + ->willReturn(new RouteCollection()); $this->assertInstanceOf('Symfony\\Component\\Routing\\Matcher\\UrlMatcher', $this->router->getMatcher()); } @@ -124,7 +124,7 @@ public function testGeneratorIsCreatedIfCacheIsNotConfigured($option) $this->loader->expects($this->once()) ->method('load')->with('routing.yml', null) - ->will($this->returnValue(new RouteCollection())); + ->willReturn(new RouteCollection()); $this->assertInstanceOf('Symfony\\Component\\Routing\\Generator\\UrlGenerator', $this->router->getGenerator()); } diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationProviderManagerTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationProviderManagerTest.php index fd2de0ca25d4e..379da4bb61329 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationProviderManagerTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationProviderManagerTest.php @@ -177,13 +177,13 @@ protected function getAuthenticationProvider($supports, $token = null, $exceptio $provider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface')->getMock(); $provider->expects($this->once()) ->method('supports') - ->will($this->returnValue($supports)) + ->willReturn($supports) ; if (null !== $token) { $provider->expects($this->once()) ->method('authenticate') - ->will($this->returnValue($token)) + ->willReturn($token) ; } elseif (null !== $exception) { $provider->expects($this->once()) diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php index 92441ba5fc617..a888d2bf81b9d 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php @@ -58,7 +58,7 @@ protected function getSupportedToken($secret) $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken')->setMethods(['getSecret'])->disableOriginalConstructor()->getMock(); $token->expects($this->any()) ->method('getSecret') - ->will($this->returnValue($secret)) + ->willReturn($secret) ; return $token; diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php index 55814a994c577..53ff170554222 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php @@ -77,7 +77,7 @@ public function testRetrieveUserReturnsUserFromTokenOnReauthentication() $token = $this->getSupportedToken(); $token->expects($this->once()) ->method('getUser') - ->will($this->returnValue($user)) + ->willReturn($user) ; $provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock()); @@ -95,7 +95,7 @@ public function testRetrieveUser() $userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock(); $userProvider->expects($this->once()) ->method('loadUserByUsername') - ->will($this->returnValue($user)) + ->willReturn($user) ; $provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock()); @@ -124,7 +124,7 @@ public function testCheckAuthenticationWhenCredentialsAreEmpty() $token ->expects($this->once()) ->method('getCredentials') - ->will($this->returnValue('')) + ->willReturn('') ; $method->invoke( @@ -140,7 +140,7 @@ public function testCheckAuthenticationWhenCredentialsAre0() $encoder ->expects($this->once()) ->method('isPasswordValid') - ->will($this->returnValue(true)) + ->willReturn(true) ; $provider = $this->getProvider(null, null, $encoder); @@ -151,7 +151,7 @@ public function testCheckAuthenticationWhenCredentialsAre0() $token ->expects($this->once()) ->method('getCredentials') - ->will($this->returnValue('0')) + ->willReturn('0') ; $method->invoke( @@ -169,7 +169,7 @@ public function testCheckAuthenticationWhenCredentialsAreNotValid() $encoder = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface')->getMock(); $encoder->expects($this->once()) ->method('isPasswordValid') - ->will($this->returnValue(false)) + ->willReturn(false) ; $provider = $this->getProvider(null, null, $encoder); @@ -179,7 +179,7 @@ public function testCheckAuthenticationWhenCredentialsAreNotValid() $token = $this->getSupportedToken(); $token->expects($this->once()) ->method('getCredentials') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $method->invoke($provider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(), $token); @@ -193,18 +193,18 @@ public function testCheckAuthenticationDoesNotReauthenticateWhenPasswordHasChang $user = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(); $user->expects($this->once()) ->method('getPassword') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $token = $this->getSupportedToken(); $token->expects($this->once()) ->method('getUser') - ->will($this->returnValue($user)); + ->willReturn($user); $dbUser = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(); $dbUser->expects($this->once()) ->method('getPassword') - ->will($this->returnValue('newFoo')) + ->willReturn('newFoo') ; $provider = $this->getProvider(); @@ -218,18 +218,18 @@ public function testCheckAuthenticationWhenTokenNeedsReauthenticationWorksWithou $user = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(); $user->expects($this->once()) ->method('getPassword') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $token = $this->getSupportedToken(); $token->expects($this->once()) ->method('getUser') - ->will($this->returnValue($user)); + ->willReturn($user); $dbUser = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(); $dbUser->expects($this->once()) ->method('getPassword') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $provider = $this->getProvider(); @@ -243,7 +243,7 @@ public function testCheckAuthentication() $encoder = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface')->getMock(); $encoder->expects($this->once()) ->method('isPasswordValid') - ->will($this->returnValue(true)) + ->willReturn(true) ; $provider = $this->getProvider(null, null, $encoder); @@ -253,7 +253,7 @@ public function testCheckAuthentication() $token = $this->getSupportedToken(); $token->expects($this->once()) ->method('getCredentials') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $method->invoke($provider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(), $token); @@ -265,7 +265,7 @@ protected function getSupportedToken() $mock ->expects($this->any()) ->method('getProviderKey') - ->will($this->returnValue('key')) + ->willReturn('key') ; return $mock; @@ -277,7 +277,7 @@ protected function getProvider($user = null, $userChecker = null, $passwordEncod if (null !== $user) { $userProvider->expects($this->once()) ->method('loadUserByUsername') - ->will($this->returnValue($user)) + ->willReturn($user) ; } @@ -293,7 +293,7 @@ protected function getProvider($user = null, $userChecker = null, $passwordEncod $encoderFactory ->expects($this->any()) ->method('getEncoder') - ->will($this->returnValue($passwordEncoder)) + ->willReturn($passwordEncoder) ; return new DaoAuthenticationProvider($userProvider, $userChecker, 'key', $encoderFactory); diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php index ef19bc2c32739..bad3072f4a9af 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php @@ -113,7 +113,7 @@ public function testQueryForDn() $query ->expects($this->once()) ->method('execute') - ->will($this->returnValue($collection)) + ->willReturn($collection) ; $ldap = $this->getMockBuilder(LdapInterface::class)->getMock(); @@ -121,13 +121,13 @@ public function testQueryForDn() ->expects($this->once()) ->method('escape') ->with('foo', '') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $ldap ->expects($this->once()) ->method('query') ->with('{username}', 'foobar') - ->will($this->returnValue($query)) + ->willReturn($query) ; $userChecker = $this->getMockBuilder(UserCheckerInterface::class)->getMock(); @@ -153,14 +153,14 @@ public function testEmptyQueryResultShouldThrowAnException() $query ->expects($this->once()) ->method('execute') - ->will($this->returnValue($collection)) + ->willReturn($collection) ; $ldap = $this->getMockBuilder(LdapInterface::class)->getMock(); $ldap ->expects($this->once()) ->method('query') - ->will($this->returnValue($query)) + ->willReturn($query) ; $userChecker = $this->getMockBuilder(UserCheckerInterface::class)->getMock(); diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php index a101208d681cc..57bce20f5b20c 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php @@ -31,7 +31,7 @@ public function testSupports() $token ->expects($this->once()) ->method('getProviderKey') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $this->assertFalse($provider->supports($token)); } @@ -62,7 +62,7 @@ public function testAuthenticate() $user ->expects($this->once()) ->method('getRoles') - ->will($this->returnValue([])) + ->willReturn([]) ; $provider = $this->getProvider($user); @@ -99,20 +99,20 @@ protected function getSupportedToken($user = false, $credentials = false) if (false !== $user) { $token->expects($this->once()) ->method('getUser') - ->will($this->returnValue($user)) + ->willReturn($user) ; } if (false !== $credentials) { $token->expects($this->once()) ->method('getCredentials') - ->will($this->returnValue($credentials)) + ->willReturn($credentials) ; } $token ->expects($this->any()) ->method('getProviderKey') - ->will($this->returnValue('key')) + ->willReturn('key') ; $token->setAttributes(['foo' => 'bar']); @@ -126,7 +126,7 @@ protected function getProvider($user = null, $userChecker = null) if (null !== $user) { $userProvider->expects($this->once()) ->method('loadUserByUsername') - ->will($this->returnValue($user)) + ->willReturn($user) ; } diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php index 26287693d6b08..6ac7438a064a2 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php @@ -69,7 +69,7 @@ public function testAuthenticate() $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user->expects($this->exactly(2)) ->method('getRoles') - ->will($this->returnValue(['ROLE_FOO'])); + ->willReturn(['ROLE_FOO']); $provider = $this->getProvider(); @@ -89,14 +89,14 @@ protected function getSupportedToken($user = null, $secret = 'test') $user ->expects($this->any()) ->method('getRoles') - ->will($this->returnValue([])); + ->willReturn([]); } $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken')->setMethods(['getProviderKey'])->setConstructorArgs([$user, 'foo', $secret])->getMock(); $token ->expects($this->once()) ->method('getProviderKey') - ->will($this->returnValue('foo')); + ->willReturn('foo'); return $token; } diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/SimpleAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/SimpleAuthenticationProviderTest.php index 661d23a4e7e21..07c1618f214dd 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/SimpleAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/SimpleAuthenticationProviderTest.php @@ -29,7 +29,7 @@ public function testAuthenticateWhenPreChecksFails() $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token->expects($this->any()) ->method('getUser') - ->will($this->returnValue($user)); + ->willReturn($user); $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); $userChecker->expects($this->once()) @@ -39,7 +39,7 @@ public function testAuthenticateWhenPreChecksFails() $authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock(); $authenticator->expects($this->once()) ->method('authenticateToken') - ->will($this->returnValue($token)); + ->willReturn($token); $provider = $this->getProvider($authenticator, null, $userChecker); @@ -56,7 +56,7 @@ public function testAuthenticateWhenPostChecksFails() $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token->expects($this->any()) ->method('getUser') - ->will($this->returnValue($user)); + ->willReturn($user); $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); $userChecker->expects($this->once()) @@ -66,7 +66,7 @@ public function testAuthenticateWhenPostChecksFails() $authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock(); $authenticator->expects($this->once()) ->method('authenticateToken') - ->will($this->returnValue($token)); + ->willReturn($token); $provider = $this->getProvider($authenticator, null, $userChecker); @@ -78,11 +78,11 @@ public function testAuthenticateSkipsUserChecksForNonUserInterfaceObjects() $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token->expects($this->any()) ->method('getUser') - ->will($this->returnValue('string-user')); + ->willReturn('string-user'); $authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock(); $authenticator->expects($this->once()) ->method('authenticateToken') - ->will($this->returnValue($token)); + ->willReturn($token); $this->assertSame($token, $this->getProvider($authenticator, null, new UserChecker())->authenticate($token)); } diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php index 7c306d2f1f0f6..e959d18c53409 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php @@ -76,7 +76,7 @@ public function testAuthenticateWhenProviderDoesNotReturnAnUserInterface() $provider = $this->getProvider(false, true); $provider->expects($this->once()) ->method('retrieveUser') - ->will($this->returnValue(null)) + ->willReturn(null) ; $provider->authenticate($this->getSupportedToken()); @@ -96,7 +96,7 @@ public function testAuthenticateWhenPreChecksFails() $provider = $this->getProvider($userChecker); $provider->expects($this->once()) ->method('retrieveUser') - ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock())) + ->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()) ; $provider->authenticate($this->getSupportedToken()); @@ -116,7 +116,7 @@ public function testAuthenticateWhenPostChecksFails() $provider = $this->getProvider($userChecker); $provider->expects($this->once()) ->method('retrieveUser') - ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock())) + ->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()) ; $provider->authenticate($this->getSupportedToken()); @@ -131,7 +131,7 @@ public function testAuthenticateWhenPostCheckAuthenticationFails() $provider = $this->getProvider(); $provider->expects($this->once()) ->method('retrieveUser') - ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock())) + ->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()) ; $provider->expects($this->once()) ->method('checkAuthentication') @@ -150,7 +150,7 @@ public function testAuthenticateWhenPostCheckAuthenticationFailsWithHideFalse() $provider = $this->getProvider(false, false); $provider->expects($this->once()) ->method('retrieveUser') - ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock())) + ->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()) ; $provider->expects($this->once()) ->method('checkAuthentication') @@ -165,24 +165,24 @@ public function testAuthenticate() $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user->expects($this->once()) ->method('getRoles') - ->will($this->returnValue(['ROLE_FOO'])) + ->willReturn(['ROLE_FOO']) ; $provider = $this->getProvider(); $provider->expects($this->once()) ->method('retrieveUser') - ->will($this->returnValue($user)) + ->willReturn($user) ; $token = $this->getSupportedToken(); $token->expects($this->once()) ->method('getCredentials') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $token->expects($this->once()) ->method('getRoles') - ->will($this->returnValue([])) + ->willReturn([]) ; $authToken = $provider->authenticate($token); @@ -199,25 +199,25 @@ public function testAuthenticateWithPreservingRoleSwitchUserRole() $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user->expects($this->once()) ->method('getRoles') - ->will($this->returnValue(['ROLE_FOO'])) + ->willReturn(['ROLE_FOO']) ; $provider = $this->getProvider(); $provider->expects($this->once()) ->method('retrieveUser') - ->will($this->returnValue($user)) + ->willReturn($user) ; $token = $this->getSupportedToken(); $token->expects($this->once()) ->method('getCredentials') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $switchUserRole = new SwitchUserRole('foo', $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); $token->expects($this->once()) ->method('getRoles') - ->will($this->returnValue([$switchUserRole])) + ->willReturn([$switchUserRole]) ; $authToken = $provider->authenticate($token); @@ -236,7 +236,7 @@ protected function getSupportedToken() $mock ->expects($this->any()) ->method('getProviderKey') - ->will($this->returnValue('key')) + ->willReturn('key') ; $mock->setAttributes(['foo' => 'bar']); diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php index 8280366d4af61..7516759c0aa8e 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php @@ -77,7 +77,7 @@ public function testGetUsername() $this->assertEquals('fabien', $token->getUsername()); $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); - $user->expects($this->once())->method('getUsername')->will($this->returnValue('fabien')); + $user->expects($this->once())->method('getUsername')->willReturn('fabien'); $token->setUser($user); $this->assertEquals('fabien', $token->getUsername()); } diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php index 0bdd54dc308bd..e1329e37430b6 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php @@ -59,7 +59,7 @@ protected function getUser($roles = ['ROLE_FOO']) $user ->expects($this->once()) ->method('getRoles') - ->will($this->returnValue($roles)) + ->willReturn($roles) ; return $user; diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php index 9ee86a079bc9a..c60a59b375d3e 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php @@ -72,10 +72,10 @@ protected function getVoterFor2Roles($token, $vote1, $vote2) $voter = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface')->getMock(); $voter->expects($this->any()) ->method('vote') - ->will($this->returnValueMap([ + ->willReturnMap([ [$token, null, ['ROLE_FOO'], $vote1], [$token, null, ['ROLE_BAR'], $vote2], - ])) + ]) ; return $voter; @@ -137,7 +137,7 @@ protected function getVoter($vote) $voter = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface')->getMock(); $voter->expects($this->any()) ->method('vote') - ->will($this->returnValue($vote)); + ->willReturn($vote); return $voter; } diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php index 6a07c94f2039c..b4986b0177863 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php @@ -46,7 +46,7 @@ public function testVoteAuthenticatesTokenIfNecessary() ->expects($this->once()) ->method('authenticate') ->with($this->equalTo($token)) - ->will($this->returnValue($newToken)); + ->willReturn($newToken); // default with() isn't a strict check $tokenComparison = function ($value) use ($newToken) { @@ -58,7 +58,7 @@ public function testVoteAuthenticatesTokenIfNecessary() ->expects($this->once()) ->method('decide') ->with($this->callback($tokenComparison)) - ->will($this->returnValue(true)); + ->willReturn(true); // first run the token has not been re-authenticated yet, after isGranted is called, it should be equal $this->assertNotSame($newToken, $this->tokenStorage->getToken()); @@ -83,12 +83,12 @@ public function testIsGranted($decide) $token ->expects($this->once()) ->method('isAuthenticated') - ->will($this->returnValue(true)); + ->willReturn(true); $this->accessDecisionManager ->expects($this->once()) ->method('decide') - ->will($this->returnValue($decide)); + ->willReturn($decide); $this->tokenStorage->setToken($token); $this->assertSame($decide, $this->authorizationChecker->isGranted('ROLE_FOO')); } diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/ExpressionVoterTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/ExpressionVoterTest.php index 7e435687c8c3c..ce368aa374f7e 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/ExpressionVoterTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/ExpressionVoterTest.php @@ -51,7 +51,7 @@ protected function getToken(array $roles, $tokenExpectsGetRoles = true) if ($tokenExpectsGetRoles) { $token->expects($this->once()) ->method('getRoles') - ->will($this->returnValue($roles)); + ->willReturn($roles); } return $token; @@ -64,7 +64,7 @@ protected function createExpressionLanguage($expressionLanguageExpectsEvaluate = if ($expressionLanguageExpectsEvaluate) { $mock->expects($this->once()) ->method('evaluate') - ->will($this->returnValue(true)); + ->willReturn(true); } return $mock; diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleVoterTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleVoterTest.php index 5fb45e08b3925..955ab842e139f 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleVoterTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleVoterTest.php @@ -54,7 +54,7 @@ protected function getToken(array $roles) $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token->expects($this->once()) ->method('getRoles') - ->will($this->returnValue($roles)); + ->willReturn($roles); return $token; } diff --git a/src/Symfony/Component/Security/Core/Tests/Encoder/UserPasswordEncoderTest.php b/src/Symfony/Component/Security/Core/Tests/Encoder/UserPasswordEncoderTest.php index 3328837ef1f74..41a602f976047 100644 --- a/src/Symfony/Component/Security/Core/Tests/Encoder/UserPasswordEncoderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Encoder/UserPasswordEncoderTest.php @@ -21,19 +21,19 @@ public function testEncodePassword() $userMock = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $userMock->expects($this->any()) ->method('getSalt') - ->will($this->returnValue('userSalt')); + ->willReturn('userSalt'); $mockEncoder = $this->getMockBuilder('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface')->getMock(); $mockEncoder->expects($this->any()) ->method('encodePassword') ->with($this->equalTo('plainPassword'), $this->equalTo('userSalt')) - ->will($this->returnValue('encodedPassword')); + ->willReturn('encodedPassword'); $mockEncoderFactory = $this->getMockBuilder('Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface')->getMock(); $mockEncoderFactory->expects($this->any()) ->method('getEncoder') ->with($this->equalTo($userMock)) - ->will($this->returnValue($mockEncoder)); + ->willReturn($mockEncoder); $passwordEncoder = new UserPasswordEncoder($mockEncoderFactory); @@ -46,22 +46,22 @@ public function testIsPasswordValid() $userMock = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $userMock->expects($this->any()) ->method('getSalt') - ->will($this->returnValue('userSalt')); + ->willReturn('userSalt'); $userMock->expects($this->any()) ->method('getPassword') - ->will($this->returnValue('encodedPassword')); + ->willReturn('encodedPassword'); $mockEncoder = $this->getMockBuilder('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface')->getMock(); $mockEncoder->expects($this->any()) ->method('isPasswordValid') ->with($this->equalTo('encodedPassword'), $this->equalTo('plainPassword'), $this->equalTo('userSalt')) - ->will($this->returnValue(true)); + ->willReturn(true); $mockEncoderFactory = $this->getMockBuilder('Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface')->getMock(); $mockEncoderFactory->expects($this->any()) ->method('getEncoder') ->with($this->equalTo($userMock)) - ->will($this->returnValue($mockEncoder)); + ->willReturn($mockEncoder); $passwordEncoder = new UserPasswordEncoder($mockEncoderFactory); diff --git a/src/Symfony/Component/Security/Core/Tests/SecurityTest.php b/src/Symfony/Component/Security/Core/Tests/SecurityTest.php index 7a1b572fc7d02..fa3e416e55c15 100644 --- a/src/Symfony/Component/Security/Core/Tests/SecurityTest.php +++ b/src/Symfony/Component/Security/Core/Tests/SecurityTest.php @@ -29,7 +29,7 @@ public function testGetToken() $tokenStorage->expects($this->once()) ->method('getToken') - ->will($this->returnValue($token)); + ->willReturn($token); $container = $this->createContainer('security.token_storage', $tokenStorage); @@ -45,12 +45,12 @@ public function testGetUser($userInToken, $expectedUser) $token = $this->getMockBuilder(TokenInterface::class)->getMock(); $token->expects($this->any()) ->method('getUser') - ->will($this->returnValue($userInToken)); + ->willReturn($userInToken); $tokenStorage = $this->getMockBuilder(TokenStorageInterface::class)->getMock(); $tokenStorage->expects($this->once()) ->method('getToken') - ->will($this->returnValue($token)); + ->willReturn($token); $container = $this->createContainer('security.token_storage', $tokenStorage); @@ -75,7 +75,7 @@ public function testIsGranted() $authorizationChecker->expects($this->once()) ->method('isGranted') ->with('SOME_ATTRIBUTE', 'SOME_SUBJECT') - ->will($this->returnValue(true)); + ->willReturn(true); $container = $this->createContainer('security.authorization_checker', $authorizationChecker); @@ -90,7 +90,7 @@ private function createContainer($serviceId, $serviceObject) $container->expects($this->atLeastOnce()) ->method('get') ->with($serviceId) - ->will($this->returnValue($serviceObject)); + ->willReturn($serviceObject); return $container; } diff --git a/src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php b/src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php index 067eef2497b83..05a7fbba19d88 100644 --- a/src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php @@ -33,7 +33,7 @@ public function testLoadUserByUsername() ->expects($this->once()) ->method('loadUserByUsername') ->with($this->equalTo('foo')) - ->will($this->returnValue($account = $this->getAccount())) + ->willReturn($account = $this->getAccount()) ; $provider = new ChainUserProvider([$provider1, $provider2]); @@ -78,7 +78,7 @@ public function testRefreshUser() $provider2 ->expects($this->once()) ->method('refreshUser') - ->will($this->returnValue($account = $this->getAccount())) + ->willReturn($account = $this->getAccount()) ; $provider = new ChainUserProvider([$provider1, $provider2]); @@ -98,7 +98,7 @@ public function testRefreshUserAgain() $provider2 ->expects($this->once()) ->method('refreshUser') - ->will($this->returnValue($account = $this->getAccount())) + ->willReturn($account = $this->getAccount()) ; $provider = new ChainUserProvider([$provider1, $provider2]); @@ -135,7 +135,7 @@ public function testSupportsClass() ->expects($this->once()) ->method('supportsClass') ->with($this->equalTo('foo')) - ->will($this->returnValue(false)) + ->willReturn(false) ; $provider2 = $this->getProvider(); @@ -143,7 +143,7 @@ public function testSupportsClass() ->expects($this->once()) ->method('supportsClass') ->with($this->equalTo('foo')) - ->will($this->returnValue(true)) + ->willReturn(true) ; $provider = new ChainUserProvider([$provider1, $provider2]); @@ -157,7 +157,7 @@ public function testSupportsClassWhenNotSupported() ->expects($this->once()) ->method('supportsClass') ->with($this->equalTo('foo')) - ->will($this->returnValue(false)) + ->willReturn(false) ; $provider2 = $this->getProvider(); @@ -165,7 +165,7 @@ public function testSupportsClassWhenNotSupported() ->expects($this->once()) ->method('supportsClass') ->with($this->equalTo('foo')) - ->will($this->returnValue(false)) + ->willReturn(false) ; $provider = new ChainUserProvider([$provider1, $provider2]); @@ -185,7 +185,7 @@ public function testAcceptsTraversable() $provider2 ->expects($this->once()) ->method('refreshUser') - ->will($this->returnValue($account = $this->getAccount())) + ->willReturn($account = $this->getAccount()) ; $provider = new ChainUserProvider(new \ArrayObject([$provider1, $provider2])); diff --git a/src/Symfony/Component/Security/Core/Tests/User/LdapUserProviderTest.php b/src/Symfony/Component/Security/Core/Tests/User/LdapUserProviderTest.php index 418475ac9381c..39a346433e463 100644 --- a/src/Symfony/Component/Security/Core/Tests/User/LdapUserProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/User/LdapUserProviderTest.php @@ -50,23 +50,23 @@ public function testLoadUserByUsernameFailsIfNoLdapEntries() $query ->expects($this->once()) ->method('execute') - ->will($this->returnValue($result)) + ->willReturn($result) ; $result ->expects($this->once()) ->method('count') - ->will($this->returnValue(0)) + ->willReturn(0) ; $ldap = $this->getMockBuilder(LdapInterface::class)->getMock(); $ldap ->expects($this->once()) ->method('escape') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $ldap ->expects($this->once()) ->method('query') - ->will($this->returnValue($query)) + ->willReturn($query) ; $provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com'); @@ -83,23 +83,23 @@ public function testLoadUserByUsernameFailsIfMoreThanOneLdapEntry() $query ->expects($this->once()) ->method('execute') - ->will($this->returnValue($result)) + ->willReturn($result) ; $result ->expects($this->once()) ->method('count') - ->will($this->returnValue(2)) + ->willReturn(2) ; $ldap = $this->getMockBuilder(LdapInterface::class)->getMock(); $ldap ->expects($this->once()) ->method('escape') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $ldap ->expects($this->once()) ->method('query') - ->will($this->returnValue($query)) + ->willReturn($query) ; $provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com'); @@ -116,33 +116,33 @@ public function testLoadUserByUsernameFailsIfMoreThanOneLdapPasswordsInEntry() $query ->expects($this->once()) ->method('execute') - ->will($this->returnValue($result)) + ->willReturn($result) ; $ldap = $this->getMockBuilder(LdapInterface::class)->getMock(); $result ->expects($this->once()) ->method('offsetGet') ->with(0) - ->will($this->returnValue(new Entry('foo', [ + ->willReturn(new Entry('foo', [ 'sAMAccountName' => ['foo'], 'userpassword' => ['bar', 'baz'], ] - ))) + )) ; $result ->expects($this->once()) ->method('count') - ->will($this->returnValue(1)) + ->willReturn(1) ; $ldap ->expects($this->once()) ->method('escape') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $ldap ->expects($this->once()) ->method('query') - ->will($this->returnValue($query)) + ->willReturn($query) ; $provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com', null, null, [], 'sAMAccountName', '({uid_key}={username})', 'userpassword'); @@ -159,29 +159,29 @@ public function testLoadUserByUsernameShouldNotFailIfEntryHasNoUidKeyAttribute() $query ->expects($this->once()) ->method('execute') - ->will($this->returnValue($result)) + ->willReturn($result) ; $ldap = $this->getMockBuilder(LdapInterface::class)->getMock(); $result ->expects($this->once()) ->method('offsetGet') ->with(0) - ->will($this->returnValue(new Entry('foo', []))) + ->willReturn(new Entry('foo', [])) ; $result ->expects($this->once()) ->method('count') - ->will($this->returnValue(1)) + ->willReturn(1) ; $ldap ->expects($this->once()) ->method('escape') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $ldap ->expects($this->once()) ->method('query') - ->will($this->returnValue($query)) + ->willReturn($query) ; $provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com', null, null, [], 'sAMAccountName', '({uid_key}={username})'); @@ -201,32 +201,32 @@ public function testLoadUserByUsernameFailsIfEntryHasNoPasswordAttribute() $query ->expects($this->once()) ->method('execute') - ->will($this->returnValue($result)) + ->willReturn($result) ; $ldap = $this->getMockBuilder(LdapInterface::class)->getMock(); $result ->expects($this->once()) ->method('offsetGet') ->with(0) - ->will($this->returnValue(new Entry('foo', [ + ->willReturn(new Entry('foo', [ 'sAMAccountName' => ['foo'], ] - ))) + )) ; $result ->expects($this->once()) ->method('count') - ->will($this->returnValue(1)) + ->willReturn(1) ; $ldap ->expects($this->once()) ->method('escape') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $ldap ->expects($this->once()) ->method('query') - ->will($this->returnValue($query)) + ->willReturn($query) ; $provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com', null, null, [], 'sAMAccountName', '({uid_key}={username})', 'userpassword'); @@ -243,32 +243,32 @@ public function testLoadUserByUsernameIsSuccessfulWithoutPasswordAttribute() $query ->expects($this->once()) ->method('execute') - ->will($this->returnValue($result)) + ->willReturn($result) ; $ldap = $this->getMockBuilder(LdapInterface::class)->getMock(); $result ->expects($this->once()) ->method('offsetGet') ->with(0) - ->will($this->returnValue(new Entry('foo', [ + ->willReturn(new Entry('foo', [ 'sAMAccountName' => ['foo'], ] - ))) + )) ; $result ->expects($this->once()) ->method('count') - ->will($this->returnValue(1)) + ->willReturn(1) ; $ldap ->expects($this->once()) ->method('escape') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $ldap ->expects($this->once()) ->method('query') - ->will($this->returnValue($query)) + ->willReturn($query) ; $provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com'); @@ -285,32 +285,32 @@ public function testLoadUserByUsernameIsSuccessfulWithoutPasswordAttributeAndWro $query ->expects($this->once()) ->method('execute') - ->will($this->returnValue($result)) + ->willReturn($result) ; $ldap = $this->getMockBuilder(LdapInterface::class)->getMock(); $result ->expects($this->once()) ->method('offsetGet') ->with(0) - ->will($this->returnValue(new Entry('foo', [ + ->willReturn(new Entry('foo', [ 'sAMAccountName' => ['foo'], ] - ))) + )) ; $result ->expects($this->once()) ->method('count') - ->will($this->returnValue(1)) + ->willReturn(1) ; $ldap ->expects($this->once()) ->method('escape') - ->will($this->returnValue('Foo')) + ->willReturn('Foo') ; $ldap ->expects($this->once()) ->method('query') - ->will($this->returnValue($query)) + ->willReturn($query) ; $provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com'); @@ -324,33 +324,33 @@ public function testLoadUserByUsernameIsSuccessfulWithPasswordAttribute() $query ->expects($this->once()) ->method('execute') - ->will($this->returnValue($result)) + ->willReturn($result) ; $ldap = $this->getMockBuilder(LdapInterface::class)->getMock(); $result ->expects($this->once()) ->method('offsetGet') ->with(0) - ->will($this->returnValue(new Entry('foo', [ + ->willReturn(new Entry('foo', [ 'sAMAccountName' => ['foo'], 'userpassword' => ['bar'], ] - ))) + )) ; $result ->expects($this->once()) ->method('count') - ->will($this->returnValue(1)) + ->willReturn(1) ; $ldap ->expects($this->once()) ->method('escape') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $ldap ->expects($this->once()) ->method('query') - ->will($this->returnValue($query)) + ->willReturn($query) ; $provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com', null, null, [], 'sAMAccountName', '({uid_key}={username})', 'userpassword'); diff --git a/src/Symfony/Component/Security/Core/Tests/User/UserCheckerTest.php b/src/Symfony/Component/Security/Core/Tests/User/UserCheckerTest.php index 8ec34843eaae0..16eea31c4f0ea 100644 --- a/src/Symfony/Component/Security/Core/Tests/User/UserCheckerTest.php +++ b/src/Symfony/Component/Security/Core/Tests/User/UserCheckerTest.php @@ -28,7 +28,7 @@ public function testCheckPostAuthPass() $checker = new UserChecker(); $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); - $account->expects($this->once())->method('isCredentialsNonExpired')->will($this->returnValue(true)); + $account->expects($this->once())->method('isCredentialsNonExpired')->willReturn(true); $this->assertNull($checker->checkPostAuth($account)); } @@ -41,7 +41,7 @@ public function testCheckPostAuthCredentialsExpired() $checker = new UserChecker(); $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); - $account->expects($this->once())->method('isCredentialsNonExpired')->will($this->returnValue(false)); + $account->expects($this->once())->method('isCredentialsNonExpired')->willReturn(false); $checker->checkPostAuth($account); } @@ -58,9 +58,9 @@ public function testCheckPreAuthPass() $checker = new UserChecker(); $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); - $account->expects($this->once())->method('isAccountNonLocked')->will($this->returnValue(true)); - $account->expects($this->once())->method('isEnabled')->will($this->returnValue(true)); - $account->expects($this->once())->method('isAccountNonExpired')->will($this->returnValue(true)); + $account->expects($this->once())->method('isAccountNonLocked')->willReturn(true); + $account->expects($this->once())->method('isEnabled')->willReturn(true); + $account->expects($this->once())->method('isAccountNonExpired')->willReturn(true); $this->assertNull($checker->checkPreAuth($account)); } @@ -73,7 +73,7 @@ public function testCheckPreAuthAccountLocked() $checker = new UserChecker(); $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); - $account->expects($this->once())->method('isAccountNonLocked')->will($this->returnValue(false)); + $account->expects($this->once())->method('isAccountNonLocked')->willReturn(false); $checker->checkPreAuth($account); } @@ -86,8 +86,8 @@ public function testCheckPreAuthDisabled() $checker = new UserChecker(); $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); - $account->expects($this->once())->method('isAccountNonLocked')->will($this->returnValue(true)); - $account->expects($this->once())->method('isEnabled')->will($this->returnValue(false)); + $account->expects($this->once())->method('isAccountNonLocked')->willReturn(true); + $account->expects($this->once())->method('isEnabled')->willReturn(false); $checker->checkPreAuth($account); } @@ -100,9 +100,9 @@ public function testCheckPreAuthAccountExpired() $checker = new UserChecker(); $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); - $account->expects($this->once())->method('isAccountNonLocked')->will($this->returnValue(true)); - $account->expects($this->once())->method('isEnabled')->will($this->returnValue(true)); - $account->expects($this->once())->method('isAccountNonExpired')->will($this->returnValue(false)); + $account->expects($this->once())->method('isAccountNonLocked')->willReturn(true); + $account->expects($this->once())->method('isEnabled')->willReturn(true); + $account->expects($this->once())->method('isAccountNonExpired')->willReturn(false); $checker->checkPreAuth($account); } diff --git a/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php b/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php index 24c2c7adda187..305b665ea32c9 100644 --- a/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php @@ -65,7 +65,7 @@ public function testPasswordIsValid() $this->encoder->expects($this->once()) ->method('isPasswordValid') ->with(static::PASSWORD, 'secret', static::SALT) - ->will($this->returnValue(true)); + ->willReturn(true); $this->validator->validate('secret', $constraint); @@ -81,7 +81,7 @@ public function testPasswordIsNotValid() $this->encoder->expects($this->once()) ->method('isPasswordValid') ->with(static::PASSWORD, 'secret', static::SALT) - ->will($this->returnValue(false)); + ->willReturn(false); $this->validator->validate('secret', $constraint); @@ -133,13 +133,13 @@ protected function createUser() $mock ->expects($this->any()) ->method('getPassword') - ->will($this->returnValue(static::PASSWORD)) + ->willReturn(static::PASSWORD) ; $mock ->expects($this->any()) ->method('getSalt') - ->will($this->returnValue(static::SALT)) + ->willReturn(static::SALT) ; return $mock; @@ -157,7 +157,7 @@ protected function createEncoderFactory($encoder = null) $mock ->expects($this->any()) ->method('getEncoder') - ->will($this->returnValue($encoder)) + ->willReturn($encoder) ; return $mock; @@ -171,7 +171,7 @@ protected function createTokenStorage($user = null) $mock ->expects($this->any()) ->method('getToken') - ->will($this->returnValue($token)) + ->willReturn($token) ; return $mock; @@ -183,7 +183,7 @@ protected function createAuthenticationToken($user = null) $mock ->expects($this->any()) ->method('getUser') - ->will($this->returnValue($user)) + ->willReturn($user) ; return $mock; diff --git a/src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php b/src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php index b954fc037b907..631c36a0db0ac 100644 --- a/src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php +++ b/src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php @@ -30,11 +30,11 @@ public function testGetNonExistingToken($namespace, $manager, $storage, $generat $storage->expects($this->once()) ->method('hasToken') ->with($namespace.'token_id') - ->will($this->returnValue(false)); + ->willReturn(false); $generator->expects($this->once()) ->method('generateToken') - ->will($this->returnValue('TOKEN')); + ->willReturn('TOKEN'); $storage->expects($this->once()) ->method('setToken') @@ -55,12 +55,12 @@ public function testUseExistingTokenIfAvailable($namespace, $manager, $storage) $storage->expects($this->once()) ->method('hasToken') ->with($namespace.'token_id') - ->will($this->returnValue(true)); + ->willReturn(true); $storage->expects($this->once()) ->method('getToken') ->with($namespace.'token_id') - ->will($this->returnValue('TOKEN')); + ->willReturn('TOKEN'); $token = $manager->getToken('token_id'); @@ -79,7 +79,7 @@ public function testRefreshTokenAlwaysReturnsNewToken($namespace, $manager, $sto $generator->expects($this->once()) ->method('generateToken') - ->will($this->returnValue('TOKEN')); + ->willReturn('TOKEN'); $storage->expects($this->once()) ->method('setToken') @@ -100,12 +100,12 @@ public function testMatchingTokenIsValid($namespace, $manager, $storage) $storage->expects($this->once()) ->method('hasToken') ->with($namespace.'token_id') - ->will($this->returnValue(true)); + ->willReturn(true); $storage->expects($this->once()) ->method('getToken') ->with($namespace.'token_id') - ->will($this->returnValue('TOKEN')); + ->willReturn('TOKEN'); $this->assertTrue($manager->isTokenValid(new CsrfToken('token_id', 'TOKEN'))); } @@ -118,12 +118,12 @@ public function testNonMatchingTokenIsNotValid($namespace, $manager, $storage) $storage->expects($this->once()) ->method('hasToken') ->with($namespace.'token_id') - ->will($this->returnValue(true)); + ->willReturn(true); $storage->expects($this->once()) ->method('getToken') ->with($namespace.'token_id') - ->will($this->returnValue('TOKEN')); + ->willReturn('TOKEN'); $this->assertFalse($manager->isTokenValid(new CsrfToken('token_id', 'FOOBAR'))); } @@ -136,7 +136,7 @@ public function testNonExistingTokenIsNotValid($namespace, $manager, $storage) $storage->expects($this->once()) ->method('hasToken') ->with($namespace.'token_id') - ->will($this->returnValue(false)); + ->willReturn(false); $storage->expects($this->never()) ->method('getToken'); @@ -152,7 +152,7 @@ public function testRemoveToken($namespace, $manager, $storage) $storage->expects($this->once()) ->method('removeToken') ->with($namespace.'token_id') - ->will($this->returnValue('REMOVED_TOKEN')); + ->willReturn('REMOVED_TOKEN'); $this->assertSame('REMOVED_TOKEN', $manager->removeToken('token_id')); } diff --git a/src/Symfony/Component/Security/Guard/Tests/Authenticator/FormLoginAuthenticatorTest.php b/src/Symfony/Component/Security/Guard/Tests/Authenticator/FormLoginAuthenticatorTest.php index ca472f87bc5e8..c3983287fc42b 100644 --- a/src/Symfony/Component/Security/Guard/Tests/Authenticator/FormLoginAuthenticatorTest.php +++ b/src/Symfony/Component/Security/Guard/Tests/Authenticator/FormLoginAuthenticatorTest.php @@ -77,7 +77,7 @@ public function testAuthenticationSuccessWithSessionButEmpty() $this->requestWithSession->getSession() ->expects($this->once()) ->method('get') - ->will($this->returnValue(null)); + ->willReturn(null); $redirectResponse = $this->authenticator->onAuthenticationSuccess($this->requestWithSession, $token, 'providerkey'); @@ -96,7 +96,7 @@ public function testAuthenticationSuccessWithSessionAndTarget() $this->requestWithSession->getSession() ->expects($this->once()) ->method('get') - ->will($this->returnValue(self::CUSTOM_SUCCESS_URL)); + ->willReturn(self::CUSTOM_SUCCESS_URL); $redirectResponse = $this->authenticator->onAuthenticationSuccess($this->requestWithSession, $token, 'providerkey'); diff --git a/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php b/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php index fa4e9ef623122..7e4d2929b6388 100644 --- a/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php @@ -51,7 +51,7 @@ public function testHandleSuccess() ->expects($this->once()) ->method('getCredentials') ->with($this->equalTo($this->request)) - ->will($this->returnValue($credentials)); + ->willReturn($credentials); // a clone of the token that should be created internally $uniqueGuardKey = 'my_firewall_0'; @@ -61,7 +61,7 @@ public function testHandleSuccess() ->expects($this->once()) ->method('authenticate') ->with($this->equalTo($nonAuthedToken)) - ->will($this->returnValue($authenticateToken)); + ->willReturn($authenticateToken); $this->guardAuthenticatorHandler ->expects($this->once()) @@ -139,18 +139,18 @@ public function testHandleSuccessWithRememberMe() ->expects($this->once()) ->method('getCredentials') ->with($this->equalTo($this->request)) - ->will($this->returnValue(['username' => 'anything_not_empty'])); + ->willReturn(['username' => 'anything_not_empty']); $this->authenticationManager ->expects($this->once()) ->method('authenticate') - ->will($this->returnValue($authenticateToken)); + ->willReturn($authenticateToken); $successResponse = new Response('Success!'); $this->guardAuthenticatorHandler ->expects($this->once()) ->method('handleAuthenticationSuccess') - ->will($this->returnValue($successResponse)); + ->willReturn($successResponse); $listener = new GuardAuthenticationListener( $this->guardAuthenticatorHandler, @@ -163,7 +163,7 @@ public function testHandleSuccessWithRememberMe() $listener->setRememberMeServices($this->rememberMeServices); $authenticator->expects($this->once()) ->method('supportsRememberMe') - ->will($this->returnValue(true)); + ->willReturn(true); // should be called - we do have a success Response $this->rememberMeServices ->expects($this->once()) @@ -219,7 +219,7 @@ public function testLegacyInterfaceNullCredentials() $authenticatorA ->expects($this->once()) ->method('getCredentials') - ->will($this->returnValue(null)); + ->willReturn(null); // this is not called $this->authenticationManager @@ -256,7 +256,7 @@ public function testLegacyInterfaceKeepsWorking() ->expects($this->once()) ->method('getCredentials') ->with($this->equalTo($this->request)) - ->will($this->returnValue($credentials)); + ->willReturn($credentials); // a clone of the token that should be created internally $uniqueGuardKey = 'my_firewall_0'; @@ -266,7 +266,7 @@ public function testLegacyInterfaceKeepsWorking() ->expects($this->once()) ->method('authenticate') ->with($this->equalTo($nonAuthedToken)) - ->will($this->returnValue($authenticateToken)); + ->willReturn($authenticateToken); $this->guardAuthenticatorHandler ->expects($this->once()) @@ -307,11 +307,11 @@ public function testReturnNullToSkipAuth() $authenticatorA ->expects($this->once()) ->method('getCredentials') - ->will($this->returnValue(null)); + ->willReturn(null); $authenticatorB ->expects($this->once()) ->method('getCredentials') - ->will($this->returnValue(null)); + ->willReturn(null); // this is not called $this->authenticationManager @@ -341,7 +341,7 @@ public function testSupportsReturnFalseSkipAuth() $authenticator ->expects($this->once()) ->method('supports') - ->will($this->returnValue(false)); + ->willReturn(false); // this is not called $authenticator @@ -370,13 +370,13 @@ public function testReturnNullFromGetCredentials() $authenticator ->expects($this->once()) ->method('supports') - ->will($this->returnValue(true)); + ->willReturn(true); // this will raise exception $authenticator ->expects($this->once()) ->method('getCredentials') - ->will($this->returnValue(null)); + ->willReturn(null); $listener = new GuardAuthenticationListener( $this->guardAuthenticatorHandler, @@ -401,13 +401,13 @@ public function testReturnNullFromGetCredentialsTriggersForAbstractGuardAuthenti $authenticator ->expects($this->once()) ->method('supports') - ->will($this->returnValue(true)); + ->willReturn(true); // this will raise exception $authenticator ->expects($this->once()) ->method('getCredentials') - ->will($this->returnValue(null)); + ->willReturn(null); $listener = new GuardAuthenticationListener( $this->guardAuthenticatorHandler, @@ -439,7 +439,7 @@ protected function setUp() $this->event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($this->request)); + ->willReturn($this->request); $this->logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $this->rememberMeServices = $this->getMockBuilder('Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface')->getMock(); diff --git a/src/Symfony/Component/Security/Guard/Tests/GuardAuthenticatorHandlerTest.php b/src/Symfony/Component/Security/Guard/Tests/GuardAuthenticatorHandlerTest.php index 9950426de9e2f..3bf204ec7f5c0 100644 --- a/src/Symfony/Component/Security/Guard/Tests/GuardAuthenticatorHandlerTest.php +++ b/src/Symfony/Component/Security/Guard/Tests/GuardAuthenticatorHandlerTest.php @@ -54,7 +54,7 @@ public function testHandleAuthenticationSuccess() $this->guardAuthenticator->expects($this->once()) ->method('onAuthenticationSuccess') ->with($this->request, $this->token, $providerKey) - ->will($this->returnValue($response)); + ->willReturn($response); $handler = new GuardAuthenticatorHandler($this->tokenStorage, $this->dispatcher); $actualResponse = $handler->handleAuthenticationSuccess($this->token, $this->request, $this->guardAuthenticator, $providerKey); @@ -73,7 +73,7 @@ public function testHandleAuthenticationFailure() $this->guardAuthenticator->expects($this->once()) ->method('onAuthenticationFailure') ->with($this->request, $authException) - ->will($this->returnValue($response)); + ->willReturn($response); $handler = new GuardAuthenticatorHandler($this->tokenStorage, $this->dispatcher); $actualResponse = $handler->handleAuthenticationFailure($authException, $this->request, $this->guardAuthenticator, 'firewall_provider_key'); @@ -90,7 +90,7 @@ public function testHandleAuthenticationClearsToken($tokenClass, $tokenProviderK ->getMock(); $token->expects($this->any()) ->method('getProviderKey') - ->will($this->returnValue($tokenProviderKey)); + ->willReturn($tokenProviderKey); $this->tokenStorage->expects($this->never()) ->method('setToken') @@ -101,7 +101,7 @@ public function testHandleAuthenticationClearsToken($tokenClass, $tokenProviderK $this->guardAuthenticator->expects($this->once()) ->method('onAuthenticationFailure') ->with($this->request, $authException) - ->will($this->returnValue($response)); + ->willReturn($response); $handler = new GuardAuthenticatorHandler($this->tokenStorage, $this->dispatcher); $actualResponse = $handler->handleAuthenticationFailure($authException, $this->request, $this->guardAuthenticator, $actualProviderKey); diff --git a/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php b/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php index a6636dd2f7f36..26f830e500d4c 100644 --- a/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php @@ -41,7 +41,7 @@ public function testAuthenticate() $this->preAuthenticationToken->expects($this->exactly(2)) ->method('getGuardProviderKey') // it will return the "1" index, which will match authenticatorB - ->will($this->returnValue('my_cool_firewall_1')); + ->willReturn('my_cool_firewall_1'); $enteredCredentials = [ 'username' => '_weaverryan_test_user', @@ -49,7 +49,7 @@ public function testAuthenticate() ]; $this->preAuthenticationToken->expects($this->atLeastOnce()) ->method('getCredentials') - ->will($this->returnValue($enteredCredentials)); + ->willReturn($enteredCredentials); // authenticators A and C are never called $authenticatorA->expects($this->never()) @@ -61,18 +61,18 @@ public function testAuthenticate() $authenticatorB->expects($this->once()) ->method('getUser') ->with($enteredCredentials, $this->userProvider) - ->will($this->returnValue($mockedUser)); + ->willReturn($mockedUser); // checkCredentials is called $authenticatorB->expects($this->once()) ->method('checkCredentials') ->with($enteredCredentials, $mockedUser) // authentication works! - ->will($this->returnValue(true)); + ->willReturn(true); $authedToken = $this->getMockBuilder(TokenInterface::class)->getMock(); $authenticatorB->expects($this->once()) ->method('createAuthenticatedToken') ->with($mockedUser, $providerKey) - ->will($this->returnValue($authedToken)); + ->willReturn($authedToken); // user checker should be called $this->userChecker->expects($this->once()) @@ -103,7 +103,7 @@ public function testLegacyAuthenticate() $this->preAuthenticationToken->expects($this->exactly(2)) ->method('getGuardProviderKey') // it will return the "1" index, which will match authenticatorB - ->will($this->returnValue('my_cool_firewall_1')); + ->willReturn('my_cool_firewall_1'); $enteredCredentials = [ 'username' => '_weaverryan_test_user', @@ -111,7 +111,7 @@ public function testLegacyAuthenticate() ]; $this->preAuthenticationToken->expects($this->atLeastOnce()) ->method('getCredentials') - ->will($this->returnValue($enteredCredentials)); + ->willReturn($enteredCredentials); // authenticators A and C are never called $authenticatorA->expects($this->never()) @@ -123,18 +123,18 @@ public function testLegacyAuthenticate() $authenticatorB->expects($this->once()) ->method('getUser') ->with($enteredCredentials, $this->userProvider) - ->will($this->returnValue($mockedUser)); + ->willReturn($mockedUser); // checkCredentials is called $authenticatorB->expects($this->once()) ->method('checkCredentials') ->with($enteredCredentials, $mockedUser) // authentication works! - ->will($this->returnValue(true)); + ->willReturn(true); $authedToken = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $authenticatorB->expects($this->once()) ->method('createAuthenticatedToken') ->with($mockedUser, $providerKey) - ->will($this->returnValue($authedToken)); + ->willReturn($authedToken); // user checker should be called $this->userChecker->expects($this->once()) @@ -162,21 +162,21 @@ public function testCheckCredentialsReturningNonTrueFailsAuthentication() $this->preAuthenticationToken->expects($this->any()) ->method('getGuardProviderKey') // the 0 index, to match the only authenticator - ->will($this->returnValue('my_uncool_firewall_0')); + ->willReturn('my_uncool_firewall_0'); $this->preAuthenticationToken->expects($this->atLeastOnce()) ->method('getCredentials') - ->will($this->returnValue('non-null-value')); + ->willReturn('non-null-value'); $mockedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $authenticator->expects($this->once()) ->method('getUser') - ->will($this->returnValue($mockedUser)); + ->willReturn($mockedUser); // checkCredentials is called $authenticator->expects($this->once()) ->method('checkCredentials') // authentication fails :( - ->will($this->returnValue(null)); + ->willReturn(null); $provider = new GuardAuthenticationProvider([$authenticator], $this->userProvider, $providerKey, $this->userChecker); $provider->authenticate($this->preAuthenticationToken); diff --git a/src/Symfony/Component/Security/Http/Tests/AccessMapTest.php b/src/Symfony/Component/Security/Http/Tests/AccessMapTest.php index 8ae9581e2c848..1f5356ba9ee58 100644 --- a/src/Symfony/Component/Security/Http/Tests/AccessMapTest.php +++ b/src/Symfony/Component/Security/Http/Tests/AccessMapTest.php @@ -45,7 +45,7 @@ private function getRequestMatcher($request, $matches) $requestMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcherInterface')->getMock(); $requestMatcher->expects($this->once()) ->method('matches')->with($request) - ->will($this->returnValue($matches)); + ->willReturn($matches); return $requestMatcher; } diff --git a/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php index a9c18f3475d5c..a71ad179a3551 100644 --- a/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php @@ -34,7 +34,7 @@ protected function setUp() $this->session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock(); $this->request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); - $this->request->expects($this->any())->method('getSession')->will($this->returnValue($this->session)); + $this->request->expects($this->any())->method('getSession')->willReturn($this->session); $this->exception = $this->getMockBuilder('Symfony\Component\Security\Core\Exception\AuthenticationException')->setMethods(['getMessage'])->getMock(); } @@ -47,12 +47,12 @@ public function testForward() ->method('set')->with(Security::AUTHENTICATION_ERROR, $this->exception); $this->httpUtils->expects($this->once()) ->method('createRequest')->with($this->request, '/login') - ->will($this->returnValue($subRequest)); + ->willReturn($subRequest); $response = new Response(); $this->httpKernel->expects($this->once()) ->method('handle')->with($subRequest, HttpKernelInterface::SUB_REQUEST) - ->will($this->returnValue($response)); + ->willReturn($response); $handler = new DefaultAuthenticationFailureHandler($this->httpKernel, $this->httpUtils, $options, $this->logger); $result = $handler->onAuthenticationFailure($this->request, $this->exception); @@ -65,7 +65,7 @@ public function testRedirect() $response = new Response(); $this->httpUtils->expects($this->once()) ->method('createRedirectResponse')->with($this->request, '/login') - ->will($this->returnValue($response)); + ->willReturn($response); $handler = new DefaultAuthenticationFailureHandler($this->httpKernel, $this->httpUtils, [], $this->logger); $result = $handler->onAuthenticationFailure($this->request, $this->exception); @@ -92,7 +92,7 @@ public function testExceptionIsPassedInRequestOnForward() $this->httpUtils->expects($this->once()) ->method('createRequest')->with($this->request, '/login') - ->will($this->returnValue($subRequest)); + ->willReturn($subRequest); $this->session->expects($this->never())->method('set'); @@ -117,7 +117,7 @@ public function testForwardIsLogged() $this->httpUtils->expects($this->once()) ->method('createRequest')->with($this->request, '/login') - ->will($this->returnValue($this->getRequest())); + ->willReturn($this->getRequest()); $this->logger ->expects($this->once()) @@ -143,7 +143,7 @@ public function testFailurePathCanBeOverwrittenWithRequest() { $this->request->expects($this->once()) ->method('get')->with('_failure_path') - ->will($this->returnValue('/auth/login')); + ->willReturn('/auth/login'); $this->httpUtils->expects($this->once()) ->method('createRedirectResponse')->with($this->request, '/auth/login'); @@ -156,7 +156,7 @@ public function testFailurePathCanBeOverwrittenWithNestedAttributeInRequest() { $this->request->expects($this->once()) ->method('get')->with('_failure_path') - ->will($this->returnValue(['value' => '/auth/login'])); + ->willReturn(['value' => '/auth/login']); $this->httpUtils->expects($this->once()) ->method('createRedirectResponse')->with($this->request, '/auth/login'); @@ -171,7 +171,7 @@ public function testFailurePathParameterCanBeOverwritten() $this->request->expects($this->once()) ->method('get')->with('_my_failure_path') - ->will($this->returnValue('/auth/login')); + ->willReturn('/auth/login'); $this->httpUtils->expects($this->once()) ->method('createRedirectResponse')->with($this->request, '/auth/login'); diff --git a/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php index 531d49227f2c2..8f0ba0728c874 100644 --- a/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php @@ -24,7 +24,7 @@ class DefaultAuthenticationSuccessHandlerTest extends TestCase public function testRequestRedirections(Request $request, $options, $redirectedUrl) { $urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock(); - $urlGenerator->expects($this->any())->method('generate')->will($this->returnValue('http://localhost/login')); + $urlGenerator->expects($this->any())->method('generate')->willReturn('http://localhost/login'); $httpUtils = new HttpUtils($urlGenerator); $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $handler = new DefaultAuthenticationSuccessHandler($httpUtils, $options); @@ -37,7 +37,7 @@ public function testRequestRedirections(Request $request, $options, $redirectedU public function getRequestRedirections() { $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock(); - $session->expects($this->once())->method('get')->with('_security.admin.target_path')->will($this->returnValue('/admin/dashboard')); + $session->expects($this->once())->method('get')->with('_security.admin.target_path')->willReturn('/admin/dashboard'); $session->expects($this->once())->method('remove')->with('_security.admin.target_path'); $requestWithSession = Request::create('/'); $requestWithSession->setSession($session); diff --git a/src/Symfony/Component/Security/Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php index 4f73e5f44cdfa..70923ae31806e 100644 --- a/src/Symfony/Component/Security/Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php @@ -53,7 +53,7 @@ public function testOnAuthenticationSuccessFallsBackToDefaultHandlerIfSimpleIsNo $this->successHandler->expects($this->once()) ->method('onAuthenticationSuccess') ->with($this->request, $this->token) - ->will($this->returnValue($this->response)); + ->willReturn($this->response); $handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler); $result = $handler->onAuthenticationSuccess($this->request, $this->token); @@ -70,7 +70,7 @@ public function testOnAuthenticationSuccessCallsSimpleAuthenticator() $authenticator->expects($this->once()) ->method('onAuthenticationSuccess') ->with($this->request, $this->token) - ->will($this->returnValue($this->response)); + ->willReturn($this->response); $handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler); $result = $handler->onAuthenticationSuccess($this->request, $this->token); @@ -91,7 +91,7 @@ public function testOnAuthenticationSuccessThrowsAnExceptionIfNonResponseIsRetur $authenticator->expects($this->once()) ->method('onAuthenticationSuccess') ->with($this->request, $this->token) - ->will($this->returnValue(new \stdClass())); + ->willReturn(new \stdClass()); $handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler); $handler->onAuthenticationSuccess($this->request, $this->token); @@ -102,13 +102,13 @@ public function testOnAuthenticationSuccessFallsBackToDefaultHandlerIfNullIsRetu $this->successHandler->expects($this->once()) ->method('onAuthenticationSuccess') ->with($this->request, $this->token) - ->will($this->returnValue($this->response)); + ->willReturn($this->response); $authenticator = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Tests\TestSuccessHandlerInterface'); $authenticator->expects($this->once()) ->method('onAuthenticationSuccess') ->with($this->request, $this->token) - ->will($this->returnValue(null)); + ->willReturn(null); $handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler); $result = $handler->onAuthenticationSuccess($this->request, $this->token); @@ -123,7 +123,7 @@ public function testOnAuthenticationFailureFallsBackToDefaultHandlerIfSimpleIsNo $this->failureHandler->expects($this->once()) ->method('onAuthenticationFailure') ->with($this->request, $this->authenticationException) - ->will($this->returnValue($this->response)); + ->willReturn($this->response); $handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler); $result = $handler->onAuthenticationFailure($this->request, $this->authenticationException); @@ -140,7 +140,7 @@ public function testOnAuthenticationFailureCallsSimpleAuthenticator() $authenticator->expects($this->once()) ->method('onAuthenticationFailure') ->with($this->request, $this->authenticationException) - ->will($this->returnValue($this->response)); + ->willReturn($this->response); $handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler); $result = $handler->onAuthenticationFailure($this->request, $this->authenticationException); @@ -161,7 +161,7 @@ public function testOnAuthenticationFailureThrowsAnExceptionIfNonResponseIsRetur $authenticator->expects($this->once()) ->method('onAuthenticationFailure') ->with($this->request, $this->authenticationException) - ->will($this->returnValue(new \stdClass())); + ->willReturn(new \stdClass()); $handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler); $handler->onAuthenticationFailure($this->request, $this->authenticationException); @@ -172,13 +172,13 @@ public function testOnAuthenticationFailureFallsBackToDefaultHandlerIfNullIsRetu $this->failureHandler->expects($this->once()) ->method('onAuthenticationFailure') ->with($this->request, $this->authenticationException) - ->will($this->returnValue($this->response)); + ->willReturn($this->response); $authenticator = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Tests\TestFailureHandlerInterface'); $authenticator->expects($this->once()) ->method('onAuthenticationFailure') ->with($this->request, $this->authenticationException) - ->will($this->returnValue(null)); + ->willReturn(null); $handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler); $result = $handler->onAuthenticationFailure($this->request, $this->authenticationException); diff --git a/src/Symfony/Component/Security/Http/Tests/EntryPoint/FormAuthenticationEntryPointTest.php b/src/Symfony/Component/Security/Http/Tests/EntryPoint/FormAuthenticationEntryPointTest.php index 2e43f4ba63d65..999ff728bf461 100644 --- a/src/Symfony/Component/Security/Http/Tests/EntryPoint/FormAuthenticationEntryPointTest.php +++ b/src/Symfony/Component/Security/Http/Tests/EntryPoint/FormAuthenticationEntryPointTest.php @@ -29,7 +29,7 @@ public function testStart() ->expects($this->once()) ->method('createRedirectResponse') ->with($this->equalTo($request), $this->equalTo('/the/login/path')) - ->will($this->returnValue($response)) + ->willReturn($response) ; $entryPoint = new FormAuthenticationEntryPoint($httpKernel, $httpUtils, '/the/login/path', false); @@ -48,7 +48,7 @@ public function testStartWithUseForward() ->expects($this->once()) ->method('createRequest') ->with($this->equalTo($request), $this->equalTo('/the/login/path')) - ->will($this->returnValue($subRequest)) + ->willReturn($subRequest) ; $httpKernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); @@ -56,7 +56,7 @@ public function testStartWithUseForward() ->expects($this->once()) ->method('handle') ->with($this->equalTo($subRequest), $this->equalTo(HttpKernelInterface::SUB_REQUEST)) - ->will($this->returnValue($response)) + ->willReturn($response) ; $entryPoint = new FormAuthenticationEntryPoint($httpKernel, $httpUtils, '/the/login/path', true); diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php index 44bbf4423be5b..c4ccdd6a69b2e 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php @@ -31,7 +31,7 @@ public function testHandleWithValidValues() $tokenStorage ->expects($this->any()) ->method('getToken') - ->will($this->returnValue(null)) + ->willReturn(null) ; $tokenStorage ->expects($this->once()) @@ -44,7 +44,7 @@ public function testHandleWithValidValues() ->expects($this->once()) ->method('authenticate') ->with($this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken')) - ->will($this->returnValue($token)) + ->willReturn($token) ; $listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', [ @@ -55,13 +55,13 @@ public function testHandleWithValidValues() $listener ->expects($this->once()) ->method('getPreAuthenticatedData') - ->will($this->returnValue($userCredentials)); + ->willReturn($userCredentials); $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $listener->handle($event); @@ -77,7 +77,7 @@ public function testHandleWhenAuthenticationFails() $tokenStorage ->expects($this->any()) ->method('getToken') - ->will($this->returnValue(null)) + ->willReturn(null) ; $tokenStorage ->expects($this->never()) @@ -101,13 +101,13 @@ public function testHandleWhenAuthenticationFails() $listener ->expects($this->once()) ->method('getPreAuthenticatedData') - ->will($this->returnValue($userCredentials)); + ->willReturn($userCredentials); $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $listener->handle($event); @@ -125,7 +125,7 @@ public function testHandleWhenAuthenticationFailsWithDifferentToken() $tokenStorage ->expects($this->any()) ->method('getToken') - ->will($this->returnValue($token)) + ->willReturn($token) ; $tokenStorage ->expects($this->never()) @@ -149,13 +149,13 @@ public function testHandleWhenAuthenticationFailsWithDifferentToken() $listener ->expects($this->once()) ->method('getPreAuthenticatedData') - ->will($this->returnValue($userCredentials)); + ->willReturn($userCredentials); $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $listener->handle($event); @@ -173,7 +173,7 @@ public function testHandleWithASimilarAuthenticatedToken() $tokenStorage ->expects($this->any()) ->method('getToken') - ->will($this->returnValue($token)) + ->willReturn($token) ; $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); @@ -190,13 +190,13 @@ public function testHandleWithASimilarAuthenticatedToken() $listener ->expects($this->once()) ->method('getPreAuthenticatedData') - ->will($this->returnValue($userCredentials)); + ->willReturn($userCredentials); $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $listener->handle($event); @@ -214,7 +214,7 @@ public function testHandleWithAnInvalidSimilarToken() $tokenStorage ->expects($this->any()) ->method('getToken') - ->will($this->returnValue($token)) + ->willReturn($token) ; $tokenStorage ->expects($this->once()) @@ -239,13 +239,13 @@ public function testHandleWithAnInvalidSimilarToken() $listener ->expects($this->once()) ->method('getPreAuthenticatedData') - ->will($this->returnValue($userCredentials)); + ->willReturn($userCredentials); $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $listener->handle($event); diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php index 92b2270877fbc..0bb27258befe0 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php @@ -28,21 +28,21 @@ public function testHandleWhenTheAccessDecisionManagerDecidesToRefuseAccess() ->expects($this->any()) ->method('getPatterns') ->with($this->equalTo($request)) - ->will($this->returnValue([['foo' => 'bar'], null])) + ->willReturn([['foo' => 'bar'], null]) ; $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token ->expects($this->any()) ->method('isAuthenticated') - ->will($this->returnValue(true)) + ->willReturn(true) ; $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') - ->will($this->returnValue($token)) + ->willReturn($token) ; $accessDecisionManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface')->getMock(); @@ -50,7 +50,7 @@ public function testHandleWhenTheAccessDecisionManagerDecidesToRefuseAccess() ->expects($this->once()) ->method('decide') ->with($this->equalTo($token), $this->equalTo(['foo' => 'bar']), $this->equalTo($request)) - ->will($this->returnValue(false)) + ->willReturn(false) ; $listener = new AccessListener( @@ -64,7 +64,7 @@ public function testHandleWhenTheAccessDecisionManagerDecidesToRefuseAccess() $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $listener->handle($event); @@ -79,21 +79,21 @@ public function testHandleWhenTheTokenIsNotAuthenticated() ->expects($this->any()) ->method('getPatterns') ->with($this->equalTo($request)) - ->will($this->returnValue([['foo' => 'bar'], null])) + ->willReturn([['foo' => 'bar'], null]) ; $notAuthenticatedToken = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $notAuthenticatedToken ->expects($this->any()) ->method('isAuthenticated') - ->will($this->returnValue(false)) + ->willReturn(false) ; $authenticatedToken = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $authenticatedToken ->expects($this->any()) ->method('isAuthenticated') - ->will($this->returnValue(true)) + ->willReturn(true) ; $authManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); @@ -101,14 +101,14 @@ public function testHandleWhenTheTokenIsNotAuthenticated() ->expects($this->once()) ->method('authenticate') ->with($this->equalTo($notAuthenticatedToken)) - ->will($this->returnValue($authenticatedToken)) + ->willReturn($authenticatedToken) ; $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') - ->will($this->returnValue($notAuthenticatedToken)) + ->willReturn($notAuthenticatedToken) ; $tokenStorage ->expects($this->once()) @@ -121,7 +121,7 @@ public function testHandleWhenTheTokenIsNotAuthenticated() ->expects($this->once()) ->method('decide') ->with($this->equalTo($authenticatedToken), $this->equalTo(['foo' => 'bar']), $this->equalTo($request)) - ->will($this->returnValue(true)) + ->willReturn(true) ; $listener = new AccessListener( @@ -135,7 +135,7 @@ public function testHandleWhenTheTokenIsNotAuthenticated() $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $listener->handle($event); @@ -150,7 +150,7 @@ public function testHandleWhenThereIsNoAccessMapEntryMatchingTheRequest() ->expects($this->any()) ->method('getPatterns') ->with($this->equalTo($request)) - ->will($this->returnValue([null, null])) + ->willReturn([null, null]) ; $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); @@ -163,7 +163,7 @@ public function testHandleWhenThereIsNoAccessMapEntryMatchingTheRequest() $tokenStorage ->expects($this->any()) ->method('getToken') - ->will($this->returnValue($token)) + ->willReturn($token) ; $listener = new AccessListener( @@ -177,7 +177,7 @@ public function testHandleWhenThereIsNoAccessMapEntryMatchingTheRequest() $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $listener->handle($event); @@ -192,7 +192,7 @@ public function testHandleWhenTheSecurityTokenStorageHasNoToken() $tokenStorage ->expects($this->any()) ->method('getToken') - ->will($this->returnValue(null)) + ->willReturn(null) ; $listener = new AccessListener( diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php index f6f36415d37e1..15b151a5cf828 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php @@ -23,7 +23,7 @@ public function testHandleWithTokenStorageHavingAToken() $tokenStorage ->expects($this->any()) ->method('getToken') - ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())) + ->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()) ; $tokenStorage ->expects($this->never()) @@ -46,7 +46,7 @@ public function testHandleWithTokenStorageHavingNoToken() $tokenStorage ->expects($this->any()) ->method('getToken') - ->will($this->returnValue(null)) + ->willReturn(null) ; $anonymousToken = new AnonymousToken('TheSecret', 'anon.', []); @@ -58,7 +58,7 @@ public function testHandleWithTokenStorageHavingNoToken() ->with($this->callback(function ($token) { return 'TheSecret' === $token->getSecret(); })) - ->will($this->returnValue($anonymousToken)) + ->willReturn($anonymousToken) ; $tokenStorage diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/BasicAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/BasicAuthenticationListenerTest.php index 2eec46b1d16a6..e331542369f53 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/BasicAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/BasicAuthenticationListenerTest.php @@ -34,7 +34,7 @@ public function testHandleWithValidUsernameAndPasswordServerParameters() $tokenStorage ->expects($this->any()) ->method('getToken') - ->will($this->returnValue(null)) + ->willReturn(null) ; $tokenStorage ->expects($this->once()) @@ -47,7 +47,7 @@ public function testHandleWithValidUsernameAndPasswordServerParameters() ->expects($this->once()) ->method('authenticate') ->with($this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken')) - ->will($this->returnValue($token)) + ->willReturn($token) ; $listener = new BasicAuthenticationListener( @@ -61,7 +61,7 @@ public function testHandleWithValidUsernameAndPasswordServerParameters() $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $listener->handle($event); @@ -80,7 +80,7 @@ public function testHandleWhenAuthenticationFails() $tokenStorage ->expects($this->any()) ->method('getToken') - ->will($this->returnValue(null)) + ->willReturn(null) ; $tokenStorage ->expects($this->never()) @@ -94,7 +94,7 @@ public function testHandleWhenAuthenticationFails() ->expects($this->any()) ->method('start') ->with($this->equalTo($request), $this->isInstanceOf('Symfony\Component\Security\Core\Exception\AuthenticationException')) - ->will($this->returnValue($response)) + ->willReturn($response) ; $listener = new BasicAuthenticationListener( @@ -108,7 +108,7 @@ public function testHandleWhenAuthenticationFails() $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $event ->expects($this->once()) @@ -140,7 +140,7 @@ public function testHandleWithNoUsernameServerParameter() $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $listener->handle($event); @@ -156,7 +156,7 @@ public function testHandleWithASimilarAuthenticatedToken() $tokenStorage ->expects($this->any()) ->method('getToken') - ->will($this->returnValue($token)) + ->willReturn($token) ; $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); @@ -176,7 +176,7 @@ public function testHandleWithASimilarAuthenticatedToken() $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $listener->handle($event); @@ -209,7 +209,7 @@ public function testHandleWithADifferentAuthenticatedToken() $tokenStorage ->expects($this->any()) ->method('getToken') - ->will($this->returnValue($token)) + ->willReturn($token) ; $tokenStorage ->expects($this->never()) @@ -223,7 +223,7 @@ public function testHandleWithADifferentAuthenticatedToken() ->expects($this->any()) ->method('start') ->with($this->equalTo($request), $this->isInstanceOf('Symfony\Component\Security\Core\Exception\AuthenticationException')) - ->will($this->returnValue($response)) + ->willReturn($response) ; $listener = new BasicAuthenticationListener( @@ -237,7 +237,7 @@ public function testHandleWithADifferentAuthenticatedToken() $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $event ->expects($this->once()) diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/ChannelListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/ChannelListenerTest.php index 3740faec8ba8e..3511c629c1d4e 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/ChannelListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/ChannelListenerTest.php @@ -23,7 +23,7 @@ public function testHandleWithNotSecuredRequestAndHttpChannel() $request ->expects($this->any()) ->method('isSecure') - ->will($this->returnValue(false)) + ->willReturn(false) ; $accessMap = $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock(); @@ -31,7 +31,7 @@ public function testHandleWithNotSecuredRequestAndHttpChannel() ->expects($this->any()) ->method('getPatterns') ->with($this->equalTo($request)) - ->will($this->returnValue([[], 'http'])) + ->willReturn([[], 'http']) ; $entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock(); @@ -44,7 +44,7 @@ public function testHandleWithNotSecuredRequestAndHttpChannel() $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $event ->expects($this->never()) @@ -61,7 +61,7 @@ public function testHandleWithSecuredRequestAndHttpsChannel() $request ->expects($this->any()) ->method('isSecure') - ->will($this->returnValue(true)) + ->willReturn(true) ; $accessMap = $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock(); @@ -69,7 +69,7 @@ public function testHandleWithSecuredRequestAndHttpsChannel() ->expects($this->any()) ->method('getPatterns') ->with($this->equalTo($request)) - ->will($this->returnValue([[], 'https'])) + ->willReturn([[], 'https']) ; $entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock(); @@ -82,7 +82,7 @@ public function testHandleWithSecuredRequestAndHttpsChannel() $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $event ->expects($this->never()) @@ -99,7 +99,7 @@ public function testHandleWithNotSecuredRequestAndHttpsChannel() $request ->expects($this->any()) ->method('isSecure') - ->will($this->returnValue(false)) + ->willReturn(false) ; $response = new Response(); @@ -109,7 +109,7 @@ public function testHandleWithNotSecuredRequestAndHttpsChannel() ->expects($this->any()) ->method('getPatterns') ->with($this->equalTo($request)) - ->will($this->returnValue([[], 'https'])) + ->willReturn([[], 'https']) ; $entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock(); @@ -117,14 +117,14 @@ public function testHandleWithNotSecuredRequestAndHttpsChannel() ->expects($this->once()) ->method('start') ->with($this->equalTo($request)) - ->will($this->returnValue($response)) + ->willReturn($response) ; $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $event ->expects($this->once()) @@ -142,7 +142,7 @@ public function testHandleWithSecuredRequestAndHttpChannel() $request ->expects($this->any()) ->method('isSecure') - ->will($this->returnValue(true)) + ->willReturn(true) ; $response = new Response(); @@ -152,7 +152,7 @@ public function testHandleWithSecuredRequestAndHttpChannel() ->expects($this->any()) ->method('getPatterns') ->with($this->equalTo($request)) - ->will($this->returnValue([[], 'http'])) + ->willReturn([[], 'http']) ; $entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock(); @@ -160,14 +160,14 @@ public function testHandleWithSecuredRequestAndHttpChannel() ->expects($this->once()) ->method('start') ->with($this->equalTo($request)) - ->will($this->returnValue($response)) + ->willReturn($response) ; $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $event ->expects($this->once()) diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php index 8df2f40acd116..250b26cfef6ec 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php @@ -151,17 +151,17 @@ public function testInvalidTokenInSession($token) $event->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)); + ->willReturn($request); $request->expects($this->any()) ->method('hasPreviousSession') - ->will($this->returnValue(true)); + ->willReturn(true); $request->expects($this->any()) ->method('getSession') - ->will($this->returnValue($session)); + ->willReturn($session); $session->expects($this->any()) ->method('get') ->with('_security_key123') - ->will($this->returnValue($token)); + ->willReturn($token); $tokenStorage->expects($this->once()) ->method('setToken') ->with(null); @@ -193,10 +193,10 @@ public function testHandleAddsKernelResponseListener() $event->expects($this->any()) ->method('isMasterRequest') - ->will($this->returnValue(true)); + ->willReturn(true); $event->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock())); + ->willReturn($this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock()); $dispatcher->expects($this->once()) ->method('addListener') @@ -218,14 +218,14 @@ public function testOnKernelResponseListenerRemovesItself() $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); $request->expects($this->any()) ->method('hasSession') - ->will($this->returnValue(true)); + ->willReturn(true); $event->expects($this->any()) ->method('isMasterRequest') - ->will($this->returnValue(true)); + ->willReturn(true); $event->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)); + ->willReturn($request); $dispatcher->expects($this->once()) ->method('removeListener') @@ -237,12 +237,12 @@ public function testOnKernelResponseListenerRemovesItself() public function testHandleRemovesTokenIfNoPreviousSessionWasFound() { $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); - $request->expects($this->any())->method('hasPreviousSession')->will($this->returnValue(false)); + $request->expects($this->any())->method('hasPreviousSession')->willReturn(false); $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent') ->disableOriginalConstructor() ->getMock(); - $event->expects($this->any())->method('getRequest')->will($this->returnValue($request)); + $event->expects($this->any())->method('getRequest')->willReturn($request); $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage->expects($this->once())->method('setToken')->with(null); diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/DigestAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/DigestAuthenticationListenerTest.php index b5378902ea9f7..5dbd2cd0feb5a 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/DigestAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/DigestAuthenticationListenerTest.php @@ -47,7 +47,7 @@ public function testHandleWithValidDigest() $tokenStorage ->expects($this->once()) ->method('getToken') - ->will($this->returnValue(null)) + ->willReturn(null) ; $tokenStorage ->expects($this->once()) @@ -64,7 +64,7 @@ public function testHandleWithValidDigest() $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $listener->handle($event); diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php index 53fedebcad705..1dda0ab968c78 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php @@ -77,7 +77,7 @@ public function testExceptionWhenEntryPointReturnsBadValue() $event = $this->createEvent(new AuthenticationException()); $entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock(); - $entryPoint->expects($this->once())->method('start')->will($this->returnValue('NOT A RESPONSE')); + $entryPoint->expects($this->once())->method('start')->willReturn('NOT A RESPONSE'); $listener = $this->createExceptionListener(null, null, null, $entryPoint); $listener->onKernelException($event); @@ -106,12 +106,12 @@ public function testAccessDeniedExceptionFullFledgedAndWithoutAccessDeniedHandle public function testAccessDeniedExceptionFullFledgedAndWithoutAccessDeniedHandlerAndWithErrorPage(\Exception $exception, \Exception $eventException = null) { $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); - $kernel->expects($this->once())->method('handle')->will($this->returnValue(new Response('Unauthorized', 401))); + $kernel->expects($this->once())->method('handle')->willReturn(new Response('Unauthorized', 401)); $event = $this->createEvent($exception, $kernel); $httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock(); - $httpUtils->expects($this->once())->method('createRequest')->will($this->returnValue(Request::create('/error'))); + $httpUtils->expects($this->once())->method('createRequest')->willReturn(Request::create('/error')); $listener = $this->createExceptionListener(null, $this->createTrustResolver(true), $httpUtils, null, '/error'); $listener->onKernelException($event); @@ -131,7 +131,7 @@ public function testAccessDeniedExceptionFullFledgedAndWithAccessDeniedHandlerAn $event = $this->createEvent($exception); $accessDeniedHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authorization\AccessDeniedHandlerInterface')->getMock(); - $accessDeniedHandler->expects($this->once())->method('handle')->will($this->returnValue(new Response('error'))); + $accessDeniedHandler->expects($this->once())->method('handle')->willReturn(new Response('error')); $listener = $this->createExceptionListener(null, $this->createTrustResolver(true), null, null, null, $accessDeniedHandler); $listener->onKernelException($event); @@ -148,7 +148,7 @@ public function testAccessDeniedExceptionNotFullFledged(\Exception $exception, \ $event = $this->createEvent($exception); $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); - $tokenStorage->expects($this->once())->method('getToken')->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())); + $tokenStorage->expects($this->once())->method('getToken')->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); $listener = $this->createExceptionListener($tokenStorage, $this->createTrustResolver(false), null, $this->createEntryPoint()); $listener->onKernelException($event); @@ -171,7 +171,7 @@ public function getAccessDeniedExceptionProvider() private function createEntryPoint(Response $response = null) { $entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock(); - $entryPoint->expects($this->once())->method('start')->will($this->returnValue($response ?: new Response('OK'))); + $entryPoint->expects($this->once())->method('start')->willReturn($response ?: new Response('OK')); return $entryPoint; } @@ -179,7 +179,7 @@ private function createEntryPoint(Response $response = null) private function createTrustResolver($fullFledged) { $trustResolver = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface')->getMock(); - $trustResolver->expects($this->once())->method('isFullFledged')->will($this->returnValue($fullFledged)); + $trustResolver->expects($this->once())->method('isFullFledged')->willReturn($fullFledged); return $trustResolver; } diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php index fbcea3d738e70..3796f871562c6 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php @@ -30,7 +30,7 @@ public function testHandleUnmatchedPath() $httpUtils->expects($this->once()) ->method('checkRequestPath') ->with($request, $options['logout_path']) - ->will($this->returnValue(false)); + ->willReturn(false); $listener->handle($event); } @@ -49,20 +49,20 @@ public function testHandleMatchedPathWithSuccessHandlerAndCsrfValidation() $httpUtils->expects($this->once()) ->method('checkRequestPath') ->with($request, $options['logout_path']) - ->will($this->returnValue(true)); + ->willReturn(true); $tokenManager->expects($this->once()) ->method('isTokenValid') - ->will($this->returnValue(true)); + ->willReturn(true); $successHandler->expects($this->once()) ->method('onLogoutSuccess') ->with($request) - ->will($this->returnValue($response = new Response())); + ->willReturn($response = new Response()); $tokenStorage->expects($this->once()) ->method('getToken') - ->will($this->returnValue($token = $this->getToken())); + ->willReturn($token = $this->getToken()); $handler = $this->getHandler(); $handler->expects($this->once()) @@ -93,16 +93,16 @@ public function testHandleMatchedPathWithoutSuccessHandlerAndCsrfValidation() $httpUtils->expects($this->once()) ->method('checkRequestPath') ->with($request, $options['logout_path']) - ->will($this->returnValue(true)); + ->willReturn(true); $successHandler->expects($this->once()) ->method('onLogoutSuccess') ->with($request) - ->will($this->returnValue($response = new Response())); + ->willReturn($response = new Response()); $tokenStorage->expects($this->once()) ->method('getToken') - ->will($this->returnValue($token = $this->getToken())); + ->willReturn($token = $this->getToken()); $handler = $this->getHandler(); $handler->expects($this->once()) @@ -136,12 +136,12 @@ public function testSuccessHandlerReturnsNonResponse() $httpUtils->expects($this->once()) ->method('checkRequestPath') ->with($request, $options['logout_path']) - ->will($this->returnValue(true)); + ->willReturn(true); $successHandler->expects($this->once()) ->method('onLogoutSuccess') ->with($request) - ->will($this->returnValue(null)); + ->willReturn(null); $listener->handle($event); } @@ -162,11 +162,11 @@ public function testCsrfValidationFails() $httpUtils->expects($this->once()) ->method('checkRequestPath') ->with($request, $options['logout_path']) - ->will($this->returnValue(true)); + ->willReturn(true); $tokenManager->expects($this->once()) ->method('isTokenValid') - ->will($this->returnValue(false)); + ->willReturn(false); $listener->handle($event); } @@ -189,7 +189,7 @@ private function getGetResponseEvent() $event->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request = new Request())); + ->willReturn($request = new Request()); return [$event, $request]; } diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php index 686c7231e6899..57d297103ec80 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php @@ -26,7 +26,7 @@ public function testOnCoreSecurityDoesNotTryToPopulateNonEmptyTokenStorage() $tokenStorage ->expects($this->once()) ->method('getToken') - ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())) + ->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()) ; $tokenStorage @@ -44,20 +44,20 @@ public function testOnCoreSecurityDoesNothingWhenNoCookieIsSet() $tokenStorage ->expects($this->once()) ->method('getToken') - ->will($this->returnValue(null)) + ->willReturn(null) ; $service ->expects($this->once()) ->method('autoLogin') - ->will($this->returnValue(null)) + ->willReturn(null) ; $event = $this->getGetResponseEvent(); $event ->expects($this->once()) ->method('getRequest') - ->will($this->returnValue(new Request())) + ->willReturn(new Request()) ; $this->assertNull($listener->handle($event)); @@ -72,13 +72,13 @@ public function testOnCoreSecurityIgnoresAuthenticationExceptionThrownByAuthenti $tokenStorage ->expects($this->once()) ->method('getToken') - ->will($this->returnValue(null)) + ->willReturn(null) ; $service ->expects($this->once()) ->method('autoLogin') - ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())) + ->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()) ; $service @@ -97,7 +97,7 @@ public function testOnCoreSecurityIgnoresAuthenticationExceptionThrownByAuthenti $event ->expects($this->once()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $listener->handle($event); @@ -114,13 +114,13 @@ public function testOnCoreSecurityIgnoresAuthenticationOptionallyRethrowsExcepti $tokenStorage ->expects($this->once()) ->method('getToken') - ->will($this->returnValue(null)) + ->willReturn(null) ; $service ->expects($this->once()) ->method('autoLogin') - ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())) + ->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()) ; $service @@ -139,7 +139,7 @@ public function testOnCoreSecurityIgnoresAuthenticationOptionallyRethrowsExcepti $event ->expects($this->once()) ->method('getRequest') - ->will($this->returnValue(new Request())) + ->willReturn(new Request()) ; $listener->handle($event); @@ -152,7 +152,7 @@ public function testOnCoreSecurityAuthenticationExceptionDuringAutoLoginTriggers $tokenStorage ->expects($this->once()) ->method('getToken') - ->will($this->returnValue(null)) + ->willReturn(null) ; $exception = new AuthenticationException('Authentication failed.'); @@ -176,7 +176,7 @@ public function testOnCoreSecurityAuthenticationExceptionDuringAutoLoginTriggers $event ->expects($this->once()) ->method('getRequest') - ->will($this->returnValue(new Request())) + ->willReturn(new Request()) ; $listener->handle($event); @@ -189,14 +189,14 @@ public function testOnCoreSecurity() $tokenStorage ->expects($this->once()) ->method('getToken') - ->will($this->returnValue(null)) + ->willReturn(null) ; $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $service ->expects($this->once()) ->method('autoLogin') - ->will($this->returnValue($token)) + ->willReturn($token) ; $tokenStorage @@ -208,14 +208,14 @@ public function testOnCoreSecurity() $manager ->expects($this->once()) ->method('authenticate') - ->will($this->returnValue($token)) + ->willReturn($token) ; $event = $this->getGetResponseEvent(); $event ->expects($this->once()) ->method('getRequest') - ->will($this->returnValue(new Request())) + ->willReturn(new Request()) ; $listener->handle($event); @@ -228,14 +228,14 @@ public function testSessionStrategy() $tokenStorage ->expects($this->once()) ->method('getToken') - ->will($this->returnValue(null)) + ->willReturn(null) ; $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $service ->expects($this->once()) ->method('autoLogin') - ->will($this->returnValue($token)) + ->willReturn($token) ; $tokenStorage @@ -247,40 +247,40 @@ public function testSessionStrategy() $manager ->expects($this->once()) ->method('authenticate') - ->will($this->returnValue($token)) + ->willReturn($token) ; $session = $this->getMockBuilder('\Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock(); $session ->expects($this->once()) ->method('isStarted') - ->will($this->returnValue(true)) + ->willReturn(true) ; $request = $this->getMockBuilder('\Symfony\Component\HttpFoundation\Request')->getMock(); $request ->expects($this->once()) ->method('hasSession') - ->will($this->returnValue(true)) + ->willReturn(true) ; $request ->expects($this->once()) ->method('getSession') - ->will($this->returnValue($session)) + ->willReturn($session) ; $event = $this->getGetResponseEvent(); $event ->expects($this->once()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $sessionStrategy ->expects($this->once()) ->method('onAuthentication') - ->will($this->returnValue(null)) + ->willReturn(null) ; $listener->handle($event); @@ -293,14 +293,14 @@ public function testSessionIsMigratedByDefault() $tokenStorage ->expects($this->once()) ->method('getToken') - ->will($this->returnValue(null)) + ->willReturn(null) ; $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $service ->expects($this->once()) ->method('autoLogin') - ->will($this->returnValue($token)) + ->willReturn($token) ; $tokenStorage @@ -312,14 +312,14 @@ public function testSessionIsMigratedByDefault() $manager ->expects($this->once()) ->method('authenticate') - ->will($this->returnValue($token)) + ->willReturn($token) ; $session = $this->getMockBuilder('\Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock(); $session ->expects($this->once()) ->method('isStarted') - ->will($this->returnValue(true)) + ->willReturn(true) ; $session ->expects($this->once()) @@ -330,20 +330,20 @@ public function testSessionIsMigratedByDefault() $request ->expects($this->any()) ->method('hasSession') - ->will($this->returnValue(true)) + ->willReturn(true) ; $request ->expects($this->any()) ->method('getSession') - ->will($this->returnValue($session)) + ->willReturn($session) ; $event = $this->getGetResponseEvent(); $event ->expects($this->once()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $listener->handle($event); @@ -356,14 +356,14 @@ public function testOnCoreSecurityInteractiveLoginEventIsDispatchedIfDispatcherI $tokenStorage ->expects($this->once()) ->method('getToken') - ->will($this->returnValue(null)) + ->willReturn(null) ; $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $service ->expects($this->once()) ->method('autoLogin') - ->will($this->returnValue($token)) + ->willReturn($token) ; $tokenStorage @@ -375,7 +375,7 @@ public function testOnCoreSecurityInteractiveLoginEventIsDispatchedIfDispatcherI $manager ->expects($this->once()) ->method('authenticate') - ->will($this->returnValue($token)) + ->willReturn($token) ; $event = $this->getGetResponseEvent(); @@ -383,7 +383,7 @@ public function testOnCoreSecurityInteractiveLoginEventIsDispatchedIfDispatcherI $event ->expects($this->once()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $dispatcher diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php index 8739e1b62abb3..1584b66ecee44 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php @@ -40,7 +40,7 @@ public function testHandle() ->expects($this->once()) ->method('authenticate') ->with($this->equalTo($this->token)) - ->will($this->returnValue($this->token)) + ->willReturn($this->token) ; $simpleAuthenticator = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\SimplePreAuthenticatorInterface')->getMock(); @@ -48,7 +48,7 @@ public function testHandle() ->expects($this->once()) ->method('createToken') ->with($this->equalTo($this->request), $this->equalTo('secured_area')) - ->will($this->returnValue($this->token)) + ->willReturn($this->token) ; $loginEvent = new InteractiveLoginEvent($this->request, $this->token); @@ -85,7 +85,7 @@ public function testHandlecatchAuthenticationException() ->expects($this->once()) ->method('createToken') ->with($this->equalTo($this->request), $this->equalTo('secured_area')) - ->will($this->returnValue($this->token)) + ->willReturn($this->token) ; $listener = new SimplePreAuthenticationListener($this->tokenStorage, $this->authenticationManager, 'secured_area', $simpleAuthenticator, $this->logger, $this->dispatcher); @@ -108,7 +108,7 @@ protected function setUp() $this->event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($this->request)) + ->willReturn($this->request) ; $this->logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php index 709bc4c862f9e..2d22a91d6bdeb 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php @@ -167,7 +167,7 @@ public function testSwitchUserIsDisallowed() $this->accessDecisionManager->expects($this->once()) ->method('decide')->with($token, ['ROLE_ALLOWED_TO_SWITCH']) - ->will($this->returnValue(false)); + ->willReturn(false); $listener = new SwitchUserListener($this->tokenStorage, $this->userProvider, $this->userChecker, 'provider123', $this->accessDecisionManager); $listener->handle($this->event); @@ -183,11 +183,11 @@ public function testSwitchUser() $this->accessDecisionManager->expects($this->once()) ->method('decide')->with($token, ['ROLE_ALLOWED_TO_SWITCH']) - ->will($this->returnValue(true)); + ->willReturn(true); $this->userProvider->expects($this->once()) ->method('loadUserByUsername')->with('kuba') - ->will($this->returnValue($user)); + ->willReturn($user); $this->userChecker->expects($this->once()) ->method('checkPostAuth')->with($user); @@ -213,11 +213,11 @@ public function testSwitchUserKeepsOtherQueryStringParameters() $this->accessDecisionManager->expects($this->once()) ->method('decide')->with($token, ['ROLE_ALLOWED_TO_SWITCH']) - ->will($this->returnValue(true)); + ->willReturn(true); $this->userProvider->expects($this->once()) ->method('loadUserByUsername')->with('kuba') - ->will($this->returnValue($user)); + ->willReturn($user); $this->userChecker->expects($this->once()) ->method('checkPostAuth')->with($user); @@ -241,11 +241,11 @@ public function testSwitchUserWithReplacedToken() $this->accessDecisionManager->expects($this->any()) ->method('decide')->with($token, ['ROLE_ALLOWED_TO_SWITCH']) - ->will($this->returnValue(true)); + ->willReturn(true); $this->userProvider->expects($this->any()) ->method('loadUserByUsername')->with('kuba') - ->will($this->returnValue($user)); + ->willReturn($user); $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); $dispatcher @@ -288,11 +288,11 @@ public function testSwitchUserStateless() $this->accessDecisionManager->expects($this->once()) ->method('decide')->with($token, ['ROLE_ALLOWED_TO_SWITCH']) - ->will($this->returnValue(true)); + ->willReturn(true); $this->userProvider->expects($this->once()) ->method('loadUserByUsername')->with('kuba') - ->will($this->returnValue($user)); + ->willReturn($user); $this->userChecker->expects($this->once()) ->method('checkPostAuth')->with($user); diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php index f1536db6d25a6..61455745289df 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php @@ -38,21 +38,21 @@ public function testHandleWhenUsernameLength($username, $ok) $httpUtils ->expects($this->any()) ->method('checkRequestPath') - ->will($this->returnValue(true)) + ->willReturn(true) ; $failureHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface')->getMock(); $failureHandler ->expects($ok ? $this->never() : $this->once()) ->method('onAuthenticationFailure') - ->will($this->returnValue(new Response())) + ->willReturn(new Response()) ; $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager')->disableOriginalConstructor()->getMock(); $authenticationManager ->expects($ok ? $this->once() : $this->never()) ->method('authenticate') - ->will($this->returnValue(new Response())) + ->willReturn(new Response()) ; $listener = new UsernamePasswordFormAuthenticationListener( @@ -70,7 +70,7 @@ public function testHandleWhenUsernameLength($username, $ok) $event ->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($request)) + ->willReturn($request) ; $listener->handle($event); @@ -154,7 +154,7 @@ public function testHandleNonStringUsernameWith__toString($postOnly) $usernameClass ->expects($this->atLeastOnce()) ->method('__toString') - ->will($this->returnValue('someUsername')); + ->willReturn('someUsername'); $request = Request::create('/login_check', 'POST', ['_username' => $usernameClass]); $request->setSession($this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock()); diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordJsonAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordJsonAuthenticationListenerTest.php index ed7acfbe5d7a7..7d2e55906b1d9 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordJsonAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordJsonAuthenticationListenerTest.php @@ -43,7 +43,7 @@ private function createListener(array $options = [], $success = true, $matchChec $httpUtils ->expects($this->any()) ->method('checkRequestPath') - ->will($this->returnValue($matchCheckPath)) + ->willReturn($matchCheckPath) ; $authenticationManager = $this->getMockBuilder(AuthenticationManagerInterface::class)->getMock(); diff --git a/src/Symfony/Component/Security/Http/Tests/FirewallMapTest.php b/src/Symfony/Component/Security/Http/Tests/FirewallMapTest.php index 04fe3b4ea3052..a8eb97192dc70 100644 --- a/src/Symfony/Component/Security/Http/Tests/FirewallMapTest.php +++ b/src/Symfony/Component/Security/Http/Tests/FirewallMapTest.php @@ -28,7 +28,7 @@ public function testGetListeners() ->expects($this->once()) ->method('matches') ->with($this->equalTo($request)) - ->will($this->returnValue(false)) + ->willReturn(false) ; $map->add($notMatchingMatcher, [$this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock()]); @@ -38,7 +38,7 @@ public function testGetListeners() ->expects($this->once()) ->method('matches') ->with($this->equalTo($request)) - ->will($this->returnValue(true)) + ->willReturn(true) ; $theListener = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock(); $theException = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ExceptionListener')->disableOriginalConstructor()->getMock(); @@ -70,7 +70,7 @@ public function testGetListenersWithAnEntryHavingNoRequestMatcher() ->expects($this->once()) ->method('matches') ->with($this->equalTo($request)) - ->will($this->returnValue(false)) + ->willReturn(false) ; $map->add($notMatchingMatcher, [$this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock()]); @@ -105,7 +105,7 @@ public function testGetListenersWithNoMatchingEntry() ->expects($this->once()) ->method('matches') ->with($this->equalTo($request)) - ->will($this->returnValue(false)) + ->willReturn(false) ; $map->add($notMatchingMatcher, [$this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock()]); diff --git a/src/Symfony/Component/Security/Http/Tests/FirewallTest.php b/src/Symfony/Component/Security/Http/Tests/FirewallTest.php index 9113890b5e745..673a8be7139d0 100644 --- a/src/Symfony/Component/Security/Http/Tests/FirewallTest.php +++ b/src/Symfony/Component/Security/Http/Tests/FirewallTest.php @@ -37,7 +37,7 @@ public function testOnKernelRequestRegistersExceptionListener() ->expects($this->once()) ->method('getListeners') ->with($this->equalTo($request)) - ->will($this->returnValue([[], $listener])) + ->willReturn([[], $listener]) ; $event = new GetResponseEvent($this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $request, HttpKernelInterface::MASTER_REQUEST); @@ -66,7 +66,7 @@ public function testOnKernelRequestStopsWhenThereIsAResponse() $map ->expects($this->once()) ->method('getListeners') - ->will($this->returnValue([[$first, $second], null])) + ->willReturn([[$first, $second], null]) ; $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent') @@ -81,7 +81,7 @@ public function testOnKernelRequestStopsWhenThereIsAResponse() $event ->expects($this->at(0)) ->method('hasResponse') - ->will($this->returnValue(true)) + ->willReturn(true) ; $firewall = new Firewall($map, $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock()); diff --git a/src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php b/src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php index 5368f4683c741..a4a76747e5a58 100644 --- a/src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php +++ b/src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php @@ -92,12 +92,12 @@ public function testCreateRedirectResponseWithRouteName() ->expects($this->any()) ->method('generate') ->with('foobar', [], UrlGeneratorInterface::ABSOLUTE_URL) - ->will($this->returnValue('http://localhost/foo/bar')) + ->willReturn('http://localhost/foo/bar') ; $urlGenerator ->expects($this->any()) ->method('getContext') - ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Routing\RequestContext')->getMock())) + ->willReturn($this->getMockBuilder('Symfony\Component\Routing\RequestContext')->getMock()) ; $response = $utils->createRedirectResponse($this->getRequest(), 'foobar'); @@ -125,12 +125,12 @@ public function testCreateRequestWithRouteName() $urlGenerator ->expects($this->once()) ->method('generate') - ->will($this->returnValue('/foo/bar')) + ->willReturn('/foo/bar') ; $urlGenerator ->expects($this->any()) ->method('getContext') - ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Routing\RequestContext')->getMock())) + ->willReturn($this->getMockBuilder('Symfony\Component\Routing\RequestContext')->getMock()) ; $subRequest = $utils->createRequest($this->getRequest(), 'foobar'); @@ -229,7 +229,7 @@ public function testCheckRequestPathWithUrlMatcherAndResourceFoundByUrl() ->expects($this->any()) ->method('match') ->with('/foo/bar') - ->will($this->returnValue(['_route' => 'foobar'])) + ->willReturn(['_route' => 'foobar']) ; $utils = new HttpUtils(null, $urlMatcher); @@ -244,7 +244,7 @@ public function testCheckRequestPathWithUrlMatcherAndResourceFoundByRequest() ->expects($this->any()) ->method('matchRequest') ->with($request) - ->will($this->returnValue(['_route' => 'foobar'])) + ->willReturn(['_route' => 'foobar']) ; $utils = new HttpUtils(null, $urlMatcher); @@ -323,7 +323,7 @@ private function getUrlGenerator($generatedUrl = '/foo/bar') $urlGenerator ->expects($this->any()) ->method('generate') - ->will($this->returnValue($generatedUrl)) + ->willReturn($generatedUrl) ; return $urlGenerator; diff --git a/src/Symfony/Component/Security/Http/Tests/Logout/DefaultLogoutSuccessHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Logout/DefaultLogoutSuccessHandlerTest.php index 9936fc933957b..926f8cc4b23af 100644 --- a/src/Symfony/Component/Security/Http/Tests/Logout/DefaultLogoutSuccessHandlerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Logout/DefaultLogoutSuccessHandlerTest.php @@ -26,7 +26,7 @@ public function testLogout() $httpUtils->expects($this->once()) ->method('createRedirectResponse') ->with($request, '/dashboard') - ->will($this->returnValue($response)); + ->willReturn($response); $handler = new DefaultLogoutSuccessHandler($httpUtils, '/dashboard'); $result = $handler->onLogoutSuccess($request); diff --git a/src/Symfony/Component/Security/Http/Tests/Logout/SessionLogoutHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Logout/SessionLogoutHandlerTest.php index e32d46e3e577e..cf25d1f77c820 100644 --- a/src/Symfony/Component/Security/Http/Tests/Logout/SessionLogoutHandlerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Logout/SessionLogoutHandlerTest.php @@ -28,7 +28,7 @@ public function testLogout() $request ->expects($this->once()) ->method('getSession') - ->will($this->returnValue($session)) + ->willReturn($session) ; $session diff --git a/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php b/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php index 38b8474ffc38b..ade199c0b9224 100644 --- a/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php +++ b/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php @@ -51,7 +51,7 @@ public function testAutoLoginThrowsExceptionWhenImplementationDoesNotReturnUserI $service ->expects($this->once()) ->method('processAutoLoginCookie') - ->will($this->returnValue(null)) + ->willReturn(null) ; $service->autoLogin($request); @@ -67,13 +67,13 @@ public function testAutoLogin() $user ->expects($this->once()) ->method('getRoles') - ->will($this->returnValue([])) + ->willReturn([]) ; $service ->expects($this->once()) ->method('processAutoLoginCookie') - ->will($this->returnValue($user)) + ->willReturn($user) ; $returnedToken = $service->autoLogin($request); @@ -131,7 +131,7 @@ public function testLoginSuccessIsNotProcessedWhenTokenDoesNotContainUserInterfa $token ->expects($this->once()) ->method('getUser') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $service @@ -154,13 +154,13 @@ public function testLoginSuccessIsNotProcessedWhenRememberMeIsNotRequested() $token ->expects($this->once()) ->method('getUser') - ->will($this->returnValue($account)) + ->willReturn($account) ; $service ->expects($this->never()) ->method('onLoginSuccess') - ->will($this->returnValue(null)) + ->willReturn(null) ; $this->assertFalse($request->request->has('foo')); @@ -178,13 +178,13 @@ public function testLoginSuccessWhenRememberMeAlwaysIsTrue() $token ->expects($this->once()) ->method('getUser') - ->will($this->returnValue($account)) + ->willReturn($account) ; $service ->expects($this->once()) ->method('onLoginSuccess') - ->will($this->returnValue(null)) + ->willReturn(null) ; $service->loginSuccess($request, $response, $token); @@ -205,13 +205,13 @@ public function testLoginSuccessWhenRememberMeParameterWithPathIsPositive($value $token ->expects($this->once()) ->method('getUser') - ->will($this->returnValue($account)) + ->willReturn($account) ; $service ->expects($this->once()) ->method('onLoginSuccess') - ->will($this->returnValue(true)) + ->willReturn(true) ; $service->loginSuccess($request, $response, $token); @@ -232,13 +232,13 @@ public function testLoginSuccessWhenRememberMeParameterIsPositive($value) $token ->expects($this->once()) ->method('getUser') - ->will($this->returnValue($account)) + ->willReturn($account) ; $service ->expects($this->once()) ->method('onLoginSuccess') - ->will($this->returnValue(true)) + ->willReturn(true) ; $service->loginSuccess($request, $response, $token); @@ -296,7 +296,7 @@ protected function getProvider() $provider ->expects($this->any()) ->method('supportsClass') - ->will($this->returnValue(true)) + ->willReturn(true) ; return $provider; diff --git a/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php b/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php index 529b050c40b3e..599a7e81c303b 100644 --- a/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php +++ b/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php @@ -84,7 +84,7 @@ public function testAutoLoginReturnsNullOnNonExistentUser() $tokenProvider ->expects($this->once()) ->method('loadTokenBySeries') - ->will($this->returnValue(new PersistentToken('fooclass', 'fooname', 'fooseries', 'foovalue', new \DateTime()))) + ->willReturn(new PersistentToken('fooclass', 'fooname', 'fooseries', 'foovalue', new \DateTime())) ; $service->setTokenProvider($tokenProvider); @@ -111,14 +111,14 @@ public function testAutoLoginThrowsExceptionOnStolenCookieAndRemovesItFromThePer $tokenProvider ->expects($this->once()) ->method('loadTokenBySeries') - ->will($this->returnValue(new PersistentToken('fooclass', 'foouser', 'fooseries', 'anotherFooValue', new \DateTime()))) + ->willReturn(new PersistentToken('fooclass', 'foouser', 'fooseries', 'anotherFooValue', new \DateTime())) ; $tokenProvider ->expects($this->once()) ->method('deleteTokenBySeries') ->with($this->equalTo('fooseries')) - ->will($this->returnValue(null)) + ->willReturn(null) ; try { @@ -141,7 +141,7 @@ public function testAutoLoginDoesNotAcceptAnExpiredCookie() ->expects($this->once()) ->method('loadTokenBySeries') ->with($this->equalTo('fooseries')) - ->will($this->returnValue(new PersistentToken('fooclass', 'username', 'fooseries', 'foovalue', new \DateTime('yesterday')))) + ->willReturn(new PersistentToken('fooclass', 'username', 'fooseries', 'foovalue', new \DateTime('yesterday'))) ; $service->setTokenProvider($tokenProvider); @@ -155,7 +155,7 @@ public function testAutoLogin() $user ->expects($this->once()) ->method('getRoles') - ->will($this->returnValue(['ROLE_FOO'])) + ->willReturn(['ROLE_FOO']) ; $userProvider = $this->getProvider(); @@ -163,7 +163,7 @@ public function testAutoLogin() ->expects($this->once()) ->method('loadUserByUsername') ->with($this->equalTo('foouser')) - ->will($this->returnValue($user)) + ->willReturn($user) ; $service = $this->getService($userProvider, ['name' => 'foo', 'path' => null, 'domain' => null, 'secure' => false, 'httponly' => false, 'always_remember_me' => true, 'lifetime' => 3600]); @@ -175,7 +175,7 @@ public function testAutoLogin() ->expects($this->once()) ->method('loadTokenBySeries') ->with($this->equalTo('fooseries')) - ->will($this->returnValue(new PersistentToken('fooclass', 'foouser', 'fooseries', 'foovalue', new \DateTime()))) + ->willReturn(new PersistentToken('fooclass', 'foouser', 'fooseries', 'foovalue', new \DateTime())) ; $service->setTokenProvider($tokenProvider); @@ -200,7 +200,7 @@ public function testLogout() ->expects($this->once()) ->method('deleteTokenBySeries') ->with($this->equalTo('fooseries')) - ->will($this->returnValue(null)) + ->willReturn(null) ; $service->setTokenProvider($tokenProvider); @@ -276,13 +276,13 @@ public function testLoginSuccessSetsCookieWhenLoggedInWithNonRememberMeTokenInte $account ->expects($this->once()) ->method('getUsername') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token ->expects($this->any()) ->method('getUser') - ->will($this->returnValue($account)) + ->willReturn($account) ; $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); @@ -331,7 +331,7 @@ protected function getProvider() $provider ->expects($this->any()) ->method('supportsClass') - ->will($this->returnValue(true)) + ->willReturn(true) ; return $provider; diff --git a/src/Symfony/Component/Security/Http/Tests/RememberMe/ResponseListenerTest.php b/src/Symfony/Component/Security/Http/Tests/RememberMe/ResponseListenerTest.php index 501d3850fa649..465636eb9f77e 100644 --- a/src/Symfony/Component/Security/Http/Tests/RememberMe/ResponseListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/RememberMe/ResponseListenerTest.php @@ -95,9 +95,9 @@ private function getEvent($request, $response, $type = HttpKernelInterface::MAST ->disableOriginalConstructor() ->getMock(); - $event->expects($this->any())->method('getRequest')->will($this->returnValue($request)); - $event->expects($this->any())->method('isMasterRequest')->will($this->returnValue(HttpKernelInterface::MASTER_REQUEST === $type)); - $event->expects($this->any())->method('getResponse')->will($this->returnValue($response)); + $event->expects($this->any())->method('getRequest')->willReturn($request); + $event->expects($this->any())->method('isMasterRequest')->willReturn(HttpKernelInterface::MASTER_REQUEST === $type); + $event->expects($this->any())->method('getResponse')->willReturn($response); return $event; } diff --git a/src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php b/src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php index f0d938de84064..f24e4fff80805 100644 --- a/src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php +++ b/src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php @@ -67,14 +67,14 @@ public function testAutoLoginDoesNotAcceptCookieWithInvalidHash() $user ->expects($this->once()) ->method('getPassword') - ->will($this->returnValue('foopass')) + ->willReturn('foopass') ; $userProvider ->expects($this->once()) ->method('loadUserByUsername') ->with($this->equalTo('foouser')) - ->will($this->returnValue($user)) + ->willReturn($user) ; $this->assertNull($service->autoLogin($request)); @@ -92,14 +92,14 @@ public function testAutoLoginDoesNotAcceptAnExpiredCookie() $user ->expects($this->once()) ->method('getPassword') - ->will($this->returnValue('foopass')) + ->willReturn('foopass') ; $userProvider ->expects($this->once()) ->method('loadUserByUsername') ->with($this->equalTo('foouser')) - ->will($this->returnValue($user)) + ->willReturn($user) ; $this->assertNull($service->autoLogin($request)); @@ -117,12 +117,12 @@ public function testAutoLogin($username) $user ->expects($this->once()) ->method('getRoles') - ->will($this->returnValue(['ROLE_FOO'])) + ->willReturn(['ROLE_FOO']) ; $user ->expects($this->once()) ->method('getPassword') - ->will($this->returnValue('foopass')) + ->willReturn('foopass') ; $userProvider = $this->getProvider(); @@ -130,7 +130,7 @@ public function testAutoLogin($username) ->expects($this->once()) ->method('loadUserByUsername') ->with($this->equalTo($username)) - ->will($this->returnValue($user)) + ->willReturn($user) ; $service = $this->getService($userProvider, ['name' => 'foo', 'always_remember_me' => true, 'lifetime' => 3600]); @@ -191,7 +191,7 @@ public function testLoginSuccessIgnoresTokensWhichDoNotContainAnUserInterfaceImp $token ->expects($this->once()) ->method('getUser') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $cookies = $response->headers->getCookies(); @@ -214,17 +214,17 @@ public function testLoginSuccess() $user ->expects($this->once()) ->method('getPassword') - ->will($this->returnValue('foopass')) + ->willReturn('foopass') ; $user ->expects($this->once()) ->method('getUsername') - ->will($this->returnValue('foouser')) + ->willReturn('foouser') ; $token ->expects($this->atLeastOnce()) ->method('getUser') - ->will($this->returnValue($user)) + ->willReturn($user) ; $cookies = $response->headers->getCookies(); @@ -277,7 +277,7 @@ protected function getProvider() $provider ->expects($this->any()) ->method('supportsClass') - ->will($this->returnValue(true)) + ->willReturn(true) ; return $provider; diff --git a/src/Symfony/Component/Security/Http/Tests/Session/SessionAuthenticationStrategyTest.php b/src/Symfony/Component/Security/Http/Tests/Session/SessionAuthenticationStrategyTest.php index 271bc99cc5ba3..6c0df8cb5f2cb 100644 --- a/src/Symfony/Component/Security/Http/Tests/Session/SessionAuthenticationStrategyTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Session/SessionAuthenticationStrategyTest.php @@ -61,7 +61,7 @@ private function getRequest($session = null) $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); if (null !== $session) { - $request->expects($this->any())->method('getSession')->will($this->returnValue($session)); + $request->expects($this->any())->method('getSession')->willReturn($session); } return $request; diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/ChainDecoderTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/ChainDecoderTest.php index 3a84d99dde286..22b86758a590a 100644 --- a/src/Symfony/Component/Serializer/Tests/Encoder/ChainDecoderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Encoder/ChainDecoderTest.php @@ -32,12 +32,12 @@ protected function setUp() $this->decoder1 ->method('supportsDecoding') - ->will($this->returnValueMap([ + ->willReturnMap([ [self::FORMAT_1, [], true], [self::FORMAT_2, [], false], [self::FORMAT_3, [], false], [self::FORMAT_3, ['foo' => 'bar'], true], - ])); + ]); $this->decoder2 = $this ->getMockBuilder('Symfony\Component\Serializer\Encoder\DecoderInterface') @@ -45,11 +45,11 @@ protected function setUp() $this->decoder2 ->method('supportsDecoding') - ->will($this->returnValueMap([ + ->willReturnMap([ [self::FORMAT_1, [], false], [self::FORMAT_2, [], true], [self::FORMAT_3, [], false], - ])); + ]); $this->chainDecoder = new ChainDecoder([$this->decoder1, $this->decoder2]); } diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/ChainEncoderTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/ChainEncoderTest.php index 48ccbdca0aca6..d9b6251ed93c3 100644 --- a/src/Symfony/Component/Serializer/Tests/Encoder/ChainEncoderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Encoder/ChainEncoderTest.php @@ -34,12 +34,12 @@ protected function setUp() $this->encoder1 ->method('supportsEncoding') - ->will($this->returnValueMap([ + ->willReturnMap([ [self::FORMAT_1, [], true], [self::FORMAT_2, [], false], [self::FORMAT_3, [], false], [self::FORMAT_3, ['foo' => 'bar'], true], - ])); + ]); $this->encoder2 = $this ->getMockBuilder('Symfony\Component\Serializer\Encoder\EncoderInterface') @@ -47,11 +47,11 @@ protected function setUp() $this->encoder2 ->method('supportsEncoding') - ->will($this->returnValueMap([ + ->willReturnMap([ [self::FORMAT_1, [], false], [self::FORMAT_2, [], true], [self::FORMAT_3, [], false], - ])); + ]); $this->chainEncoder = new ChainEncoder([$this->encoder1, $this->encoder2]); } diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/Factory/CacheMetadataFactoryTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/Factory/CacheMetadataFactoryTest.php index cac4367ca7995..067f16acf9c36 100644 --- a/src/Symfony/Component/Serializer/Tests/Mapping/Factory/CacheMetadataFactoryTest.php +++ b/src/Symfony/Component/Serializer/Tests/Mapping/Factory/CacheMetadataFactoryTest.php @@ -31,7 +31,7 @@ public function testGetMetadataFor() $decorated ->expects($this->once()) ->method('getMetadataFor') - ->will($this->returnValue($metadata)) + ->willReturn($metadata) ; $factory = new CacheClassMetadataFactory($decorated, new ArrayAdapter()); @@ -47,7 +47,7 @@ public function testHasMetadataFor() $decorated ->expects($this->once()) ->method('hasMetadataFor') - ->will($this->returnValue(true)) + ->willReturn(true) ; $factory = new CacheClassMetadataFactory($decorated, new ArrayAdapter()); diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/Factory/ClassMetadataFactoryTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/Factory/ClassMetadataFactoryTest.php index 3d2aaa4c7ccdd..4e32085c98454 100644 --- a/src/Symfony/Component/Serializer/Tests/Mapping/Factory/ClassMetadataFactoryTest.php +++ b/src/Symfony/Component/Serializer/Tests/Mapping/Factory/ClassMetadataFactoryTest.php @@ -55,7 +55,7 @@ public function testCacheExists() $cache ->expects($this->once()) ->method('fetch') - ->will($this->returnValue('foo')) + ->willReturn('foo') ; $factory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()), $cache); @@ -68,7 +68,7 @@ public function testCacheExists() public function testCacheNotExists() { $cache = $this->getMockBuilder('Doctrine\Common\Cache\Cache')->getMock(); - $cache->method('fetch')->will($this->returnValue(false)); + $cache->method('fetch')->willReturn(false); $cache->method('save'); $factory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()), $cache); diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/ArrayDenormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/ArrayDenormalizerTest.php index fd456cb9dd4d8..132f3c0806350 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/ArrayDenormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/ArrayDenormalizerTest.php @@ -39,12 +39,12 @@ public function testDenormalize() $this->serializer->expects($this->at(0)) ->method('denormalize') ->with(['foo' => 'one', 'bar' => 'two']) - ->will($this->returnValue(new ArrayDummy('one', 'two'))); + ->willReturn(new ArrayDummy('one', 'two')); $this->serializer->expects($this->at(1)) ->method('denormalize') ->with(['foo' => 'three', 'bar' => 'four']) - ->will($this->returnValue(new ArrayDummy('three', 'four'))); + ->willReturn(new ArrayDummy('three', 'four')); $result = $this->denormalizer->denormalize( [ @@ -68,7 +68,7 @@ public function testSupportsValidArray() $this->serializer->expects($this->once()) ->method('supportsDenormalization') ->with($this->anything(), __NAMESPACE__.'\ArrayDummy', $this->anything()) - ->will($this->returnValue(true)); + ->willReturn(true); $this->assertTrue( $this->denormalizer->supportsDenormalization( @@ -85,7 +85,7 @@ public function testSupportsInvalidArray() { $this->serializer->expects($this->any()) ->method('supportsDenormalization') - ->will($this->returnValue(false)); + ->willReturn(false); $this->assertFalse( $this->denormalizer->supportsDenormalization( diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php index 894801747540c..d92fad3f80978 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php @@ -63,7 +63,7 @@ public function testNormalize() ->expects($this->once()) ->method('normalize') ->with($object, 'any') - ->will($this->returnValue('string_object')) + ->willReturn('string_object') ; $this->assertEquals( diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/JsonSerializableNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/JsonSerializableNormalizerTest.php index c6b167cbbe13e..4d9a53eeb9374 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/JsonSerializableNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/JsonSerializableNormalizerTest.php @@ -50,11 +50,11 @@ public function testNormalize() $this->serializer ->expects($this->once()) ->method('normalize') - ->will($this->returnCallback(function ($data) { + ->willReturnCallback(function ($data) { $this->assertArraySubset(['foo' => 'a', 'bar' => 'b', 'baz' => 'c'], $data); return 'string_object'; - })) + }) ; $this->assertEquals('string_object', $this->normalizer->normalize(new JsonSerializableDummy())); @@ -70,11 +70,11 @@ public function testCircularNormalize() $this->serializer ->expects($this->once()) ->method('normalize') - ->will($this->returnCallback(function ($data, $format, $context) { + ->willReturnCallback(function ($data, $format, $context) { $this->normalizer->normalize($data['qux'], $format, $context); return 'string_object'; - })) + }) ; $this->assertEquals('string_object', $this->normalizer->normalize(new JsonSerializableDummy())); diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php index b30739714b663..fe9d0b8546096 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php @@ -65,7 +65,7 @@ public function testNormalize() ->expects($this->once()) ->method('normalize') ->with($object, 'any') - ->will($this->returnValue('string_object')) + ->willReturn('string_object') ; $this->assertEquals( diff --git a/src/Symfony/Component/Templating/Tests/DelegatingEngineTest.php b/src/Symfony/Component/Templating/Tests/DelegatingEngineTest.php index 875672d27fff5..3d61ec2716b59 100644 --- a/src/Symfony/Component/Templating/Tests/DelegatingEngineTest.php +++ b/src/Symfony/Component/Templating/Tests/DelegatingEngineTest.php @@ -26,7 +26,7 @@ public function testRenderDelegatesToSupportedEngine() $secondEngine->expects($this->once()) ->method('render') ->with('template.php', ['foo' => 'bar']) - ->will($this->returnValue('')); + ->willReturn(''); $delegatingEngine = new DelegatingEngine([$firstEngine, $secondEngine]); $result = $delegatingEngine->render('template.php', ['foo' => 'bar']); @@ -53,7 +53,7 @@ public function testStreamDelegatesToSupportedEngine() $streamingEngine->expects($this->once()) ->method('stream') ->with('template.php', ['foo' => 'bar']) - ->will($this->returnValue('')); + ->willReturn(''); $delegatingEngine = new DelegatingEngine([$streamingEngine]); $result = $delegatingEngine->stream('template.php', ['foo' => 'bar']); @@ -77,7 +77,7 @@ public function testExists() $engine->expects($this->once()) ->method('exists') ->with('template.php') - ->will($this->returnValue(true)); + ->willReturn(true); $delegatingEngine = new DelegatingEngine([$engine]); @@ -132,7 +132,7 @@ private function getEngineMock($template, $supports) $engine->expects($this->once()) ->method('supports') ->with($template) - ->will($this->returnValue($supports)); + ->willReturn($supports); return $engine; } @@ -144,7 +144,7 @@ private function getStreamingEngineMock($template, $supports) $engine->expects($this->once()) ->method('supports') ->with($template) - ->will($this->returnValue($supports)); + ->willReturn($supports); return $engine; } diff --git a/src/Symfony/Component/Translation/Tests/DataCollector/TranslationDataCollectorTest.php b/src/Symfony/Component/Translation/Tests/DataCollector/TranslationDataCollectorTest.php index b4d350ef862e5..bd97a2445c0a5 100644 --- a/src/Symfony/Component/Translation/Tests/DataCollector/TranslationDataCollectorTest.php +++ b/src/Symfony/Component/Translation/Tests/DataCollector/TranslationDataCollectorTest.php @@ -27,7 +27,7 @@ protected function setUp() public function testCollectEmptyMessages() { $translator = $this->getTranslator(); - $translator->expects($this->any())->method('getCollectedMessages')->will($this->returnValue([])); + $translator->expects($this->any())->method('getCollectedMessages')->willReturn([]); $dataCollector = new TranslationDataCollector($translator); $dataCollector->lateCollect(); @@ -125,7 +125,7 @@ public function testCollect() ]; $translator = $this->getTranslator(); - $translator->expects($this->any())->method('getCollectedMessages')->will($this->returnValue($collectedMessages)); + $translator->expects($this->any())->method('getCollectedMessages')->willReturn($collectedMessages); $dataCollector = new TranslationDataCollector($translator); $dataCollector->lateCollect(); diff --git a/src/Symfony/Component/Translation/Tests/MessageCatalogueTest.php b/src/Symfony/Component/Translation/Tests/MessageCatalogueTest.php index 433be2eeaf45c..0f9c8d684e3ba 100644 --- a/src/Symfony/Component/Translation/Tests/MessageCatalogueTest.php +++ b/src/Symfony/Component/Translation/Tests/MessageCatalogueTest.php @@ -84,10 +84,10 @@ public function testReplace() public function testAddCatalogue() { $r = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock(); - $r->expects($this->any())->method('__toString')->will($this->returnValue('r')); + $r->expects($this->any())->method('__toString')->willReturn('r'); $r1 = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock(); - $r1->expects($this->any())->method('__toString')->will($this->returnValue('r1')); + $r1->expects($this->any())->method('__toString')->willReturn('r1'); $catalogue = new MessageCatalogue('en', ['domain1' => ['foo' => 'foo'], 'domain2' => ['bar' => 'bar']]); $catalogue->addResource($r); @@ -106,13 +106,13 @@ public function testAddCatalogue() public function testAddFallbackCatalogue() { $r = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock(); - $r->expects($this->any())->method('__toString')->will($this->returnValue('r')); + $r->expects($this->any())->method('__toString')->willReturn('r'); $r1 = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock(); - $r1->expects($this->any())->method('__toString')->will($this->returnValue('r1')); + $r1->expects($this->any())->method('__toString')->willReturn('r1'); $r2 = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock(); - $r2->expects($this->any())->method('__toString')->will($this->returnValue('r2')); + $r2->expects($this->any())->method('__toString')->willReturn('r2'); $catalogue = new MessageCatalogue('fr_FR', ['domain1' => ['foo' => 'foo'], 'domain2' => ['bar' => 'bar']]); $catalogue->addResource($r); @@ -171,11 +171,11 @@ public function testGetAddResource() { $catalogue = new MessageCatalogue('en'); $r = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock(); - $r->expects($this->any())->method('__toString')->will($this->returnValue('r')); + $r->expects($this->any())->method('__toString')->willReturn('r'); $catalogue->addResource($r); $catalogue->addResource($r); $r1 = $this->getMockBuilder('Symfony\Component\Config\Resource\ResourceInterface')->getMock(); - $r1->expects($this->any())->method('__toString')->will($this->returnValue('r1')); + $r1->expects($this->any())->method('__toString')->willReturn('r1'); $catalogue->addResource($r1); $this->assertEquals([$r, $r1], $catalogue->getResources()); diff --git a/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php b/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php index 6c94e14c54bac..0213e22254782 100644 --- a/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php +++ b/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php @@ -100,7 +100,7 @@ public function testCatalogueIsReloadedWhenResourcesAreNoLongerFresh() $loader ->expects($this->exactly(2)) ->method('load') - ->will($this->returnValue($catalogue)) + ->willReturn($catalogue) ; // 1st pass @@ -242,11 +242,11 @@ public function testRefreshCacheWhenResourcesAreNoLongerFresh() { $resource = $this->getMockBuilder('Symfony\Component\Config\Resource\SelfCheckingResourceInterface')->getMock(); $loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock(); - $resource->method('isFresh')->will($this->returnValue(false)); + $resource->method('isFresh')->willReturn(false); $loader ->expects($this->exactly(2)) ->method('load') - ->will($this->returnValue($this->getCatalogue('fr', [], [$resource]))); + ->willReturn($this->getCatalogue('fr', [], [$resource])); // prime the cache $translator = new Translator('fr', null, $this->tmpDir, true); diff --git a/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php b/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php index f07adb94238f5..0a11c4741385a 100644 --- a/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php +++ b/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php @@ -109,7 +109,7 @@ protected function createContext() $validator->expects($this->any()) ->method('inContext') ->with($context) - ->will($this->returnValue($contextualValidator)); + ->willReturn($contextualValidator); return $context; } @@ -174,7 +174,7 @@ protected function expectValidateAt($i, $propertyPath, $value, $group) $validator->expects($this->at(2 * $i)) ->method('atPath') ->with($propertyPath) - ->will($this->returnValue($validator)); + ->willReturn($validator); $validator->expects($this->at(2 * $i + 1)) ->method('validate') ->with($value, $this->logicalOr(null, [], $this->isInstanceOf('\Symfony\Component\Validator\Constraints\Valid')), $group); @@ -186,7 +186,7 @@ protected function expectValidateValueAt($i, $propertyPath, $value, $constraints $contextualValidator->expects($this->at(2 * $i)) ->method('atPath') ->with($propertyPath) - ->will($this->returnValue($contextualValidator)); + ->willReturn($contextualValidator); $contextualValidator->expects($this->at(2 * $i + 1)) ->method('validate') ->with($value, $constraints, $group); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php index 5cffcefd52726..72ca333d3c0a3 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php @@ -258,11 +258,11 @@ public function testExpressionLanguageUsage() $used = false; $expressionLanguage->method('evaluate') - ->will($this->returnCallback(function () use (&$used) { + ->willReturnCallback(function () use (&$used) { $used = true; return true; - })); + }); $validator = new ExpressionValidator(null, $expressionLanguage); $validator->initialize($this->createContext()); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php index b3428e77828ce..65906c5539fee 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php @@ -291,11 +291,11 @@ public function testValidMimeType() $file ->expects($this->once()) ->method('getPathname') - ->will($this->returnValue($this->path)); + ->willReturn($this->path); $file ->expects($this->once()) ->method('getMimeType') - ->will($this->returnValue('image/jpg')); + ->willReturn('image/jpg'); $constraint = new File([ 'mimeTypes' => ['image/png', 'image/jpg'], @@ -315,11 +315,11 @@ public function testValidWildcardMimeType() $file ->expects($this->once()) ->method('getPathname') - ->will($this->returnValue($this->path)); + ->willReturn($this->path); $file ->expects($this->once()) ->method('getMimeType') - ->will($this->returnValue('image/jpg')); + ->willReturn('image/jpg'); $constraint = new File([ 'mimeTypes' => ['image/*'], @@ -339,11 +339,11 @@ public function testInvalidMimeType() $file ->expects($this->once()) ->method('getPathname') - ->will($this->returnValue($this->path)); + ->willReturn($this->path); $file ->expects($this->once()) ->method('getMimeType') - ->will($this->returnValue('application/pdf')); + ->willReturn('application/pdf'); $constraint = new File([ 'mimeTypes' => ['image/png', 'image/jpg'], @@ -369,11 +369,11 @@ public function testInvalidWildcardMimeType() $file ->expects($this->once()) ->method('getPathname') - ->will($this->returnValue($this->path)); + ->willReturn($this->path); $file ->expects($this->once()) ->method('getMimeType') - ->will($this->returnValue('application/pdf')); + ->willReturn('application/pdf'); $constraint = new File([ 'mimeTypes' => ['image/*', 'image/jpg'], diff --git a/src/Symfony/Component/Validator/Tests/ContainerConstraintValidatorFactoryTest.php b/src/Symfony/Component/Validator/Tests/ContainerConstraintValidatorFactoryTest.php index 3782fba46c3b1..5178bc3b3060d 100644 --- a/src/Symfony/Component/Validator/Tests/ContainerConstraintValidatorFactoryTest.php +++ b/src/Symfony/Component/Validator/Tests/ContainerConstraintValidatorFactoryTest.php @@ -54,7 +54,7 @@ public function testGetInstanceInvalidValidatorClass() $constraint ->expects($this->once()) ->method('validatedBy') - ->will($this->returnValue('Fully\\Qualified\\ConstraintValidator\\Class\\Name')); + ->willReturn('Fully\\Qualified\\ConstraintValidator\\Class\\Name'); $factory = new ContainerConstraintValidatorFactory(new Container()); $factory->getInstance($constraint); diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Cache/AbstractCacheTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Cache/AbstractCacheTest.php index 4d0363fd717b4..bd088e0f093d7 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Cache/AbstractCacheTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Cache/AbstractCacheTest.php @@ -31,7 +31,7 @@ public function testWrite() $meta->expects($this->once()) ->method('getClassName') - ->will($this->returnValue('Foo\\Bar')); + ->willReturn('Foo\\Bar'); $this->cache->write($meta); @@ -51,7 +51,7 @@ public function testHas() $meta->expects($this->once()) ->method('getClassName') - ->will($this->returnValue('Foo\\Bar')); + ->willReturn('Foo\\Bar'); $this->assertFalse($this->cache->has('Foo\\Bar'), 'has() returns false when there is no entry'); @@ -68,7 +68,7 @@ public function testRead() $meta->expects($this->once()) ->method('getClassName') - ->will($this->returnValue('Foo\\Bar')); + ->willReturn('Foo\\Bar'); $this->assertFalse($this->cache->read('Foo\\Bar'), 'read() returns false when there is no entry'); diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php index a7876d7f9168f..9ad85e3f904fe 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php @@ -97,7 +97,7 @@ public function testWriteMetadataToCache() [$this->equalTo(self::PARENT_CLASS)], [$this->equalTo(self::INTERFACE_A_CLASS)] ) - ->will($this->returnValue(false)); + ->willReturn(false); $cache->expects($this->exactly(2)) ->method('write') ->withConsecutive( @@ -172,12 +172,12 @@ public function testMetadataCacheWithRuntimeConstraint() $cache ->expects($this->any()) ->method('write') - ->will($this->returnCallback(function ($metadata) { serialize($metadata); })) + ->willReturnCallback(function ($metadata) { serialize($metadata); }) ; $cache->expects($this->any()) ->method('read') - ->will($this->returnValue(false)); + ->willReturn(false); $metadata = $factory->getMetadataFor(self::PARENT_CLASS); $metadata->addConstraint(new Callback(function () {})); diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Loader/LoaderChainTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Loader/LoaderChainTest.php index f9905386c9601..45b8576f0e16a 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Loader/LoaderChainTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Loader/LoaderChainTest.php @@ -46,12 +46,12 @@ public function testReturnsTrueIfAnyLoaderReturnedTrue() $loader1 = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock(); $loader1->expects($this->any()) ->method('loadClassMetadata') - ->will($this->returnValue(true)); + ->willReturn(true); $loader2 = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock(); $loader2->expects($this->any()) ->method('loadClassMetadata') - ->will($this->returnValue(false)); + ->willReturn(false); $chain = new LoaderChain([ $loader1, @@ -68,12 +68,12 @@ public function testReturnsFalseIfNoLoaderReturnedTrue() $loader1 = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock(); $loader1->expects($this->any()) ->method('loadClassMetadata') - ->will($this->returnValue(false)); + ->willReturn(false); $loader2 = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock(); $loader2->expects($this->any()) ->method('loadClassMetadata') - ->will($this->returnValue(false)); + ->willReturn(false); $chain = new LoaderChain([ $loader1, diff --git a/src/Symfony/Component/Validator/Tests/Validator/AbstractTest.php b/src/Symfony/Component/Validator/Tests/Validator/AbstractTest.php index 1df64de4d99c6..2bc3d11ef6d49 100644 --- a/src/Symfony/Component/Validator/Tests/Validator/AbstractTest.php +++ b/src/Symfony/Component/Validator/Tests/Validator/AbstractTest.php @@ -610,9 +610,9 @@ public function testInitializeObjectsOnFirstValidation() $initializer1->expects($this->once()) ->method('initialize') ->with($entity) - ->will($this->returnCallback(function ($object) { + ->willReturnCallback(function ($object) { $object->initialized = true; - })); + }); $initializer2->expects($this->once()) ->method('initialize') diff --git a/src/Symfony/Component/Workflow/Tests/RegistryTest.php b/src/Symfony/Component/Workflow/Tests/RegistryTest.php index 25d2e1cc3b5ea..adedfc93b74d0 100644 --- a/src/Symfony/Component/Workflow/Tests/RegistryTest.php +++ b/src/Symfony/Component/Workflow/Tests/RegistryTest.php @@ -92,9 +92,9 @@ private function createSupportStrategy($supportedClassName) { $strategy = $this->getMockBuilder(SupportStrategyInterface::class)->getMock(); $strategy->expects($this->any())->method('supports') - ->will($this->returnCallback(function ($workflow, $subject) use ($supportedClassName) { + ->willReturnCallback(function ($workflow, $subject) use ($supportedClassName) { return $subject instanceof $supportedClassName; - })); + }); return $strategy; } From da85b48c32456f2170875a1f272d4f7853119ae8 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 30 May 2019 18:27:37 +0200 Subject: [PATCH 10/59] [HttpClient] remove unused argument --- src/Symfony/Component/HttpClient/CachingHttpClient.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpClient/CachingHttpClient.php b/src/Symfony/Component/HttpClient/CachingHttpClient.php index 3abf3113beac4..7cf28a28fc75b 100644 --- a/src/Symfony/Component/HttpClient/CachingHttpClient.php +++ b/src/Symfony/Component/HttpClient/CachingHttpClient.php @@ -11,7 +11,6 @@ namespace Symfony\Component\HttpClient; -use Psr\Log\LoggerInterface; use Symfony\Component\HttpClient\Response\MockResponse; use Symfony\Component\HttpClient\Response\ResponseStream; use Symfony\Component\HttpFoundation\Request; @@ -39,7 +38,7 @@ class CachingHttpClient implements HttpClientInterface private $cache; private $defaultOptions = self::OPTIONS_DEFAULTS; - public function __construct(HttpClientInterface $client, StoreInterface $store, array $defaultOptions = [], LoggerInterface $logger = null) + public function __construct(HttpClientInterface $client, StoreInterface $store, array $defaultOptions = []) { if (!class_exists(HttpClientKernel::class)) { throw new \LogicException(sprintf('Using "%s" requires that the HttpKernel component version 4.3 or higher is installed, try running "composer require symfony/http-kernel:^4.3".', __CLASS__)); From a3555fc49cd89c2408d07e7e9edb92275c999d69 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Thu, 30 May 2019 21:25:18 +0200 Subject: [PATCH 11/59] do not enable validator auto mapping by default --- .../Doctrine/Tests/Validator/DoctrineLoaderTest.php | 4 ++-- .../Bridge/Doctrine/Validator/DoctrineLoader.php | 2 +- .../AddAutoMappingConfigurationPass.php | 6 +++++- .../AddAutoMappingConfigurationPassTest.php | 13 +++++++++++++ 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php index cde956eed3493..63fd66eaddbd0 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php @@ -36,7 +36,7 @@ public function testLoadClassMetadata() $validator = Validation::createValidatorBuilder() ->enableAnnotationMapping() - ->addLoader(new DoctrineLoader(DoctrineTestHelper::createTestEntityManager())) + ->addLoader(new DoctrineLoader(DoctrineTestHelper::createTestEntityManager(), '{^Symfony\\\\Bridge\\\\Doctrine\\\\Tests\\\\Fixtures\\\\DoctrineLoaderEntity$}')) ->getValidator() ; @@ -111,7 +111,7 @@ public function testClassValidator(bool $expected, string $classValidatorRegexp public function regexpProvider() { return [ - [true, null], + [false, null], [true, '{^'.preg_quote(DoctrineLoaderEntity::class).'$|^'.preg_quote(Entity::class).'$}'], [false, '{^'.preg_quote(Entity::class).'$}'], ]; diff --git a/src/Symfony/Bridge/Doctrine/Validator/DoctrineLoader.php b/src/Symfony/Bridge/Doctrine/Validator/DoctrineLoader.php index 376670e8e405a..9e3c32aa621e4 100644 --- a/src/Symfony/Bridge/Doctrine/Validator/DoctrineLoader.php +++ b/src/Symfony/Bridge/Doctrine/Validator/DoctrineLoader.php @@ -42,7 +42,7 @@ public function __construct(EntityManagerInterface $entityManager, string $class public function loadClassMetadata(ClassMetadata $metadata): bool { $className = $metadata->getClassName(); - if (null !== $this->classValidatorRegexp && !preg_match($this->classValidatorRegexp, $className)) { + if (null === $this->classValidatorRegexp || !preg_match($this->classValidatorRegexp, $className)) { return false; } diff --git a/src/Symfony/Component/Validator/DependencyInjection/AddAutoMappingConfigurationPass.php b/src/Symfony/Component/Validator/DependencyInjection/AddAutoMappingConfigurationPass.php index fc110bbbe66a9..177f42e655d84 100644 --- a/src/Symfony/Component/Validator/DependencyInjection/AddAutoMappingConfigurationPass.php +++ b/src/Symfony/Component/Validator/DependencyInjection/AddAutoMappingConfigurationPass.php @@ -70,8 +70,12 @@ public function process(ContainerBuilder $container) /** * Builds a regexp to check if a class is auto-mapped. */ - private function getRegexp(array $patterns): string + private function getRegexp(array $patterns): ?string { + if (!$patterns) { + return null; + } + $regexps = []; foreach ($patterns as $pattern) { // Escape namespace diff --git a/src/Symfony/Component/Validator/Tests/DependencyInjection/AddAutoMappingConfigurationPassTest.php b/src/Symfony/Component/Validator/Tests/DependencyInjection/AddAutoMappingConfigurationPassTest.php index b4b5699760404..bce1101ef5cca 100644 --- a/src/Symfony/Component/Validator/Tests/DependencyInjection/AddAutoMappingConfigurationPassTest.php +++ b/src/Symfony/Component/Validator/Tests/DependencyInjection/AddAutoMappingConfigurationPassTest.php @@ -70,4 +70,17 @@ public function mappingProvider(): array ['Symfony\Component\Validator\Tests\Fixtures\\**', ['trailing_double_star'], '{^App\\\\|^Symfony\\\\Component\\\\Validator\\\\Tests\\\\Fixtures\\\\.*?$}'], ]; } + + public function testDoNotMapAllClassesWhenConfigIsEmpty() + { + $container = new ContainerBuilder(); + $container->setParameter('validator.auto_mapping', []); + + $container->register('validator.builder', ValidatorBuilder::class); + $container->register('loader')->addTag('validator.auto_mapper'); + + (new AddAutoMappingConfigurationPass())->process($container); + + $this->assertNull($container->getDefinition('loader')->getArgument('$classValidatorRegexp')); + } } From 0bb8ba4ea4c8d7871a3259a0d42402909a2a9c2e Mon Sep 17 00:00:00 2001 From: SAMUEL NELA Date: Fri, 31 May 2019 00:41:44 +0200 Subject: [PATCH 12/59] [Contracts] Fixed typos --- .../Contracts/EventDispatcher/EventDispatcherInterface.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Contracts/EventDispatcher/EventDispatcherInterface.php b/src/Symfony/Contracts/EventDispatcher/EventDispatcherInterface.php index 9b1a69add2336..2d470af92006c 100644 --- a/src/Symfony/Contracts/EventDispatcher/EventDispatcherInterface.php +++ b/src/Symfony/Contracts/EventDispatcher/EventDispatcherInterface.php @@ -23,7 +23,7 @@ interface EventDispatcherInterface extends PsrEventDispatcherInterface * Dispatches an event to all registered listeners. * * For BC with Symfony 4, the $eventName argument is not declared explicitly on the - * signature of the method. Implementations that are not bound by this BC contraint + * signature of the method. Implementations that are not bound by this BC constraint * MUST declare it explicitly, as allowed by PHP. * * @param object $event The event to pass to the event handlers/listeners @@ -44,7 +44,7 @@ interface EventDispatcherInterface * Dispatches an event to all registered listeners. * * For BC with Symfony 4, the $eventName argument is not declared explicitly on the - * signature of the method. Implementations that are not bound by this BC contraint + * signature of the method. Implementations that are not bound by this BC constraint * MUST declare it explicitly, as allowed by PHP. * * @param object $event The event to pass to the event handlers/listeners From e48d5d07e32c60a086c1e4c0a6096f7365ca36ae Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Fri, 31 May 2019 01:37:35 +0200 Subject: [PATCH 13/59] [DomCrawler] Fix type error with null Form::$currentUri --- src/Symfony/Component/DomCrawler/Form.php | 2 +- src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/DomCrawler/Form.php b/src/Symfony/Component/DomCrawler/Form.php index 339603d09ef2d..8bdd364347601 100644 --- a/src/Symfony/Component/DomCrawler/Form.php +++ b/src/Symfony/Component/DomCrawler/Form.php @@ -44,7 +44,7 @@ class Form extends Link implements \ArrayAccess * * @throws \LogicException if the node is not a button inside a form tag */ - public function __construct(\DOMElement $node, string $currentUri, string $method = null, string $baseHref = null) + public function __construct(\DOMElement $node, string $currentUri = null, string $method = null, string $baseHref = null) { parent::__construct($node, $currentUri, $method); $this->baseHref = $baseHref; diff --git a/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php b/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php index c3b40f322663b..548fd1833f114 100644 --- a/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php @@ -1091,6 +1091,7 @@ public function getBaseTagWithFormData() ['/basepath', '/registration', 'http://domain.com/registration', 'http://domain.com/registration', ' tag does work with a path and form action'], ['/basepath', '', 'http://domain.com/registration', 'http://domain.com/registration', ' tag does work with a path and empty form action'], ['http://base.com/', '/registration', 'http://base.com/registration', 'http://domain.com/registration', ' tag does work with a URL and form action'], + ['http://base.com/', 'http://base.com/registration', 'http://base.com/registration', null, ' tag does work with a URL and form action'], ['http://base.com', '', 'http://domain.com/path/form', 'http://domain.com/path/form', ' tag does work with a URL and an empty form action'], ['http://base.com/path', '/registration', 'http://base.com/registration', 'http://domain.com/path/form', ' tag does work with a URL and form action'], ]; From 91817e4de0e4f046c7162df3bd2d9cfe277965f0 Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Thu, 30 May 2019 20:39:48 +0200 Subject: [PATCH 14/59] [Messenger] Inject RoutableMessageBus instead of bus locator --- .../Resources/config/console.xml | 2 +- .../Command/ConsumeMessagesCommand.php | 20 ++- .../DependencyInjection/MessengerPass.php | 1 - .../Messenger/RoutableMessageBus.php | 15 +- .../Command/ConsumeMessagesCommandTest.php | 138 ++++++++++++++++++ 5 files changed, 159 insertions(+), 17 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/console.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/console.xml index 46c103cee4675..ebd7d6ce46a6d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/console.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/console.xml @@ -82,7 +82,7 @@ - + diff --git a/src/Symfony/Component/Messenger/Command/ConsumeMessagesCommand.php b/src/Symfony/Component/Messenger/Command/ConsumeMessagesCommand.php index 0e91cfc795551..be6f4c1733b27 100644 --- a/src/Symfony/Component/Messenger/Command/ConsumeMessagesCommand.php +++ b/src/Symfony/Component/Messenger/Command/ConsumeMessagesCommand.php @@ -40,7 +40,7 @@ class ConsumeMessagesCommand extends Command { protected static $defaultName = 'messenger:consume'; - private $busLocator; + private $routableBus; private $receiverLocator; private $logger; private $receiverNames; @@ -49,15 +49,23 @@ class ConsumeMessagesCommand extends Command /** @var CacheItemPoolInterface|null */ private $restartSignalCachePool; - public function __construct(ContainerInterface $busLocator, ContainerInterface $receiverLocator, LoggerInterface $logger = null, array $receiverNames = [], /* ContainerInterface */ $retryStrategyLocator = null, EventDispatcherInterface $eventDispatcher = null) + /** + * @param RoutableMessageBus $routableBus + */ + public function __construct($routableBus, ContainerInterface $receiverLocator, LoggerInterface $logger = null, array $receiverNames = [], /* ContainerInterface */ $retryStrategyLocator = null, EventDispatcherInterface $eventDispatcher = null) { + // to be deprecated in 4.4 + if ($routableBus instanceof ContainerInterface) { + $routableBus = new RoutableMessageBus($routableBus); + } + if (\is_array($retryStrategyLocator)) { @trigger_error(sprintf('The 5th argument of the class "%s" should be a retry-strategy locator, an array of bus names as a value is deprecated since Symfony 4.3.', __CLASS__), E_USER_DEPRECATED); $retryStrategyLocator = null; } - $this->busLocator = $busLocator; + $this->routableBus = $routableBus; $this->receiverLocator = $receiverLocator; $this->logger = $logger; $this->receiverNames = $receiverNames; @@ -177,11 +185,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $retryStrategies[$receiverName] = null !== $this->retryStrategyLocator ? $this->retryStrategyLocator->get($receiverName) : null; } - if (null !== $input->getOption('bus')) { - $bus = $this->busLocator->get($input->getOption('bus')); - } else { - $bus = new RoutableMessageBus($this->busLocator); - } + $bus = $input->getOption('bus') ? $this->routableBus->getMessageBus($input->getOption('bus')) : $this->routableBus; $worker = new Worker($receivers, $bus, $retryStrategies, $this->eventDispatcher, $this->logger); $stopsWhen = []; diff --git a/src/Symfony/Component/Messenger/DependencyInjection/MessengerPass.php b/src/Symfony/Component/Messenger/DependencyInjection/MessengerPass.php index bc5f0290c337f..ce7abe1d25fa9 100644 --- a/src/Symfony/Component/Messenger/DependencyInjection/MessengerPass.php +++ b/src/Symfony/Component/Messenger/DependencyInjection/MessengerPass.php @@ -260,7 +260,6 @@ private function registerReceivers(ContainerBuilder $container, array $busIds) if ($container->hasDefinition('console.command.messenger_consume_messages')) { $container->getDefinition('console.command.messenger_consume_messages') - ->replaceArgument(0, ServiceLocatorTagPass::register($container, $buses)) ->replaceArgument(3, array_values($receiverNames)); } diff --git a/src/Symfony/Component/Messenger/RoutableMessageBus.php b/src/Symfony/Component/Messenger/RoutableMessageBus.php index c0f7eeca1b9a0..3af52308904fe 100644 --- a/src/Symfony/Component/Messenger/RoutableMessageBus.php +++ b/src/Symfony/Component/Messenger/RoutableMessageBus.php @@ -45,11 +45,6 @@ public function dispatch($envelope, array $stamps = []): Envelope throw new InvalidArgumentException('Messages passed to RoutableMessageBus::dispatch() must be inside an Envelope'); } - return $this->getMessageBus($envelope)->dispatch($envelope, $stamps); - } - - private function getMessageBus(Envelope $envelope): MessageBusInterface - { /** @var BusNameStamp|null $busNameStamp */ $busNameStamp = $envelope->last(BusNameStamp::class); @@ -58,11 +53,17 @@ private function getMessageBus(Envelope $envelope): MessageBusInterface throw new InvalidArgumentException(sprintf('Envelope is missing a BusNameStamp and no fallback message bus is configured on RoutableMessageBus.')); } - return $this->fallbackBus; + return $this->fallbackBus->dispatch($envelope, $stamps); } - $busName = $busNameStamp->getBusName(); + return $this->getMessageBus($busNameStamp->getBusName())->dispatch($envelope, $stamps); + } + /** + * @internal + */ + public function getMessageBus(string $busName): MessageBusInterface + { if (!$this->busLocator->has($busName)) { throw new InvalidArgumentException(sprintf('Bus named "%s" does not exist.', $busName)); } diff --git a/src/Symfony/Component/Messenger/Tests/Command/ConsumeMessagesCommandTest.php b/src/Symfony/Component/Messenger/Tests/Command/ConsumeMessagesCommandTest.php index e7ce90b85c0bf..3191c65b644a4 100644 --- a/src/Symfony/Component/Messenger/Tests/Command/ConsumeMessagesCommandTest.php +++ b/src/Symfony/Component/Messenger/Tests/Command/ConsumeMessagesCommandTest.php @@ -12,8 +12,16 @@ namespace Symfony\Component\Messenger\Tests\Command; use PHPUnit\Framework\TestCase; +use Symfony\Component\Console\Application; +use Symfony\Component\Console\Tester\CommandTester; +use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ServiceLocator; use Symfony\Component\Messenger\Command\ConsumeMessagesCommand; +use Symfony\Component\Messenger\Envelope; +use Symfony\Component\Messenger\MessageBusInterface; +use Symfony\Component\Messenger\RoutableMessageBus; +use Symfony\Component\Messenger\Stamp\BusNameStamp; +use Symfony\Component\Messenger\Transport\Receiver\ReceiverInterface; class ConsumeMessagesCommandTest extends TestCase { @@ -24,4 +32,134 @@ public function testConfigurationWithDefaultReceiver() $this->assertFalse($inputArgument->isRequired()); $this->assertSame(['amqp'], $inputArgument->getDefault()); } + + public function testBasicRun() + { + $envelope = new Envelope(new \stdClass(), [new BusNameStamp('dummy-bus')]); + + $receiver = $this->createMock(ReceiverInterface::class); + $receiver->expects($this->once())->method('get')->willReturn([$envelope]); + + $receiverLocator = $this->createMock(ContainerInterface::class); + $receiverLocator->expects($this->once())->method('has')->with('dummy-receiver')->willReturn(true); + $receiverLocator->expects($this->once())->method('get')->with('dummy-receiver')->willReturn($receiver); + + $bus = $this->createMock(MessageBusInterface::class); + $bus->expects($this->once())->method('dispatch'); + + $busLocator = $this->createMock(ContainerInterface::class); + $busLocator->expects($this->once())->method('has')->with('dummy-bus')->willReturn(true); + $busLocator->expects($this->once())->method('get')->with('dummy-bus')->willReturn($bus); + + $command = new ConsumeMessagesCommand(new RoutableMessageBus($busLocator), $receiverLocator); + + $application = new Application(); + $application->add($command); + $tester = new CommandTester($application->get('messenger:consume')); + $tester->execute([ + 'receivers' => ['dummy-receiver'], + '--limit' => 1, + ]); + + $this->assertSame(0, $tester->getStatusCode()); + $this->assertContains('[OK] Consuming messages from transports "dummy-receiver"', $tester->getDisplay()); + } + + public function testRunWithBusOption() + { + $envelope = new Envelope(new \stdClass()); + + $receiver = $this->createMock(ReceiverInterface::class); + $receiver->expects($this->once())->method('get')->willReturn([$envelope]); + + $receiverLocator = $this->createMock(ContainerInterface::class); + $receiverLocator->expects($this->once())->method('has')->with('dummy-receiver')->willReturn(true); + $receiverLocator->expects($this->once())->method('get')->with('dummy-receiver')->willReturn($receiver); + + $bus = $this->createMock(MessageBusInterface::class); + $bus->expects($this->once())->method('dispatch'); + + $busLocator = $this->createMock(ContainerInterface::class); + $busLocator->expects($this->once())->method('has')->with('dummy-bus')->willReturn(true); + $busLocator->expects($this->once())->method('get')->with('dummy-bus')->willReturn($bus); + + $command = new ConsumeMessagesCommand(new RoutableMessageBus($busLocator), $receiverLocator); + + $application = new Application(); + $application->add($command); + $tester = new CommandTester($application->get('messenger:consume')); + $tester->execute([ + 'receivers' => ['dummy-receiver'], + '--bus' => 'dummy-bus', + '--limit' => 1, + ]); + + $this->assertSame(0, $tester->getStatusCode()); + $this->assertContains('[OK] Consuming messages from transports "dummy-receiver"', $tester->getDisplay()); + } + + public function testBasicRunWithBusLocator() + { + $envelope = new Envelope(new \stdClass(), [new BusNameStamp('dummy-bus')]); + + $receiver = $this->createMock(ReceiverInterface::class); + $receiver->expects($this->once())->method('get')->willReturn([$envelope]); + + $receiverLocator = $this->createMock(ContainerInterface::class); + $receiverLocator->expects($this->once())->method('has')->with('dummy-receiver')->willReturn(true); + $receiverLocator->expects($this->once())->method('get')->with('dummy-receiver')->willReturn($receiver); + + $bus = $this->createMock(MessageBusInterface::class); + $bus->expects($this->once())->method('dispatch'); + + $busLocator = $this->createMock(ContainerInterface::class); + $busLocator->expects($this->once())->method('has')->with('dummy-bus')->willReturn(true); + $busLocator->expects($this->once())->method('get')->with('dummy-bus')->willReturn($bus); + + $command = new ConsumeMessagesCommand($busLocator, $receiverLocator); + + $application = new Application(); + $application->add($command); + $tester = new CommandTester($application->get('messenger:consume')); + $tester->execute([ + 'receivers' => ['dummy-receiver'], + '--limit' => 1, + ]); + + $this->assertSame(0, $tester->getStatusCode()); + $this->assertContains('[OK] Consuming messages from transports "dummy-receiver"', $tester->getDisplay()); + } + + public function testRunWithBusOptionAndBusLocator() + { + $envelope = new Envelope(new \stdClass()); + + $receiver = $this->createMock(ReceiverInterface::class); + $receiver->expects($this->once())->method('get')->willReturn([$envelope]); + + $receiverLocator = $this->createMock(ContainerInterface::class); + $receiverLocator->expects($this->once())->method('has')->with('dummy-receiver')->willReturn(true); + $receiverLocator->expects($this->once())->method('get')->with('dummy-receiver')->willReturn($receiver); + + $bus = $this->createMock(MessageBusInterface::class); + $bus->expects($this->once())->method('dispatch'); + + $busLocator = $this->createMock(ContainerInterface::class); + $busLocator->expects($this->once())->method('has')->with('dummy-bus')->willReturn(true); + $busLocator->expects($this->once())->method('get')->with('dummy-bus')->willReturn($bus); + + $command = new ConsumeMessagesCommand($busLocator, $receiverLocator); + + $application = new Application(); + $application->add($command); + $tester = new CommandTester($application->get('messenger:consume')); + $tester->execute([ + 'receivers' => ['dummy-receiver'], + '--bus' => 'dummy-bus', + '--limit' => 1, + ]); + + $this->assertSame(0, $tester->getStatusCode()); + $this->assertContains('[OK] Consuming messages from transports "dummy-receiver"', $tester->getDisplay()); + } } From ee71cdbae4db09b574ec88244327b238da92bc39 Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Thu, 30 May 2019 18:46:20 +0200 Subject: [PATCH 15/59] [Validator] Fix TimezoneValidator default option --- .../Validator/Constraints/Timezone.php | 10 ++++++++- .../Constraints/TimezoneValidator.php | 22 ------------------- .../Tests/Constraints/TimezoneTest.php | 2 +- .../Constraints/TimezoneValidatorTest.php | 4 +--- 4 files changed, 11 insertions(+), 27 deletions(-) diff --git a/src/Symfony/Component/Validator/Constraints/Timezone.php b/src/Symfony/Component/Validator/Constraints/Timezone.php index 0f4b57b0875a8..9a46c15ddfd71 100644 --- a/src/Symfony/Component/Validator/Constraints/Timezone.php +++ b/src/Symfony/Component/Validator/Constraints/Timezone.php @@ -43,7 +43,7 @@ class Timezone extends Constraint /** * {@inheritdoc} */ - public function __construct(array $options = null) + public function __construct($options = null) { parent::__construct($options); @@ -58,4 +58,12 @@ public function __construct(array $options = null) throw new ConstraintDefinitionException('The option "intlCompatible" can only be used when the PHP intl extension is available.'); } } + + /** + * {@inheritdoc} + */ + public function getDefaultOption() + { + return 'zone'; + } } diff --git a/src/Symfony/Component/Validator/Constraints/TimezoneValidator.php b/src/Symfony/Component/Validator/Constraints/TimezoneValidator.php index d4261ff376c54..cf52239d0c245 100644 --- a/src/Symfony/Component/Validator/Constraints/TimezoneValidator.php +++ b/src/Symfony/Component/Validator/Constraints/TimezoneValidator.php @@ -75,28 +75,6 @@ public function validate($value, Constraint $constraint) ->addViolation(); } - /** - * {@inheritdoc} - */ - public function getDefaultOption() - { - return 'zone'; - } - - /** - * {@inheritdoc} - */ - protected function formatValue($value, $format = 0) - { - $value = parent::formatValue($value, $format); - - if (!$value || \DateTimeZone::PER_COUNTRY === $value) { - return $value; - } - - return array_search($value, (new \ReflectionClass(\DateTimeZone::class))->getConstants(), true) ?: $value; - } - private static function getPhpTimezones(int $zone, string $countryCode = null): array { if (null !== $countryCode) { diff --git a/src/Symfony/Component/Validator/Tests/Constraints/TimezoneTest.php b/src/Symfony/Component/Validator/Tests/Constraints/TimezoneTest.php index adc27a7699801..450c82ffeb75a 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/TimezoneTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/TimezoneTest.php @@ -23,7 +23,7 @@ public function testValidTimezoneConstraints() { new Timezone(); new Timezone(['zone' => \DateTimeZone::ALL]); - new Timezone(['zone' => \DateTimeZone::ALL_WITH_BC]); + new Timezone(\DateTimeZone::ALL_WITH_BC); new Timezone([ 'zone' => \DateTimeZone::PER_COUNTRY, 'countryCode' => 'AR', diff --git a/src/Symfony/Component/Validator/Tests/Constraints/TimezoneValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/TimezoneValidatorTest.php index 82a521d950a95..352e45c5d355c 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/TimezoneValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/TimezoneValidatorTest.php @@ -267,9 +267,7 @@ public function testGroupedTimezonesWithInvalidCountry() */ public function testDeprecatedTimezonesAreValidWithBC(string $timezone) { - $constraint = new Timezone([ - 'zone' => \DateTimeZone::ALL_WITH_BC, - ]); + $constraint = new Timezone(\DateTimeZone::ALL_WITH_BC); $this->validator->validate($timezone, $constraint); From c0fc45682ad49b825dfe017716956b09ddf2b81a Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 31 May 2019 11:10:50 +0200 Subject: [PATCH 16/59] [Security\Core] Make SodiumPasswordEncoder validate BCrypt-ed passwords --- .../Security/Core/Encoder/SodiumPasswordEncoder.php | 5 +++++ .../Core/Tests/Encoder/SodiumPasswordEncoderTest.php | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/src/Symfony/Component/Security/Core/Encoder/SodiumPasswordEncoder.php b/src/Symfony/Component/Security/Core/Encoder/SodiumPasswordEncoder.php index 96fbdca173324..e9bd6a63c94d2 100644 --- a/src/Symfony/Component/Security/Core/Encoder/SodiumPasswordEncoder.php +++ b/src/Symfony/Component/Security/Core/Encoder/SodiumPasswordEncoder.php @@ -84,6 +84,11 @@ public function isPasswordValid($encoded, $raw, $salt) return false; } + if (72 >= \strlen($raw) && 0 === strpos($encoded, '$2')) { + // Accept validating BCrypt passwords for seamless migrations + return password_verify($raw, $encoded); + } + if (\function_exists('sodium_crypto_pwhash_str_verify')) { return \sodium_crypto_pwhash_str_verify($encoded, $raw); } diff --git a/src/Symfony/Component/Security/Core/Tests/Encoder/SodiumPasswordEncoderTest.php b/src/Symfony/Component/Security/Core/Tests/Encoder/SodiumPasswordEncoderTest.php index fe9e5db0eb4cb..84c8b4849e2b5 100644 --- a/src/Symfony/Component/Security/Core/Tests/Encoder/SodiumPasswordEncoderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Encoder/SodiumPasswordEncoderTest.php @@ -31,6 +31,12 @@ public function testValidation() $this->assertFalse($encoder->isPasswordValid($result, 'anotherPassword', null)); } + public function testBCryptValidation() + { + $encoder = new SodiumPasswordEncoder(); + $this->assertTrue($encoder->isPasswordValid('$2y$04$M8GDODMoGQLQRpkYCdoJh.lbiZPee3SZI32RcYK49XYTolDGwoRMm', 'abc', null)); + } + /** * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException */ From d4a9e7e6395119f815dcb25e429bb21d619acc0e Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 31 May 2019 10:49:44 +0200 Subject: [PATCH 17/59] [TwigBridge] suggest Translation Component when TranslationExtension is used --- .../Twig/Extension/TranslationExtension.php | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php b/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php index 46fdd9e7b779a..9e927ecdf0320 100644 --- a/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php @@ -49,11 +49,19 @@ public function __construct($translator = null, NodeVisitorInterface $translatio } /** - * @deprecated since Symfony 4.2 + * @return TranslatorInterface|null */ public function getTranslator() { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED); + if (null === $this->translator) { + if (!interface_exists(TranslatorInterface::class)) { + throw new \LogicException(sprintf('You cannot use the "%s" if the Translation Contracts are not available. Try running "composer require symfony/translation".', __CLASS__)); + } + + $this->translator = new class() implements TranslatorInterface { + use TranslatorTrait; + }; + } return $this->translator; } @@ -108,13 +116,8 @@ public function trans($message, array $arguments = [], $domain = null, $locale = if (null !== $count) { $arguments['%count%'] = $count; } - if (null === $this->translator) { - $this->translator = new class() implements TranslatorInterface { - use TranslatorTrait; - }; - } - return $this->translator->trans($message, $arguments, $domain, $locale); + return $this->getTranslator()->trans($message, $arguments, $domain, $locale); } /** @@ -122,17 +125,13 @@ public function trans($message, array $arguments = [], $domain = null, $locale = */ public function transchoice($message, $count, array $arguments = [], $domain = null, $locale = null) { - if (null === $this->translator) { - $this->translator = new class() implements TranslatorInterface { - use TranslatorTrait; - }; - } + $translator = $this->getTranslator(); - if ($this->translator instanceof TranslatorInterface) { - return $this->translator->trans($message, array_merge(['%count%' => $count], $arguments), $domain, $locale); + if ($translator instanceof TranslatorInterface) { + return $translator->trans($message, array_merge(['%count%' => $count], $arguments), $domain, $locale); } - return $this->translator->transChoice($message, $count, array_merge(['%count%' => $count], $arguments), $domain, $locale); + return $translator->transChoice($message, $count, array_merge(['%count%' => $count], $arguments), $domain, $locale); } /** From f4254e6f5e74406ca7cbcd1606d0dd3c2032d0c7 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 31 May 2019 16:32:37 +0300 Subject: [PATCH 18/59] [Mailer] fixed the possibility to set a From header from MessageListener --- .../Component/Mailer/DelayedSmtpEnvelope.php | 105 ++++++++++++++++++ src/Symfony/Component/Mailer/SmtpEnvelope.php | 39 +------ .../Mailer/Tests/SmtpEnvelopeTest.php | 7 +- .../Mailer/Transport/AbstractTransport.php | 3 +- 4 files changed, 112 insertions(+), 42 deletions(-) create mode 100644 src/Symfony/Component/Mailer/DelayedSmtpEnvelope.php diff --git a/src/Symfony/Component/Mailer/DelayedSmtpEnvelope.php b/src/Symfony/Component/Mailer/DelayedSmtpEnvelope.php new file mode 100644 index 0000000000000..95356fd9e350b --- /dev/null +++ b/src/Symfony/Component/Mailer/DelayedSmtpEnvelope.php @@ -0,0 +1,105 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Mailer; + +use Symfony\Component\Mailer\Exception\InvalidArgumentException; +use Symfony\Component\Mailer\Exception\LogicException; +use Symfony\Component\Mime\Address; +use Symfony\Component\Mime\Header\Headers; +use Symfony\Component\Mime\Message; +use Symfony\Component\Mime\RawMessage; + +/** + * @author Fabien Potencier + * + * @experimental in 4.3 + * + * @internal + */ +final class DelayedSmtpEnvelope extends SmtpEnvelope +{ + private $senderSet = false; + private $recipientsSet = false; + private $message; + + public function __construct(RawMessage $message) + { + if (!$message instanceof Message) { + // FIXME: parse the raw message to create the envelope? + throw new InvalidArgumentException(sprintf('Unable to create an SmtpEnvelope from a "%s" message.', RawMessage::class)); + } + + $this->message = $message; + } + + public function setSender(Address $sender): void + { + parent::setSender($sender); + + $this->senderSet = true; + } + + public function getSender(): Address + { + if ($this->senderSet) { + return parent::getSender(); + } + + return self::getSenderFromHeaders($this->message->getHeaders()); + } + + public function setRecipients(array $recipients): void + { + parent::setRecipients($recipients); + + $this->recipientsSet = parent::getRecipients(); + } + + /** + * @return Address[] + */ + public function getRecipients(): array + { + if ($this->recipientsSet) { + return parent::getRecipients(); + } + + return self::getRecipientsFromHeaders($this->message->getHeaders()); + } + + private static function getRecipientsFromHeaders(Headers $headers): array + { + $recipients = []; + foreach (['to', 'cc', 'bcc'] as $name) { + foreach ($headers->getAll($name) as $header) { + $recipients = array_merge($recipients, $header->getAddresses()); + } + } + + return $recipients; + } + + private static function getSenderFromHeaders(Headers $headers): Address + { + if ($return = $headers->get('Return-Path')) { + return $return->getAddress(); + } + if ($sender = $headers->get('Sender')) { + return $sender->getAddress(); + } + if ($from = $headers->get('From')) { + return $from->getAddresses()[0]; + } + + throw new LogicException('Unable to determine the sender of the message.'); + } +} diff --git a/src/Symfony/Component/Mailer/SmtpEnvelope.php b/src/Symfony/Component/Mailer/SmtpEnvelope.php index 6a41027305c17..7f1458d0f8bda 100644 --- a/src/Symfony/Component/Mailer/SmtpEnvelope.php +++ b/src/Symfony/Component/Mailer/SmtpEnvelope.php @@ -12,10 +12,7 @@ namespace Symfony\Component\Mailer; use Symfony\Component\Mailer\Exception\InvalidArgumentException; -use Symfony\Component\Mailer\Exception\LogicException; use Symfony\Component\Mime\Address; -use Symfony\Component\Mime\Header\Headers; -use Symfony\Component\Mime\Message; use Symfony\Component\Mime\NamedAddress; use Symfony\Component\Mime\RawMessage; @@ -40,14 +37,7 @@ public function __construct(Address $sender, array $recipients) public static function create(RawMessage $message): self { - if ($message instanceof Message) { - $headers = $message->getHeaders(); - - return new self(self::getSenderFromHeaders($headers), self::getRecipientsFromHeaders($headers)); - } - - // FIXME: parse the raw message to create the envelope? - throw new InvalidArgumentException(sprintf('Unable to create an SmtpEnvelope from a "%s" message.', RawMessage::class)); + return new DelayedSmtpEnvelope($message); } public function setSender(Address $sender): void @@ -84,31 +74,4 @@ public function getRecipients(): array { return $this->recipients; } - - private static function getRecipientsFromHeaders(Headers $headers): array - { - $recipients = []; - foreach (['to', 'cc', 'bcc'] as $name) { - foreach ($headers->getAll($name) as $header) { - $recipients = array_merge($recipients, $header->getAddresses()); - } - } - - return $recipients; - } - - private static function getSenderFromHeaders(Headers $headers): Address - { - if ($return = $headers->get('Return-Path')) { - return $return->getAddress(); - } - if ($sender = $headers->get('Sender')) { - return $sender->getAddress(); - } - if ($from = $headers->get('From')) { - return $from->getAddresses()[0]; - } - - throw new LogicException('Unable to determine the sender of the message.'); - } } diff --git a/src/Symfony/Component/Mailer/Tests/SmtpEnvelopeTest.php b/src/Symfony/Component/Mailer/Tests/SmtpEnvelopeTest.php index 4e0c17f5e838b..6bc24bdf2f0b6 100644 --- a/src/Symfony/Component/Mailer/Tests/SmtpEnvelopeTest.php +++ b/src/Symfony/Component/Mailer/Tests/SmtpEnvelopeTest.php @@ -72,12 +72,13 @@ public function testSenderFromHeaders() $this->assertEquals('from@symfony.com', $e->getSender()->getAddress()); } - public function testSenderFromHeadersWithoutData() + public function testSenderFromHeadersWithoutFrom() { - $this->expectException(\LogicException::class); $headers = new Headers(); $headers->addMailboxListHeader('To', ['from@symfony.com']); - SmtpEnvelope::create(new Message($headers)); + $e = SmtpEnvelope::create($message = new Message($headers)); + $message->getHeaders()->addMailboxListHeader('From', ['from@symfony.com']); + $this->assertEquals('from@symfony.com', $e->getSender()->getAddress()); } public function testRecipientsFromHeaders() diff --git a/src/Symfony/Component/Mailer/Transport/AbstractTransport.php b/src/Symfony/Component/Mailer/Transport/AbstractTransport.php index deebd538f5e7f..748743fa8a307 100644 --- a/src/Symfony/Component/Mailer/Transport/AbstractTransport.php +++ b/src/Symfony/Component/Mailer/Transport/AbstractTransport.php @@ -15,6 +15,7 @@ use Psr\Log\NullLogger; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\Mailer\DelayedSmtpEnvelope; use Symfony\Component\Mailer\Event\MessageEvent; use Symfony\Component\Mailer\Exception\TransportException; use Symfony\Component\Mailer\SentMessage; @@ -62,7 +63,7 @@ public function send(RawMessage $message, SmtpEnvelope $envelope = null): ?SentM $envelope = clone $envelope; } else { try { - $envelope = SmtpEnvelope::create($message); + $envelope = new DelayedSmtpEnvelope($message); } catch (\Exception $e) { throw new TransportException('Cannot send message without a valid envelope.', 0, $e); } From e83886c81193bf259768a509ebb94bfbc2bac70e Mon Sep 17 00:00:00 2001 From: Toni Peric Date: Sat, 1 Jun 2019 15:18:31 +0200 Subject: [PATCH 19/59] Add missing translations --- .../Resources/translations/validators.hr.xlf | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.hr.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.hr.xlf index 60f02435f5f27..ccc0c0135a36d 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.hr.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.hr.xlf @@ -334,6 +334,34 @@ This value should be valid JSON. Ova vrijednost treba biti validan JSON. + + This collection should contain only unique elements. + Ova kolekcija treba sadržavati samo unikatne elemente. + + + This value should be positive. + Ova vrijednost treba biti pozitivna. + + + This value should be either positive or zero. + Ova vrijednost treba biti pozitivna ili jednaka nuli. + + + This value should be negative. + Ova vrijednost treba biti negativna. + + + This value should be either negative or zero. + Ova vrijednost treba biti negativna ili jednaka nuli. + + + This value is not a valid timezone. + Ova vrijednost nije validna vremenska zona. + + + This password has been leaked in a data breach, it must not be used. Please use another password. + Ova lozinka je procurila u nekom od sigurnosnih propusta, te je potrebno koristiti drugu lozinku. + From dee077016df2b0bbc9701ab128f380f6dcbb2059 Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Sun, 2 Jun 2019 04:44:45 +0200 Subject: [PATCH 20/59] [Messenger] set amqp content_type based on serialization format --- .../Transport/AmqpExt/AmqpSenderTest.php | 33 +++++++++++++++++++ .../Serialization/SerializerTest.php | 3 +- .../Transport/AmqpExt/AmqpSender.php | 16 ++++++++- .../Transport/Serialization/Serializer.php | 26 ++++++++++++++- 4 files changed, 75 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/AmqpSenderTest.php b/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/AmqpSenderTest.php index 95380a9e55b76..c13345f033977 100644 --- a/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/AmqpSenderTest.php +++ b/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/AmqpSenderTest.php @@ -69,6 +69,39 @@ public function testItSendsTheEncodedMessageWithoutHeaders() $sender->send($envelope); } + public function testContentTypeHeaderIsMovedToAttribute() + { + $envelope = new Envelope(new DummyMessage('Oy')); + $encoded = ['body' => '...', 'headers' => ['type' => DummyMessage::class, 'Content-Type' => 'application/json']]; + + $serializer = $this->getMockBuilder(SerializerInterface::class)->getMock(); + $serializer->method('encode')->with($envelope)->willReturnOnConsecutiveCalls($encoded); + + $connection = $this->getMockBuilder(Connection::class)->disableOriginalConstructor()->getMock(); + unset($encoded['headers']['Content-Type']); + $stamp = new AmqpStamp(null, AMQP_NOPARAM, ['content_type' => 'application/json']); + $connection->expects($this->once())->method('publish')->with($encoded['body'], $encoded['headers'], 0, $stamp); + + $sender = new AmqpSender($connection, $serializer); + $sender->send($envelope); + } + + public function testContentTypeHeaderDoesNotOverwriteAttribute() + { + $envelope = (new Envelope(new DummyMessage('Oy')))->with($stamp = new AmqpStamp('rk', AMQP_NOPARAM, ['content_type' => 'custom'])); + $encoded = ['body' => '...', 'headers' => ['type' => DummyMessage::class, 'Content-Type' => 'application/json']]; + + $serializer = $this->getMockBuilder(SerializerInterface::class)->getMock(); + $serializer->method('encode')->with($envelope)->willReturnOnConsecutiveCalls($encoded); + + $connection = $this->getMockBuilder(Connection::class)->disableOriginalConstructor()->getMock(); + unset($encoded['headers']['Content-Type']); + $connection->expects($this->once())->method('publish')->with($encoded['body'], $encoded['headers'], 0, $stamp); + + $sender = new AmqpSender($connection, $serializer); + $sender->send($envelope); + } + /** * @expectedException \Symfony\Component\Messenger\Exception\TransportException */ diff --git a/src/Symfony/Component/Messenger/Tests/Transport/Serialization/SerializerTest.php b/src/Symfony/Component/Messenger/Tests/Transport/Serialization/SerializerTest.php index f43ad2efcb839..897e4b10e0f18 100644 --- a/src/Symfony/Component/Messenger/Tests/Transport/Serialization/SerializerTest.php +++ b/src/Symfony/Component/Messenger/Tests/Transport/Serialization/SerializerTest.php @@ -55,7 +55,8 @@ public function testEncodedIsHavingTheBodyAndTypeHeader() $this->assertArrayHasKey('body', $encoded); $this->assertArrayHasKey('headers', $encoded); $this->assertArrayHasKey('type', $encoded['headers']); - $this->assertEquals(DummyMessage::class, $encoded['headers']['type']); + $this->assertSame(DummyMessage::class, $encoded['headers']['type']); + $this->assertSame('application/json', $encoded['headers']['Content-Type']); } public function testUsesTheCustomFormatAndContext() diff --git a/src/Symfony/Component/Messenger/Transport/AmqpExt/AmqpSender.php b/src/Symfony/Component/Messenger/Transport/AmqpExt/AmqpSender.php index c570c4cb33a7c..cc97af135e50b 100644 --- a/src/Symfony/Component/Messenger/Transport/AmqpExt/AmqpSender.php +++ b/src/Symfony/Component/Messenger/Transport/AmqpExt/AmqpSender.php @@ -50,12 +50,26 @@ public function send(Envelope $envelope): Envelope $delay = $delayStamp->getDelay(); } + $amqpStamp = $envelope->last(AmqpStamp::class); + if (isset($encodedMessage['headers']['Content-Type'])) { + $contentType = $encodedMessage['headers']['Content-Type']; + unset($encodedMessage['headers']['Content-Type']); + + $attributes = $amqpStamp ? $amqpStamp->getAttributes() : []; + + if (!isset($attributes['content_type'])) { + $attributes['content_type'] = $contentType; + + $amqpStamp = new AmqpStamp($amqpStamp ? $amqpStamp->getRoutingKey() : null, $amqpStamp ? $amqpStamp->getFlags() : AMQP_NOPARAM, $attributes); + } + } + try { $this->connection->publish( $encodedMessage['body'], $encodedMessage['headers'] ?? [], $delay, - $envelope->last(AmqpStamp::class) + $amqpStamp ); } catch (\AMQPException $e) { throw new TransportException($e->getMessage(), 0, $e); diff --git a/src/Symfony/Component/Messenger/Transport/Serialization/Serializer.php b/src/Symfony/Component/Messenger/Transport/Serialization/Serializer.php index c591acd05081e..3c13cb6e9038e 100644 --- a/src/Symfony/Component/Messenger/Transport/Serialization/Serializer.php +++ b/src/Symfony/Component/Messenger/Transport/Serialization/Serializer.php @@ -101,7 +101,7 @@ public function encode(Envelope $envelope): array $envelope = $envelope->withoutStampsOfType(NonSendableStampInterface::class); - $headers = ['type' => \get_class($envelope->getMessage())] + $this->encodeStamps($envelope); + $headers = ['type' => \get_class($envelope->getMessage())] + $this->encodeStamps($envelope) + $this->getContentTypeHeader(); return [ 'body' => $this->serializer->serialize($envelope->getMessage(), $this->format, $context), @@ -157,4 +157,28 @@ private function findFirstSerializerStamp(array $stamps): ?SerializerStamp return null; } + + private function getContentTypeHeader(): array + { + $mimeType = $this->getMimeTypeForFormat(); + + return null === $mimeType ? [] : ['Content-Type' => $mimeType]; + } + + private function getMimeTypeForFormat(): ?string + { + switch ($this->format) { + case 'json': + return 'application/json'; + case 'xml': + return 'application/xml'; + case 'yml': + case 'yaml': + return 'application/x-yaml'; + case 'csv': + return 'text/csv'; + } + + return null; + } } From 2b95fcaa6b308342a98f7dbd1e7ddf581d40fdb5 Mon Sep 17 00:00:00 2001 From: Massimiliano Arione Date: Mon, 3 Jun 2019 10:51:36 +0200 Subject: [PATCH 21/59] update italian validator translation --- .../Resources/translations/validators.it.xlf | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.it.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.it.xlf index 235d44d1bbee9..ca0b177586612 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.it.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.it.xlf @@ -330,6 +330,38 @@ This Business Identifier Code (BIC) is not associated with IBAN {{ iban }}. Questo codice identificativo bancario (BIC) non è associato all'IBAN {{ iban }}. + + This value should be valid JSON. + Questo valore dovrebbe essere un JSON valido. + + + This collection should contain only unique elements. + Questa collezione dovrebbe contenere solo elementi unici. + + + This value should be positive. + Questo valore dovrebbe essere positivo. + + + This value should be either positive or zero. + Questo valore dovrebbe essere positivo oppure zero. + + + This value should be negative. + Questo valore dovrebbe essere negativo. + + + This value should be either negative or zero. + Questo valore dovrebbe essere negativo oppure zero. + + + This value is not a valid timezone. + Questo valore non è un fuso orario valido. + + + This password has been leaked in a data breach, it must not be used. Please use another password. + Questa password è trapelata durante una compromissione di dati, non deve essere usata. Si prega di usre una password diversa. + From b37c1a818f8cea12ff8c91b9a41626ad678b7b06 Mon Sep 17 00:00:00 2001 From: Massimiliano Arione Date: Mon, 3 Jun 2019 11:50:31 +0200 Subject: [PATCH 22/59] fix typo in PR #31802 --- .../Validator/Resources/translations/validators.it.xlf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.it.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.it.xlf index ca0b177586612..f4c188d1dd3aa 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.it.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.it.xlf @@ -360,7 +360,7 @@ This password has been leaked in a data breach, it must not be used. Please use another password. - Questa password è trapelata durante una compromissione di dati, non deve essere usata. Si prega di usre una password diversa. + Questa password è trapelata durante una compromissione di dati, non deve essere usata. Si prega di usare una password diversa. From 56fe02512c8617eb4be5e8b914545f948bb6ce0f Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 3 Jun 2019 14:24:16 +0200 Subject: [PATCH 23/59] don't add embedded properties to wrapping class metadata --- .../Tests/Fixtures/DoctrineLoaderEmbed.php | 25 +++++++++++++++++++ .../Tests/Fixtures/DoctrineLoaderEntity.php | 5 ++++ .../Tests/Validator/DoctrineLoaderTest.php | 19 +++++++++++++- .../Doctrine/Validator/DoctrineLoader.php | 7 +++++- 4 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 src/Symfony/Bridge/Doctrine/Tests/Fixtures/DoctrineLoaderEmbed.php diff --git a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/DoctrineLoaderEmbed.php b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/DoctrineLoaderEmbed.php new file mode 100644 index 0000000000000..7985b9c4c613c --- /dev/null +++ b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/DoctrineLoaderEmbed.php @@ -0,0 +1,25 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\Doctrine\Tests\Fixtures; + +use Doctrine\ORM\Mapping as ORM; + +/** + * @ORM\Embeddable + */ +class DoctrineLoaderEmbed +{ + /** + * @ORM\Column(length=25) + */ + public $embeddedMaxLength; +} diff --git a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/DoctrineLoaderEntity.php b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/DoctrineLoaderEntity.php index 4a92edec8fa14..1f403cb1f8cae 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/DoctrineLoaderEntity.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/DoctrineLoaderEntity.php @@ -55,4 +55,9 @@ class DoctrineLoaderEntity * @ORM\Column(unique=true) */ public $alreadyMappedUnique; + + /** + * @ORM\Embedded(class=DoctrineLoaderEmbed::class) + */ + public $embedded; } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php index 63fd66eaddbd0..3e94da9065268 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php @@ -14,11 +14,14 @@ use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper; use Symfony\Bridge\Doctrine\Tests\Fixtures\BaseUser; +use Symfony\Bridge\Doctrine\Tests\Fixtures\DoctrineLoaderEmbed; use Symfony\Bridge\Doctrine\Tests\Fixtures\DoctrineLoaderEntity; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Bridge\Doctrine\Validator\DoctrineLoader; use Symfony\Component\Validator\Constraints\Length; +use Symfony\Component\Validator\Mapping\CascadingStrategy; use Symfony\Component\Validator\Mapping\ClassMetadata; +use Symfony\Component\Validator\Mapping\TraversalStrategy; use Symfony\Component\Validator\Tests\Fixtures\Entity; use Symfony\Component\Validator\Validation; use Symfony\Component\Validator\ValidatorBuilder; @@ -36,7 +39,7 @@ public function testLoadClassMetadata() $validator = Validation::createValidatorBuilder() ->enableAnnotationMapping() - ->addLoader(new DoctrineLoader(DoctrineTestHelper::createTestEntityManager(), '{^Symfony\\\\Bridge\\\\Doctrine\\\\Tests\\\\Fixtures\\\\DoctrineLoaderEntity$}')) + ->addLoader(new DoctrineLoader(DoctrineTestHelper::createTestEntityManager(), '{^Symfony\\\\Bridge\\\\Doctrine\\\\Tests\\\\Fixtures\\\\DoctrineLoader}')) ->getValidator() ; @@ -71,6 +74,20 @@ public function testLoadClassMetadata() $this->assertInstanceOf(Length::class, $alreadyMappedMaxLengthConstraints[0]); $this->assertSame(10, $alreadyMappedMaxLengthConstraints[0]->max); $this->assertSame(1, $alreadyMappedMaxLengthConstraints[0]->min); + + $embeddedMetadata = $classMetadata->getPropertyMetadata('embedded'); + $this->assertCount(1, $embeddedMetadata); + $this->assertSame(CascadingStrategy::CASCADE, $embeddedMetadata[0]->getCascadingStrategy()); + $this->assertSame(TraversalStrategy::IMPLICIT, $embeddedMetadata[0]->getTraversalStrategy()); + + $embeddedClassMetadata = $validator->getMetadataFor(new DoctrineLoaderEmbed()); + + $embeddedMaxLengthMetadata = $embeddedClassMetadata->getPropertyMetadata('embeddedMaxLength'); + $this->assertCount(1, $embeddedMaxLengthMetadata); + $embeddedMaxLengthConstraints = $embeddedMaxLengthMetadata[0]->getConstraints(); + $this->assertCount(1, $embeddedMaxLengthConstraints); + $this->assertInstanceOf(Length::class, $embeddedMaxLengthConstraints[0]); + $this->assertSame(25, $embeddedMaxLengthConstraints[0]->max); } public function testFieldMappingsConfiguration() diff --git a/src/Symfony/Bridge/Doctrine/Validator/DoctrineLoader.php b/src/Symfony/Bridge/Doctrine/Validator/DoctrineLoader.php index 9e3c32aa621e4..111733c1d51b7 100644 --- a/src/Symfony/Bridge/Doctrine/Validator/DoctrineLoader.php +++ b/src/Symfony/Bridge/Doctrine/Validator/DoctrineLoader.php @@ -17,6 +17,7 @@ use Doctrine\ORM\Mapping\MappingException as OrmMappingException; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Component\Validator\Constraints\Length; +use Symfony\Component\Validator\Constraints\Valid; use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Mapping\Loader\LoaderInterface; @@ -78,7 +79,11 @@ public function loadClassMetadata(ClassMetadata $metadata): bool $constraint = $this->getLengthConstraint($metadata, $mapping['fieldName']); if (null === $constraint) { - $metadata->addPropertyConstraint($mapping['fieldName'], new Length(['max' => $mapping['length']])); + if (isset($mapping['originalClass'])) { + $metadata->addPropertyConstraint($mapping['declaredField'], new Valid()); + } else { + $metadata->addPropertyConstraint($mapping['fieldName'], new Length(['max' => $mapping['length']])); + } } elseif (null === $constraint->max) { // If a Length constraint exists and no max length has been explicitly defined, set it $constraint->max = $mapping['length']; From 5c394eeb79e45206f8f86e5a379e2fa2b7a952db Mon Sep 17 00:00:00 2001 From: Pierre du Plessis Date: Mon, 3 Jun 2019 16:14:28 +0200 Subject: [PATCH 24/59] Collect locale details earlier in the process in TranslationDataCollector --- .../Translation/DataCollector/TranslationDataCollector.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php b/src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php index d99b493ac68a6..35dfc0e344f86 100644 --- a/src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php +++ b/src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php @@ -36,12 +36,9 @@ public function lateCollect() { $messages = $this->sanitizeCollectedMessages($this->translator->getCollectedMessages()); - $this->data = $this->computeCount($messages); + $this->data += $this->computeCount($messages); $this->data['messages'] = $messages; - $this->data['locale'] = $this->translator->getLocale(); - $this->data['fallback_locales'] = $this->translator->getFallbackLocales(); - $this->data = $this->cloneVar($this->data); } @@ -50,6 +47,8 @@ public function lateCollect() */ public function collect(Request $request, Response $response, \Exception $exception = null) { + $this->data['locale'] = $this->translator->getLocale(); + $this->data['fallback_locales'] = $this->translator->getFallbackLocales(); } /** From 648c6949fc1360247a86418317f38f77fb303de5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Mon, 3 Jun 2019 17:30:31 +0200 Subject: [PATCH 25/59] Simplify code - catch \Throwable capture all exceptions This is a legacy when we did support PHP 5.X --- src/Symfony/Component/Filesystem/Filesystem.php | 1 - src/Symfony/Component/HttpKernel/Kernel.php | 2 -- 2 files changed, 3 deletions(-) diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index 082084b4d93d1..9ec1e943546fa 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -750,7 +750,6 @@ private static function box($func) return $result; } catch (\Throwable $e) { - } catch (\Exception $e) { } \restore_error_handler(); diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 14257d0f6003d..4e316cdfdc02e 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -487,7 +487,6 @@ protected function initializeContainer() $fresh = true; } } catch (\Throwable $e) { - } catch (\Exception $e) { } finally { error_reporting($errorLevel); } @@ -556,7 +555,6 @@ protected function initializeContainer() try { $oldContainer = include $cache->getPath(); } catch (\Throwable $e) { - } catch (\Exception $e) { } finally { error_reporting($errorLevel); } From 0e741f960064e12e3383098b80294864a8f359b6 Mon Sep 17 00:00:00 2001 From: Massimiliano Arione Date: Mon, 3 Jun 2019 15:30:08 +0200 Subject: [PATCH 26/59] fix type hint for salt in PasswordEncoderInterface --- .../Security/Core/Encoder/BasePasswordEncoder.php | 4 ++-- .../Security/Core/Encoder/PasswordEncoderInterface.php | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Component/Security/Core/Encoder/BasePasswordEncoder.php b/src/Symfony/Component/Security/Core/Encoder/BasePasswordEncoder.php index 3c3ea1aa17366..3a5c4f0c4ba81 100644 --- a/src/Symfony/Component/Security/Core/Encoder/BasePasswordEncoder.php +++ b/src/Symfony/Component/Security/Core/Encoder/BasePasswordEncoder.php @@ -48,8 +48,8 @@ protected function demergePasswordAndSalt($mergedPasswordSalt) /** * Merges a password and a salt. * - * @param string $password The password to be used - * @param string $salt The salt to be used + * @param string $password The password to be used + * @param string|null $salt The salt to be used * * @return string a merged password and salt * diff --git a/src/Symfony/Component/Security/Core/Encoder/PasswordEncoderInterface.php b/src/Symfony/Component/Security/Core/Encoder/PasswordEncoderInterface.php index e0573051eb273..03cdaca44aef7 100644 --- a/src/Symfony/Component/Security/Core/Encoder/PasswordEncoderInterface.php +++ b/src/Symfony/Component/Security/Core/Encoder/PasswordEncoderInterface.php @@ -23,8 +23,8 @@ interface PasswordEncoderInterface /** * Encodes the raw password. * - * @param string $raw The password to encode - * @param string $salt The salt + * @param string $raw The password to encode + * @param string|null $salt The salt * * @return string The encoded password * @@ -36,9 +36,9 @@ public function encodePassword($raw, $salt); /** * Checks a raw password against an encoded password. * - * @param string $encoded An encoded password - * @param string $raw A raw password - * @param string $salt The salt + * @param string $encoded An encoded password + * @param string $raw A raw password + * @param string|null $salt The salt * * @return bool true if the password is valid, false otherwise * From ec690b214580c2974183563a56727bc82d68f200 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 1 Jun 2019 15:16:50 +0200 Subject: [PATCH 27/59] [Translation] Fixed case sensitivity of lint:xliff command --- .../Translation/Command/XliffLintCommand.php | 4 +++- .../Tests/Command/XliffLintCommandTest.php | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Translation/Command/XliffLintCommand.php b/src/Symfony/Component/Translation/Command/XliffLintCommand.php index 9bea4d9499392..3c2cc9efde6f4 100644 --- a/src/Symfony/Component/Translation/Command/XliffLintCommand.php +++ b/src/Symfony/Component/Translation/Command/XliffLintCommand.php @@ -124,7 +124,9 @@ private function validate($content, $file = null) $normalizedLocale = preg_quote(str_replace('-', '_', $targetLanguage), '/'); // strict file names require translation files to be named '____.locale.xlf' // otherwise, both '____.locale.xlf' and 'locale.____.xlf' are allowed - $expectedFilenamePattern = $this->requireStrictFileNames ? sprintf('/^.*\.%s\.xlf/', $normalizedLocale) : sprintf('/^(.*\.%s\.xlf|%s\..*\.xlf)/', $normalizedLocale, $normalizedLocale); + // also, the regexp matching must be case-insensitive, as defined for 'target-language' values + // http://docs.oasis-open.org/xliff/v1.2/os/xliff-core.html#target-language + $expectedFilenamePattern = $this->requireStrictFileNames ? sprintf('/^.*\.(?i:%s)\.xlf/', $normalizedLocale) : sprintf('/^(.*\.(?i:%s)\.xlf|(?i:%s)\..*\.xlf)/', $normalizedLocale, $normalizedLocale); if (0 === preg_match($expectedFilenamePattern, basename($file))) { $errors[] = [ diff --git a/src/Symfony/Component/Translation/Tests/Command/XliffLintCommandTest.php b/src/Symfony/Component/Translation/Tests/Command/XliffLintCommandTest.php index 516d98af53dba..df2e2f0951dd3 100644 --- a/src/Symfony/Component/Translation/Tests/Command/XliffLintCommandTest.php +++ b/src/Symfony/Component/Translation/Tests/Command/XliffLintCommandTest.php @@ -94,6 +94,17 @@ public function testLintIncorrectTargetLanguage() $this->assertContains('There is a mismatch between the language included in the file name ("messages.en.xlf") and the "es" value used in the "target-language" attribute of the file.', trim($tester->getDisplay())); } + public function testLintTargetLanguageIsCaseInsensitive() + { + $tester = $this->createCommandTester(); + $filename = $this->createFile('note', 'zh-cn', 'messages.zh_CN.xlf'); + + $tester->execute(['filename' => $filename], ['decorated' => false]); + + $this->assertEquals(0, $tester->getStatusCode()); + $this->assertContains('[OK] All 1 XLIFF files contain valid syntax.', trim($tester->getDisplay())); + } + /** * @expectedException \RuntimeException */ From 4fce813ed06f8a2608d9c6746605719ac606ba01 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 4 Jun 2019 08:38:41 +0200 Subject: [PATCH 28/59] [HttpClient] fix unregistering the debug buffer when using curl --- src/Symfony/Component/HttpClient/Response/CurlResponse.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Component/HttpClient/Response/CurlResponse.php b/src/Symfony/Component/HttpClient/Response/CurlResponse.php index 8cb5081e7057a..e9db983d7ba7a 100644 --- a/src/Symfony/Component/HttpClient/Response/CurlResponse.php +++ b/src/Symfony/Component/HttpClient/Response/CurlResponse.php @@ -167,6 +167,7 @@ public function getInfo(string $type = null) if (!\in_array(curl_getinfo($this->handle, CURLINFO_PRIVATE), ['headers', 'content'], true)) { rewind($this->debugBuffer); $info['debug'] = stream_get_contents($this->debugBuffer); + curl_setopt($this->handle, CURLOPT_VERBOSE, false); fclose($this->debugBuffer); $this->debugBuffer = null; $this->finalInfo = $info; From bdbac2c6e666454a743b45e0f91612593e2755bd Mon Sep 17 00:00:00 2001 From: Robert Kopera Date: Tue, 7 May 2019 15:35:36 +0200 Subject: [PATCH 29/59] [Security] added support for updated \"distinguished name\" format in x509 authentication --- .../Http/Firewall/X509AuthenticationListener.php | 5 ++++- .../Firewall/X509AuthenticationListenerTest.php | 13 +++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Component/Security/Http/Firewall/X509AuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/X509AuthenticationListener.php index d17ef7464e7f3..76b1cad349bc2 100644 --- a/src/Symfony/Component/Security/Http/Firewall/X509AuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/X509AuthenticationListener.php @@ -44,7 +44,10 @@ protected function getPreAuthenticatedData(Request $request) $user = null; if ($request->server->has($this->userKey)) { $user = $request->server->get($this->userKey); - } elseif ($request->server->has($this->credentialKey) && preg_match('#/emailAddress=(.+\@.+\..+)(/|$)#', $request->server->get($this->credentialKey), $matches)) { + } elseif ( + $request->server->has($this->credentialKey) + && preg_match('#emailAddress=(.+\@.+\.[^,/]+)($|,|/)#', $request->server->get($this->credentialKey), $matches) + ) { $user = $matches[1]; } diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/X509AuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/X509AuthenticationListenerTest.php index c55eaae0f3157..577ca7c38f1b3 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/X509AuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/X509AuthenticationListenerTest.php @@ -56,9 +56,8 @@ public static function dataProviderGetPreAuthenticatedData() /** * @dataProvider dataProviderGetPreAuthenticatedDataNoUser */ - public function testGetPreAuthenticatedDataNoUser($emailAddress) + public function testGetPreAuthenticatedDataNoUser($emailAddress, $credentials) { - $credentials = 'CN=Sample certificate DN/emailAddress='.$emailAddress; $request = new Request([], [], [], [], [], ['SSL_CLIENT_S_DN' => $credentials]); $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); @@ -76,10 +75,12 @@ public function testGetPreAuthenticatedDataNoUser($emailAddress) public static function dataProviderGetPreAuthenticatedDataNoUser() { - return [ - 'basicEmailAddress' => ['cert@example.com'], - 'emailAddressWithPlusSign' => ['cert+something@example.com'], - ]; + yield ['cert@example.com', 'CN=Sample certificate DN/emailAddress=cert@example.com']; + yield ['cert+something@example.com', 'CN=Sample certificate DN/emailAddress=cert+something@example.com']; + yield ['cert@example.com', 'CN=Sample certificate DN,emailAddress=cert@example.com']; + yield ['cert+something@example.com', 'CN=Sample certificate DN,emailAddress=cert+something@example.com']; + yield ['cert+something@example.com', 'emailAddress=cert+something@example.com,CN=Sample certificate DN']; + yield ['cert+something@example.com', 'emailAddress=cert+something@example.com']; } /** From 4acca42330df4e555f0ad4438be013df1037f70a Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 4 Jun 2019 10:18:38 +0200 Subject: [PATCH 30/59] [HttpClient] Don't throw InvalidArgumentException on bad Location header --- .../Component/HttpClient/CurlHttpClient.php | 11 ++++++++-- .../Component/HttpClient/NativeHttpClient.php | 11 +++++++++- .../HttpClient/Response/CurlResponse.php | 21 ++++++++++++------- .../HttpClient/Test/Fixtures/web/index.php | 4 ++++ .../HttpClient/Test/HttpClientTestCase.php | 14 +++++++++++++ 5 files changed, 50 insertions(+), 11 deletions(-) diff --git a/src/Symfony/Component/HttpClient/CurlHttpClient.php b/src/Symfony/Component/HttpClient/CurlHttpClient.php index fd8ecbaeed25e..9f7401b0aa466 100644 --- a/src/Symfony/Component/HttpClient/CurlHttpClient.php +++ b/src/Symfony/Component/HttpClient/CurlHttpClient.php @@ -14,6 +14,7 @@ use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerAwareTrait; use Psr\Log\LoggerInterface; +use Symfony\Component\HttpClient\Exception\InvalidArgumentException; use Symfony\Component\HttpClient\Exception\TransportException; use Symfony\Component\HttpClient\Internal\CurlClientState; use Symfony\Component\HttpClient\Internal\PushedResponse; @@ -392,14 +393,20 @@ private static function createRedirectResolver(array $options, string $host): \C } return static function ($ch, string $location) use ($redirectHeaders) { - if ($redirectHeaders && $host = parse_url($location, PHP_URL_HOST)) { + try { + $location = self::parseUrl($location); + } catch (InvalidArgumentException $e) { + return null; + } + + if ($redirectHeaders && $host = parse_url('http:'.$location['authority'], PHP_URL_HOST)) { $requestHeaders = $redirectHeaders['host'] === $host ? $redirectHeaders['with_auth'] : $redirectHeaders['no_auth']; curl_setopt($ch, CURLOPT_HTTPHEADER, $requestHeaders); } $url = self::parseUrl(curl_getinfo($ch, CURLINFO_EFFECTIVE_URL)); - return implode('', self::resolveUrl(self::parseUrl($location), $url)); + return implode('', self::resolveUrl($location, $url)); }; } } diff --git a/src/Symfony/Component/HttpClient/NativeHttpClient.php b/src/Symfony/Component/HttpClient/NativeHttpClient.php index b8e39e9479ae9..55313b1ccc740 100644 --- a/src/Symfony/Component/HttpClient/NativeHttpClient.php +++ b/src/Symfony/Component/HttpClient/NativeHttpClient.php @@ -13,6 +13,7 @@ use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerAwareTrait; +use Symfony\Component\HttpClient\Exception\InvalidArgumentException; use Symfony\Component\HttpClient\Exception\TransportException; use Symfony\Component\HttpClient\Internal\NativeClientState; use Symfony\Component\HttpClient\Response\NativeResponse; @@ -352,7 +353,15 @@ private static function createRedirectResolver(array $options, string $host, ?ar return null; } - $url = self::resolveUrl(self::parseUrl($location), $info['url']); + try { + $url = self::parseUrl($location); + } catch (InvalidArgumentException $e) { + $info['redirect_url'] = null; + + return null; + } + + $url = self::resolveUrl($url, $info['url']); $info['redirect_url'] = implode('', $url); if ($info['redirect_count'] >= $maxRedirects) { diff --git a/src/Symfony/Component/HttpClient/Response/CurlResponse.php b/src/Symfony/Component/HttpClient/Response/CurlResponse.php index e9db983d7ba7a..1c5114e92f461 100644 --- a/src/Symfony/Component/HttpClient/Response/CurlResponse.php +++ b/src/Symfony/Component/HttpClient/Response/CurlResponse.php @@ -310,14 +310,19 @@ private static function parseHeaderLine($ch, string $data, array &$info, array & $info['redirect_url'] = null; if (300 <= $statusCode && $statusCode < 400 && null !== $location) { - $info['redirect_url'] = $resolveRedirect($ch, $location); - $url = parse_url($location ?? ':'); - - if (isset($url['host']) && null !== $ip = $multi->dnsCache->hostnames[$url['host'] = strtolower($url['host'])] ?? null) { - // Populate DNS cache for redirects if needed - $port = $url['port'] ?? ('http' === ($url['scheme'] ?? parse_url(curl_getinfo($ch, CURLINFO_EFFECTIVE_URL), PHP_URL_SCHEME)) ? 80 : 443); - curl_setopt($ch, CURLOPT_RESOLVE, ["{$url['host']}:$port:$ip"]); - $multi->dnsCache->removals["-{$url['host']}:$port"] = "-{$url['host']}:$port"; + if (null === $info['redirect_url'] = $resolveRedirect($ch, $location)) { + $options['max_redirects'] = curl_getinfo($ch, CURLINFO_REDIRECT_COUNT); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); + curl_setopt($ch, CURLOPT_MAXREDIRS, $options['max_redirects']); + } else { + $url = parse_url($location ?? ':'); + + if (isset($url['host']) && null !== $ip = $multi->dnsCache->hostnames[$url['host'] = strtolower($url['host'])] ?? null) { + // Populate DNS cache for redirects if needed + $port = $url['port'] ?? ('http' === ($url['scheme'] ?? parse_url(curl_getinfo($ch, CURLINFO_EFFECTIVE_URL), PHP_URL_SCHEME)) ? 80 : 443); + curl_setopt($ch, CURLOPT_RESOLVE, ["{$url['host']}:$port:$ip"]); + $multi->dnsCache->removals["-{$url['host']}:$port"] = "-{$url['host']}:$port"; + } } } diff --git a/src/Symfony/Contracts/HttpClient/Test/Fixtures/web/index.php b/src/Symfony/Contracts/HttpClient/Test/Fixtures/web/index.php index ff68ab6878a2b..6763198937916 100644 --- a/src/Symfony/Contracts/HttpClient/Test/Fixtures/web/index.php +++ b/src/Symfony/Contracts/HttpClient/Test/Fixtures/web/index.php @@ -55,6 +55,10 @@ header('Location: http://foo.example.', true, 301); break; + case '/301/invalid': + header('Location: //?foo=bar', true, 301); + break; + case '/302': if (!isset($vars['HTTP_AUTHORIZATION'])) { header('Location: http://localhost:8057/', true, 302); diff --git a/src/Symfony/Contracts/HttpClient/Test/HttpClientTestCase.php b/src/Symfony/Contracts/HttpClient/Test/HttpClientTestCase.php index b898ba55c6c95..5bb246319e327 100644 --- a/src/Symfony/Contracts/HttpClient/Test/HttpClientTestCase.php +++ b/src/Symfony/Contracts/HttpClient/Test/HttpClientTestCase.php @@ -259,6 +259,20 @@ public function testRedirects() $this->assertSame($expected, $filteredHeaders); } + public function testInvalidRedirect() + { + $client = $this->getHttpClient(__FUNCTION__); + $response = $client->request('GET', 'http://localhost:8057/301/invalid'); + + $this->assertSame(301, $response->getStatusCode()); + $this->assertSame(['//?foo=bar'], $response->getHeaders(false)['location']); + $this->assertSame(0, $response->getInfo('redirect_count')); + $this->assertNull($response->getInfo('redirect_url')); + + $this->expectException(RedirectionExceptionInterface::class); + $response->getHeaders(); + } + public function testRelativeRedirects() { $client = $this->getHttpClient(__FUNCTION__); From adfa1ef3ceeec1ebaa3fc001a5f00cb59a14426b Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 4 Jun 2019 10:43:25 +0200 Subject: [PATCH 31/59] do not process private properties from parent class --- .../Tests/Fixtures/DoctrineLoaderEntity.php | 2 +- .../Fixtures/DoctrineLoaderParentEntity.php | 40 +++++++++++++++++++ .../Tests/Validator/DoctrineLoaderTest.php | 20 ++++++++++ .../Doctrine/Validator/DoctrineLoader.php | 2 +- 4 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 src/Symfony/Bridge/Doctrine/Tests/Fixtures/DoctrineLoaderParentEntity.php diff --git a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/DoctrineLoaderEntity.php b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/DoctrineLoaderEntity.php index 1f403cb1f8cae..b6b6a681bd5f2 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/DoctrineLoaderEntity.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/DoctrineLoaderEntity.php @@ -21,7 +21,7 @@ * * @author Kévin Dunglas */ -class DoctrineLoaderEntity +class DoctrineLoaderEntity extends DoctrineLoaderParentEntity { /** * @ORM\Id diff --git a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/DoctrineLoaderParentEntity.php b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/DoctrineLoaderParentEntity.php new file mode 100644 index 0000000000000..7ec0263559c71 --- /dev/null +++ b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/DoctrineLoaderParentEntity.php @@ -0,0 +1,40 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\Doctrine\Tests\Fixtures; + +use Doctrine\ORM\Mapping as ORM; + +/** + * @ORM\MappedSuperclass + */ +class DoctrineLoaderParentEntity +{ + /** + * @ORM\Column(length=35) + */ + public $publicParentMaxLength; + + /** + * @ORM\Column(length=30) + */ + private $privateParentMaxLength; + + public function getPrivateParentMaxLength() + { + return $this->privateParentMaxLength; + } + + public function setPrivateParentMaxLength($privateParentMaxLength): void + { + $this->privateParentMaxLength = $privateParentMaxLength; + } +} diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php index 3e94da9065268..e673d79210f85 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php @@ -16,6 +16,7 @@ use Symfony\Bridge\Doctrine\Tests\Fixtures\BaseUser; use Symfony\Bridge\Doctrine\Tests\Fixtures\DoctrineLoaderEmbed; use Symfony\Bridge\Doctrine\Tests\Fixtures\DoctrineLoaderEntity; +use Symfony\Bridge\Doctrine\Tests\Fixtures\DoctrineLoaderParentEntity; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Bridge\Doctrine\Validator\DoctrineLoader; use Symfony\Component\Validator\Constraints\Length; @@ -75,11 +76,30 @@ public function testLoadClassMetadata() $this->assertSame(10, $alreadyMappedMaxLengthConstraints[0]->max); $this->assertSame(1, $alreadyMappedMaxLengthConstraints[0]->min); + $publicParentMaxLengthMetadata = $classMetadata->getPropertyMetadata('publicParentMaxLength'); + $this->assertCount(1, $publicParentMaxLengthMetadata); + $publicParentMaxLengthConstraints = $publicParentMaxLengthMetadata[0]->getConstraints(); + $this->assertCount(1, $publicParentMaxLengthConstraints); + $this->assertInstanceOf(Length::class, $publicParentMaxLengthConstraints[0]); + $this->assertSame(35, $publicParentMaxLengthConstraints[0]->max); + $embeddedMetadata = $classMetadata->getPropertyMetadata('embedded'); $this->assertCount(1, $embeddedMetadata); $this->assertSame(CascadingStrategy::CASCADE, $embeddedMetadata[0]->getCascadingStrategy()); $this->assertSame(TraversalStrategy::IMPLICIT, $embeddedMetadata[0]->getTraversalStrategy()); + $parentClassMetadata = $validator->getMetadataFor(new DoctrineLoaderParentEntity()); + + $publicParentMaxLengthMetadata = $parentClassMetadata->getPropertyMetadata('publicParentMaxLength'); + $this->assertCount(0, $publicParentMaxLengthMetadata); + + $privateParentMaxLengthMetadata = $parentClassMetadata->getPropertyMetadata('privateParentMaxLength'); + $this->assertCount(1, $privateParentMaxLengthMetadata); + $privateParentMaxLengthConstraints = $privateParentMaxLengthMetadata[0]->getConstraints(); + $this->assertCount(1, $privateParentMaxLengthConstraints); + $this->assertInstanceOf(Length::class, $privateParentMaxLengthConstraints[0]); + $this->assertSame(30, $privateParentMaxLengthConstraints[0]->max); + $embeddedClassMetadata = $validator->getMetadataFor(new DoctrineLoaderEmbed()); $embeddedMaxLengthMetadata = $embeddedClassMetadata->getPropertyMetadata('embeddedMaxLength'); diff --git a/src/Symfony/Bridge/Doctrine/Validator/DoctrineLoader.php b/src/Symfony/Bridge/Doctrine/Validator/DoctrineLoader.php index 111733c1d51b7..b3993518dd344 100644 --- a/src/Symfony/Bridge/Doctrine/Validator/DoctrineLoader.php +++ b/src/Symfony/Bridge/Doctrine/Validator/DoctrineLoader.php @@ -81,7 +81,7 @@ public function loadClassMetadata(ClassMetadata $metadata): bool if (null === $constraint) { if (isset($mapping['originalClass'])) { $metadata->addPropertyConstraint($mapping['declaredField'], new Valid()); - } else { + } elseif (property_exists($className, $mapping['fieldName'])) { $metadata->addPropertyConstraint($mapping['fieldName'], new Length(['max' => $mapping['length']])); } } elseif (null === $constraint->max) { From d56ae06ca3d26ee48485dba0079ea985cbca947f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 4 Jun 2019 11:03:18 +0200 Subject: [PATCH 32/59] changed type hints --- src/Symfony/Component/Mailer/DelayedSmtpEnvelope.php | 9 +-------- src/Symfony/Component/Mailer/Tests/SmtpEnvelopeTest.php | 6 ------ src/Symfony/Component/Mime/MessageConverter.php | 7 +------ 3 files changed, 2 insertions(+), 20 deletions(-) diff --git a/src/Symfony/Component/Mailer/DelayedSmtpEnvelope.php b/src/Symfony/Component/Mailer/DelayedSmtpEnvelope.php index 95356fd9e350b..ef677d7de8a86 100644 --- a/src/Symfony/Component/Mailer/DelayedSmtpEnvelope.php +++ b/src/Symfony/Component/Mailer/DelayedSmtpEnvelope.php @@ -11,12 +11,10 @@ namespace Symfony\Component\Mailer; -use Symfony\Component\Mailer\Exception\InvalidArgumentException; use Symfony\Component\Mailer\Exception\LogicException; use Symfony\Component\Mime\Address; use Symfony\Component\Mime\Header\Headers; use Symfony\Component\Mime\Message; -use Symfony\Component\Mime\RawMessage; /** * @author Fabien Potencier @@ -31,13 +29,8 @@ final class DelayedSmtpEnvelope extends SmtpEnvelope private $recipientsSet = false; private $message; - public function __construct(RawMessage $message) + public function __construct(Message $message) { - if (!$message instanceof Message) { - // FIXME: parse the raw message to create the envelope? - throw new InvalidArgumentException(sprintf('Unable to create an SmtpEnvelope from a "%s" message.', RawMessage::class)); - } - $this->message = $message; } diff --git a/src/Symfony/Component/Mailer/Tests/SmtpEnvelopeTest.php b/src/Symfony/Component/Mailer/Tests/SmtpEnvelopeTest.php index 6bc24bdf2f0b6..e64be3100bb12 100644 --- a/src/Symfony/Component/Mailer/Tests/SmtpEnvelopeTest.php +++ b/src/Symfony/Component/Mailer/Tests/SmtpEnvelopeTest.php @@ -91,10 +91,4 @@ public function testRecipientsFromHeaders() $e = SmtpEnvelope::create(new Message($headers)); $this->assertEquals([new Address('to@symfony.com'), new Address('cc@symfony.com'), new Address('bcc@symfony.com')], $e->getRecipients()); } - - public function testCreateWithRawMessage() - { - $this->expectException(\InvalidArgumentException::class); - SmtpEnvelope::create(new RawMessage('')); - } } diff --git a/src/Symfony/Component/Mime/MessageConverter.php b/src/Symfony/Component/Mime/MessageConverter.php index 287cbd2f1cbc4..b139f1c086db0 100644 --- a/src/Symfony/Component/Mime/MessageConverter.php +++ b/src/Symfony/Component/Mime/MessageConverter.php @@ -28,17 +28,12 @@ final class MessageConverter /** * @throws RuntimeException when unable to convert the message to an email */ - public static function toEmail(RawMessage $message): Email + public static function toEmail(Message $message): Email { if ($message instanceof Email) { return $message; } - if (RawMessage::class === \get_class($message)) { - // FIXME: parse the raw message to create the envelope? - throw new RuntimeException(sprintf('Unable to create an Email from an instance of "%s" as it is not supported yet.', RawMessage::class)); - } - // try to convert to a "simple" Email instance $body = $message->getBody(); if ($body instanceof TextPart) { From c402418723b965edd60790a2c69e93ca6e46083a Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 3 Jun 2019 19:56:51 +0200 Subject: [PATCH 33/59] [HttpClient] add $response->cancel() --- composer.json | 2 +- .../Component/HttpClient/Response/ResponseTrait.php | 9 +++++++++ src/Symfony/Component/HttpClient/composer.json | 2 +- src/Symfony/Contracts/HttpClient/ResponseInterface.php | 5 +++++ .../Contracts/HttpClient/Test/HttpClientTestCase.php | 10 ++++++++++ 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 4824ffbb24c06..572f5f842d446 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ "psr/container": "^1.0", "psr/link": "^1.0", "psr/log": "~1.0", - "symfony/contracts": "^1.1.1", + "symfony/contracts": "^1.1.3", "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-intl-icu": "~1.0", "symfony/polyfill-intl-idn": "^1.10", diff --git a/src/Symfony/Component/HttpClient/Response/ResponseTrait.php b/src/Symfony/Component/HttpClient/Response/ResponseTrait.php index 79cc40d5d847f..e1777c3e12e10 100644 --- a/src/Symfony/Component/HttpClient/Response/ResponseTrait.php +++ b/src/Symfony/Component/HttpClient/Response/ResponseTrait.php @@ -169,6 +169,15 @@ public function toArray(bool $throw = true): array return $content; } + /** + * {@inheritdoc} + */ + public function cancel(): void + { + $this->info['error'] = 'Response has been canceled.'; + $this->close(); + } + /** * Closes the response and all its network handles. */ diff --git a/src/Symfony/Component/HttpClient/composer.json b/src/Symfony/Component/HttpClient/composer.json index 4ffe7bfd82b54..bda296a9d92e0 100644 --- a/src/Symfony/Component/HttpClient/composer.json +++ b/src/Symfony/Component/HttpClient/composer.json @@ -21,7 +21,7 @@ "require": { "php": "^7.1.3", "psr/log": "^1.0", - "symfony/http-client-contracts": "^1.1", + "symfony/http-client-contracts": "^1.1.3", "symfony/polyfill-php73": "^1.11" }, "require-dev": { diff --git a/src/Symfony/Contracts/HttpClient/ResponseInterface.php b/src/Symfony/Contracts/HttpClient/ResponseInterface.php index 6751184b87a90..a7e01be84c28f 100644 --- a/src/Symfony/Contracts/HttpClient/ResponseInterface.php +++ b/src/Symfony/Contracts/HttpClient/ResponseInterface.php @@ -71,6 +71,11 @@ public function getContent(bool $throw = true): string; */ public function toArray(bool $throw = true): array; + /** + * Cancels the response. + */ + public function cancel(): void; + /** * Returns info coming from the transport layer. * diff --git a/src/Symfony/Contracts/HttpClient/Test/HttpClientTestCase.php b/src/Symfony/Contracts/HttpClient/Test/HttpClientTestCase.php index b898ba55c6c95..a5ea76f25629b 100644 --- a/src/Symfony/Contracts/HttpClient/Test/HttpClientTestCase.php +++ b/src/Symfony/Contracts/HttpClient/Test/HttpClientTestCase.php @@ -481,6 +481,16 @@ public function testPostCallback() $this->assertSame(['foo' => '0123456789', 'REQUEST_METHOD' => 'POST'], $response->toArray()); } + public function testCancel() + { + $client = $this->getHttpClient(__FUNCTION__); + $response = $client->request('GET', 'http://localhost:8057/timeout-header'); + + $response->cancel(); + $this->expectException(TransportExceptionInterface::class); + $response->getHeaders(); + } + public function testOnProgressCancel() { $client = $this->getHttpClient(__FUNCTION__); From 38a5b2c9437286bff2965d92b7f18725813219c8 Mon Sep 17 00:00:00 2001 From: mmokhi Date: Mon, 27 May 2019 18:46:39 +0200 Subject: [PATCH 34/59] Fix inconsistency in json format regarding DST value The `$expected` template seems not to be consistent. It will change when the DST value is 0 (it'll not have `dst_savings` for example) This patch takes care of the issue, by adding proper condition. Sponsored-by: Platform.sh --- .../VarDumper/Tests/Caster/IntlCasterTest.php | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/IntlCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/IntlCasterTest.php index c93b9df83d55a..0bff5bf496385 100644 --- a/src/Symfony/Component/VarDumper/Tests/Caster/IntlCasterTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Caster/IntlCasterTest.php @@ -240,6 +240,12 @@ public function testCastDateFormatter() $expectedTimeType = $var->getTimeType(); $expectedDateType = $var->getDateType(); + $expectedTimeZone = $var->getTimeZone(); + $expectedTimeZoneDisplayName = $expectedTimeZone->getDisplayName(); + $expectedTimeZoneID = $expectedTimeZone->getID(); + $expectedTimeZoneRawOffset = $expectedTimeZone->getRawOffset(); + $expectedTimeZoneDSTSavings = $expectedTimeZone->useDaylightTime() ? "\n dst_savings: ".$expectedTimeZone->getDSTSavings() : ''; + $expectedCalendarObject = $var->getCalendarObject(); $expectedCalendarObjectType = $expectedCalendarObject->getType(); $expectedCalendarObjectFirstDayOfWeek = $expectedCalendarObject->getFirstDayOfWeek(); @@ -254,13 +260,7 @@ public function testCastDateFormatter() $expectedCalendarObjectTimeZoneDisplayName = $expectedCalendarObjectTimeZone->getDisplayName(); $expectedCalendarObjectTimeZoneID = $expectedCalendarObjectTimeZone->getID(); $expectedCalendarObjectTimeZoneRawOffset = $expectedCalendarObjectTimeZone->getRawOffset(); - $expectedCalendarObjectTimeZoneDSTSavings = $expectedCalendarObjectTimeZone->getDSTSavings(); - - $expectedTimeZone = $var->getTimeZone(); - $expectedTimeZoneDisplayName = $expectedTimeZone->getDisplayName(); - $expectedTimeZoneID = $expectedTimeZone->getID(); - $expectedTimeZoneRawOffset = $expectedTimeZone->getRawOffset(); - $expectedTimeZoneDSTSavings = $expectedTimeZone->getDSTSavings(); + $expectedCalendarObjectTimeZoneDSTSavings = $expectedTimeZone->useDaylightTime() ? "\n dst_savings: ".$expectedCalendarObjectTimeZone->getDSTSavings() : ''; $expected = << Date: Tue, 4 Jun 2019 15:28:20 +0200 Subject: [PATCH 35/59] [Form] add missing symfony/service-contracts dependency --- src/Symfony/Component/Form/composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Form/composer.json b/src/Symfony/Component/Form/composer.json index 8e2f0989dfa46..9d29f76336c9e 100644 --- a/src/Symfony/Component/Form/composer.json +++ b/src/Symfony/Component/Form/composer.json @@ -22,7 +22,8 @@ "symfony/options-resolver": "~4.3", "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-mbstring": "~1.0", - "symfony/property-access": "~3.4|~4.0" + "symfony/property-access": "~3.4|~4.0", + "symfony/service-contracts": "~1.1" }, "require-dev": { "doctrine/collections": "~1.0", From 4f0ad25fabdda0b4a1f659d55acf3bd1e6abd5a1 Mon Sep 17 00:00:00 2001 From: Beno!t POLASZEK Date: Tue, 4 Jun 2019 15:59:49 +0200 Subject: [PATCH 36/59] Set default crypto method - Fix #31105 --- .../Component/Mailer/Transport/Smtp/Stream/SocketStream.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Symfony/Component/Mailer/Transport/Smtp/Stream/SocketStream.php b/src/Symfony/Component/Mailer/Transport/Smtp/Stream/SocketStream.php index 07692b11bac71..308201d538f0e 100644 --- a/src/Symfony/Component/Mailer/Transport/Smtp/Stream/SocketStream.php +++ b/src/Symfony/Component/Mailer/Transport/Smtp/Stream/SocketStream.php @@ -140,6 +140,9 @@ public function initialize(): void if ($this->streamContextOptions) { $options = array_merge($options, $this->streamContextOptions); } + if ($this->isTLS()) { + $options['ssl']['crypto_method'] = $options['ssl']['crypto_method'] ?? STREAM_CRYPTO_METHOD_TLS_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT; + } $streamContext = stream_context_create($options); $this->stream = @stream_socket_client($this->url, $errno, $errstr, $this->timeout, STREAM_CLIENT_CONNECT, $streamContext); if (false === $this->stream) { From e7c96d3b438f8b7f68786f5ef2dc46c4e15a2a12 Mon Sep 17 00:00:00 2001 From: Titouan Galopin Date: Tue, 4 Jun 2019 17:16:29 +0200 Subject: [PATCH 37/59] Rename the Symfony Mailer service config to avoid conflict with SwitMailer --- .../Bundle/FrameworkBundle/Resources/config/mailer.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/mailer.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/mailer.xml index 241c1ab00a4ff..d39899c0a9736 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/mailer.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/mailer.xml @@ -5,11 +5,12 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> - + - + + From 3cd56cb0181dca569c4405ad1a7e42747570ef3b Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 4 Jun 2019 17:54:17 +0200 Subject: [PATCH 38/59] [VarDumper] fix dumping the cloner itself --- src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php b/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php index 5582d24c3abac..aacab2c8853bf 100644 --- a/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php +++ b/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php @@ -84,6 +84,7 @@ abstract class AbstractCloner implements ClonerInterface 'Symfony\Component\VarDumper\Exception\ThrowingCasterException' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castThrowingCasterException'], 'Symfony\Component\VarDumper\Caster\TraceStub' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castTraceStub'], 'Symfony\Component\VarDumper\Caster\FrameStub' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castFrameStub'], + 'Symfony\Component\VarDumper\Cloner\AbstractCloner' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'], 'Symfony\Component\Debug\Exception\SilencedErrorContext' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castSilencedErrorContext'], 'ProxyManager\Proxy\ProxyInterface' => ['Symfony\Component\VarDumper\Caster\ProxyManagerCaster', 'castProxy'], @@ -188,10 +189,7 @@ public function __construct(array $casters = null) public function addCasters(array $casters) { foreach ($casters as $type => $callback) { - $closure = &$this->casters[$type][]; - $closure = $callback instanceof \Closure ? $callback : static function (...$args) use ($callback, &$closure) { - return ($closure = \Closure::fromCallable($callback))(...$args); - }; + $this->casters[$type][] = $callback; } } From e6e63017f07ef1830f1e9d3818120ed0a5593d32 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 4 Jun 2019 20:42:06 +0200 Subject: [PATCH 39/59] [HttpFoundation] work around PHP 7.3 bug related to json_encode() --- .../Console/Descriptor/JsonDescriptor.php | 6 ++++++ .../Component/Console/Descriptor/JsonDescriptor.php | 9 ++++++++- .../Component/Form/Console/Descriptor/JsonDescriptor.php | 6 ++++++ src/Symfony/Component/HttpFoundation/JsonResponse.php | 5 +++++ src/Symfony/Component/Serializer/Encoder/JsonEncode.php | 5 +++++ .../Component/Translation/Dumper/JsonFileDumper.php | 5 +++++ 6 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php index 6b05612ff53d9..2e00fc2262317 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php @@ -185,6 +185,12 @@ protected function describeContainerParameter($parameter, array $options = []) private function writeData(array $data, array $options) { $flags = isset($options['json_encoding']) ? $options['json_encoding'] : 0; + + if (\PHP_VERSION_ID >= 70300 && (JSON_THROW_ON_ERROR & $flags)) { + // Work around https://bugs.php.net/77997 + json_encode(null); + } + $this->write(json_encode($data, $flags | JSON_PRETTY_PRINT)."\n"); } diff --git a/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php index 197b843d4b76c..529fb82c4029f 100644 --- a/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php @@ -97,7 +97,14 @@ protected function describeApplication(Application $application, array $options */ private function writeData(array $data, array $options) { - $this->write(json_encode($data, isset($options['json_encoding']) ? $options['json_encoding'] : 0)); + $flags = isset($options['json_encoding']) ? $options['json_encoding'] : 0; + + if (\PHP_VERSION_ID >= 70300 && (JSON_THROW_ON_ERROR & $flags)) { + // Work around https://bugs.php.net/77997 + json_encode(null); + } + + $this->write(json_encode($data, $flags)); } /** diff --git a/src/Symfony/Component/Form/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Component/Form/Console/Descriptor/JsonDescriptor.php index ab518dbfeed12..00a5425866b29 100644 --- a/src/Symfony/Component/Form/Console/Descriptor/JsonDescriptor.php +++ b/src/Symfony/Component/Form/Console/Descriptor/JsonDescriptor.php @@ -82,6 +82,12 @@ protected function describeOption(OptionsResolver $optionsResolver, array $optio private function writeData(array $data, array $options) { $flags = isset($options['json_encoding']) ? $options['json_encoding'] : 0; + + if (\PHP_VERSION_ID >= 70300 && (JSON_THROW_ON_ERROR & $flags)) { + // Work around https://bugs.php.net/77997 + json_encode(null); + } + $this->output->write(json_encode($data, $flags | JSON_PRETTY_PRINT)."\n"); } diff --git a/src/Symfony/Component/HttpFoundation/JsonResponse.php b/src/Symfony/Component/HttpFoundation/JsonResponse.php index 6fb32ee41bdac..52f55f7486c97 100644 --- a/src/Symfony/Component/HttpFoundation/JsonResponse.php +++ b/src/Symfony/Component/HttpFoundation/JsonResponse.php @@ -153,6 +153,11 @@ public function setData($data = []) restore_error_handler(); } } else { + if (\PHP_VERSION_ID >= 70300 && (JSON_THROW_ON_ERROR & $this->encodingOptions)) { + // Work around https://bugs.php.net/77997 + json_encode(null); + } + try { $data = json_encode($data, $this->encodingOptions); } catch (\Exception $e) { diff --git a/src/Symfony/Component/Serializer/Encoder/JsonEncode.php b/src/Symfony/Component/Serializer/Encoder/JsonEncode.php index 9b07d709b8cff..e5b48757dd0c2 100644 --- a/src/Symfony/Component/Serializer/Encoder/JsonEncode.php +++ b/src/Symfony/Component/Serializer/Encoder/JsonEncode.php @@ -36,6 +36,11 @@ public function encode($data, $format, array $context = []) { $context = $this->resolveContext($context); + if (\PHP_VERSION_ID >= 70300 && (JSON_THROW_ON_ERROR & $context['json_encode_options'])) { + // Work around https://bugs.php.net/77997 + json_encode(null); + } + $encodedJson = json_encode($data, $context['json_encode_options']); if (JSON_ERROR_NONE !== json_last_error() && (false === $encodedJson || !($context['json_encode_options'] & JSON_PARTIAL_OUTPUT_ON_ERROR))) { diff --git a/src/Symfony/Component/Translation/Dumper/JsonFileDumper.php b/src/Symfony/Component/Translation/Dumper/JsonFileDumper.php index 3ee446dc73183..2a8d23d477e21 100644 --- a/src/Symfony/Component/Translation/Dumper/JsonFileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/JsonFileDumper.php @@ -31,6 +31,11 @@ public function formatCatalogue(MessageCatalogue $messages, $domain, array $opti $flags = \defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0; } + if (\PHP_VERSION_ID >= 70300 && (JSON_THROW_ON_ERROR & $flags)) { + // Work around https://bugs.php.net/77997 + json_encode(null); + } + return json_encode($messages->all($domain), $flags); } From 42904e34e6b62c56a3c4cdcf1002ac9c900896fc Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 4 Jun 2019 20:58:48 +0200 Subject: [PATCH 40/59] [HttpClient] work around PHP 7.3 bug related to json_encode() --- src/Symfony/Component/HttpClient/HttpClientTrait.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpClient/HttpClientTrait.php b/src/Symfony/Component/HttpClient/HttpClientTrait.php index 0023e3bbb0f5e..bea095134edf9 100644 --- a/src/Symfony/Component/HttpClient/HttpClientTrait.php +++ b/src/Symfony/Component/HttpClient/HttpClientTrait.php @@ -301,7 +301,13 @@ private static function jsonEncode($value, int $flags = null, int $maxDepth = 51 } try { - $value = json_encode($value, $flags | (\PHP_VERSION_ID >= 70300 ? JSON_THROW_ON_ERROR : 0), $maxDepth); + if (\PHP_VERSION_ID >= 70300) { + // Work around https://bugs.php.net/77997 + json_encode(null); + $flags |= JSON_THROW_ON_ERROR; + } + + $value = json_encode($value, $flags, $maxDepth); } catch (\JsonException $e) { throw new InvalidArgumentException(sprintf('Invalid value for "json" option: %s.', $e->getMessage())); } From 14b27b7d0255278b0c58df2cfc5b5c0b7629768a Mon Sep 17 00:00:00 2001 From: Franco Traversaro Date: Tue, 4 Jun 2019 13:10:58 +0200 Subject: [PATCH 41/59] [Console] Add check for Konsole/Yakuake to disable hyperlinks --- .../Component/Console/Formatter/OutputFormatterStyle.php | 2 +- src/Symfony/Component/VarDumper/Dumper/CliDumper.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Console/Formatter/OutputFormatterStyle.php b/src/Symfony/Component/Console/Formatter/OutputFormatterStyle.php index 6a181f8ff6751..655bdd083e50e 100644 --- a/src/Symfony/Component/Console/Formatter/OutputFormatterStyle.php +++ b/src/Symfony/Component/Console/Formatter/OutputFormatterStyle.php @@ -187,7 +187,7 @@ public function apply($text) $unsetCodes = []; if (null === $this->handlesHrefGracefully) { - $this->handlesHrefGracefully = 'JetBrains-JediTerm' !== getenv('TERMINAL_EMULATOR'); + $this->handlesHrefGracefully = 'JetBrains-JediTerm' !== getenv('TERMINAL_EMULATOR') && !getenv('KONSOLE_VERSION'); } if (null !== $this->foreground) { diff --git a/src/Symfony/Component/VarDumper/Dumper/CliDumper.php b/src/Symfony/Component/VarDumper/Dumper/CliDumper.php index 3ca3e33587c41..9b258f4505266 100644 --- a/src/Symfony/Component/VarDumper/Dumper/CliDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/CliDumper.php @@ -435,7 +435,7 @@ protected function style($style, $value, $attr = []) } if (null === $this->handlesHrefGracefully) { - $this->handlesHrefGracefully = 'JetBrains-JediTerm' !== getenv('TERMINAL_EMULATOR'); + $this->handlesHrefGracefully = 'JetBrains-JediTerm' !== getenv('TERMINAL_EMULATOR') && !getenv('KONSOLE_VERSION'); } if (isset($attr['ellipsis'], $attr['ellipsis-type'])) { From b5e6c99a3b1aa46ffeb859111e5b0fde4678bde4 Mon Sep 17 00:00:00 2001 From: Ivo Date: Wed, 5 Jun 2019 10:24:41 +0200 Subject: [PATCH 42/59] [HttpFoundation] Fixed case-sensitive handling of cache-control header in RedirectResponse constructor. --- src/Symfony/Component/HttpFoundation/RedirectResponse.php | 2 +- .../Component/HttpFoundation/Tests/RedirectResponseTest.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpFoundation/RedirectResponse.php b/src/Symfony/Component/HttpFoundation/RedirectResponse.php index 5e1dfe58507fb..51fd869abea25 100644 --- a/src/Symfony/Component/HttpFoundation/RedirectResponse.php +++ b/src/Symfony/Component/HttpFoundation/RedirectResponse.php @@ -42,7 +42,7 @@ public function __construct($url, $status = 302, $headers = []) throw new \InvalidArgumentException(sprintf('The HTTP status code is not a redirect ("%s" given).', $status)); } - if (301 == $status && !\array_key_exists('cache-control', $headers)) { + if (301 == $status && !\array_key_exists('cache-control', array_change_key_case($headers, \CASE_LOWER))) { $this->headers->remove('cache-control'); } } diff --git a/src/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php index 64c3e73ee21af..5f6a8ac0883f4 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php @@ -91,6 +91,10 @@ public function testCacheHeaders() $this->assertFalse($response->headers->hasCacheControlDirective('no-cache')); $this->assertTrue($response->headers->hasCacheControlDirective('max-age')); + $response = new RedirectResponse('foo.bar', 301, ['Cache-Control' => 'max-age=86400']); + $this->assertFalse($response->headers->hasCacheControlDirective('no-cache')); + $this->assertTrue($response->headers->hasCacheControlDirective('max-age')); + $response = new RedirectResponse('foo.bar', 302); $this->assertTrue($response->headers->hasCacheControlDirective('no-cache')); } From d32a29527b582ad88b5c24f38c1680100ace4546 Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Wed, 5 Jun 2019 11:11:58 +0200 Subject: [PATCH 43/59] [Routing] revert deprecation of Serializable in routing we still need to implement Serializable as long as we support PHP < 7.4. otherwise serialized data in php 7.2 would not work anymore when people upgrade to php 7.4 --- UPGRADE-4.3.md | 5 +++-- UPGRADE-5.0.md | 5 +++-- src/Symfony/Component/Routing/CHANGELOG.md | 5 +++-- src/Symfony/Component/Routing/CompiledRoute.php | 6 ++++-- src/Symfony/Component/Routing/Route.php | 6 ++++-- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/UPGRADE-4.3.md b/UPGRADE-4.3.md index a2ea3f28710e8..531a8e61b99b6 100644 --- a/UPGRADE-4.3.md +++ b/UPGRADE-4.3.md @@ -121,8 +121,9 @@ Routing * The `generator_base_class`, `generator_cache_class`, `matcher_base_class`, and `matcher_cache_class` router options have been deprecated. - * Implementing `Serializable` for `Route` and `CompiledRoute` is deprecated; if you serialize them, please - ensure your unserialization logic can recover from a failure related to an updated serialization format + * `Serializable` implementing methods for `Route` and `CompiledRoute` are marked as `@internal` and `@final`. + Instead of overwriting them, use `__serialize` and `__unserialize` as extension points which are forward compatible + with the new serialization methods in PHP 7.4. Security -------- diff --git a/UPGRADE-5.0.md b/UPGRADE-5.0.md index 6f71eb546c8a7..c2abf4f8b7fd7 100644 --- a/UPGRADE-5.0.md +++ b/UPGRADE-5.0.md @@ -282,8 +282,9 @@ Routing * The `generator_base_class`, `generator_cache_class`, `matcher_base_class`, and `matcher_cache_class` router options have been removed. - * `Route` and `CompiledRoute` don't implement `Serializable` anymore; if you serialize them, please - ensure your unserialization logic can recover from a failure related to an updated serialization format + * `Serializable` implementing methods for `Route` and `CompiledRoute` are final. + Instead of overwriting them, use `__serialize` and `__unserialize` as extension points which are forward compatible + with the new serialization methods in PHP 7.4. Security -------- diff --git a/src/Symfony/Component/Routing/CHANGELOG.md b/src/Symfony/Component/Routing/CHANGELOG.md index f7439903e04a5..05ae44b5f110c 100644 --- a/src/Symfony/Component/Routing/CHANGELOG.md +++ b/src/Symfony/Component/Routing/CHANGELOG.md @@ -8,8 +8,9 @@ CHANGELOG * added `CompiledUrlGenerator` and `CompiledUrlGeneratorDumper` * deprecated `PhpGeneratorDumper` and `PhpMatcherDumper` * deprecated `generator_base_class`, `generator_cache_class`, `matcher_base_class` and `matcher_cache_class` router options - * deprecated implementing `Serializable` for `Route` and `CompiledRoute`; if you serialize them, please - ensure your unserialization logic can recover from a failure related to an updated serialization format + * `Serializable` implementing methods for `Route` and `CompiledRoute` are marked as `@internal` and `@final`. + Instead of overwriting them, use `__serialize` and `__unserialize` as extension points which are forward compatible + with the new serialization methods in PHP 7.4. * exposed `utf8` Route option, defaults "locale" and "format" in configuration loaders and configurators * added support for invokable route loader services diff --git a/src/Symfony/Component/Routing/CompiledRoute.php b/src/Symfony/Component/Routing/CompiledRoute.php index 06dc87d74015c..87278e702a899 100644 --- a/src/Symfony/Component/Routing/CompiledRoute.php +++ b/src/Symfony/Component/Routing/CompiledRoute.php @@ -64,7 +64,8 @@ public function __serialize(): array } /** - * @internal since Symfony 4.3, will be removed in Symfony 5 as the class won't implement Serializable anymore + * @internal since Symfony 4.3 + * @final since Symfony 4.3 */ public function serialize() { @@ -84,7 +85,8 @@ public function __unserialize(array $data): void } /** - * @internal since Symfony 4.3, will be removed in Symfony 5 as the class won't implement Serializable anymore + * @internal since Symfony 4.3 + * @final since Symfony 4.3 */ public function unserialize($serialized) { diff --git a/src/Symfony/Component/Routing/Route.php b/src/Symfony/Component/Routing/Route.php index 178c5d3ac213b..90d8e617c4e97 100644 --- a/src/Symfony/Component/Routing/Route.php +++ b/src/Symfony/Component/Routing/Route.php @@ -78,7 +78,8 @@ public function __serialize(): array } /** - * @internal since Symfony 4.3, will be removed in Symfony 5 as the class won't implement Serializable anymore + * @internal since Symfony 4.3 + * @final since Symfony 4.3 */ public function serialize() { @@ -104,7 +105,8 @@ public function __unserialize(array $data): void } /** - * @internal since Symfony 4.3, will be removed in Symfony 5 as the class won't implement Serializable anymore + * @internal since Symfony 4.3 + * @final since Symfony 4.3 */ public function unserialize($serialized) { From d18f42c409b49771a5b8bb9c02de6a404e3260d1 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 5 Jun 2019 13:22:47 +0200 Subject: [PATCH 44/59] Fix json-encoding when JSON_THROW_ON_ERROR is used --- .../Console/Descriptor/JsonDescriptor.php | 5 ----- .../Component/Console/Descriptor/JsonDescriptor.php | 5 ----- .../Form/Console/Descriptor/JsonDescriptor.php | 5 ----- src/Symfony/Component/HttpFoundation/JsonResponse.php | 9 ++++----- .../Component/Serializer/Encoder/JsonDecode.php | 10 +++++++++- .../Component/Serializer/Encoder/JsonEncode.php | 7 +++---- .../Component/Translation/Dumper/JsonFileDumper.php | 5 ----- 7 files changed, 16 insertions(+), 30 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php index 2e00fc2262317..c18d278688193 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php @@ -186,11 +186,6 @@ private function writeData(array $data, array $options) { $flags = isset($options['json_encoding']) ? $options['json_encoding'] : 0; - if (\PHP_VERSION_ID >= 70300 && (JSON_THROW_ON_ERROR & $flags)) { - // Work around https://bugs.php.net/77997 - json_encode(null); - } - $this->write(json_encode($data, $flags | JSON_PRETTY_PRINT)."\n"); } diff --git a/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php index 529fb82c4029f..f5a143800b27c 100644 --- a/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php @@ -99,11 +99,6 @@ private function writeData(array $data, array $options) { $flags = isset($options['json_encoding']) ? $options['json_encoding'] : 0; - if (\PHP_VERSION_ID >= 70300 && (JSON_THROW_ON_ERROR & $flags)) { - // Work around https://bugs.php.net/77997 - json_encode(null); - } - $this->write(json_encode($data, $flags)); } diff --git a/src/Symfony/Component/Form/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Component/Form/Console/Descriptor/JsonDescriptor.php index 00a5425866b29..428586965ba64 100644 --- a/src/Symfony/Component/Form/Console/Descriptor/JsonDescriptor.php +++ b/src/Symfony/Component/Form/Console/Descriptor/JsonDescriptor.php @@ -83,11 +83,6 @@ private function writeData(array $data, array $options) { $flags = isset($options['json_encoding']) ? $options['json_encoding'] : 0; - if (\PHP_VERSION_ID >= 70300 && (JSON_THROW_ON_ERROR & $flags)) { - // Work around https://bugs.php.net/77997 - json_encode(null); - } - $this->output->write(json_encode($data, $flags | JSON_PRETTY_PRINT)."\n"); } diff --git a/src/Symfony/Component/HttpFoundation/JsonResponse.php b/src/Symfony/Component/HttpFoundation/JsonResponse.php index 52f55f7486c97..24798eea42b32 100644 --- a/src/Symfony/Component/HttpFoundation/JsonResponse.php +++ b/src/Symfony/Component/HttpFoundation/JsonResponse.php @@ -153,11 +153,6 @@ public function setData($data = []) restore_error_handler(); } } else { - if (\PHP_VERSION_ID >= 70300 && (JSON_THROW_ON_ERROR & $this->encodingOptions)) { - // Work around https://bugs.php.net/77997 - json_encode(null); - } - try { $data = json_encode($data, $this->encodingOptions); } catch (\Exception $e) { @@ -166,6 +161,10 @@ public function setData($data = []) } throw $e; } + + if (\PHP_VERSION_ID >= 70300 && (JSON_THROW_ON_ERROR & $this->encodingOptions)) { + return $this->setJson($data); + } } } diff --git a/src/Symfony/Component/Serializer/Encoder/JsonDecode.php b/src/Symfony/Component/Serializer/Encoder/JsonDecode.php index 1d0b86afc5d07..a55f1232e7e98 100644 --- a/src/Symfony/Component/Serializer/Encoder/JsonDecode.php +++ b/src/Symfony/Component/Serializer/Encoder/JsonDecode.php @@ -72,7 +72,15 @@ public function decode($data, $format, array $context = []) $recursionDepth = $context['json_decode_recursion_depth']; $options = $context['json_decode_options']; - $decodedData = json_decode($data, $associative, $recursionDepth, $options); + try { + $decodedData = json_decode($data, $associative, $recursionDepth, $options); + } catch (\JsonException $e) { + throw new NotEncodableValueException($e->getMessage(), 0, $e); + } + + if (\PHP_VERSION_ID >= 70300 && (JSON_THROW_ON_ERROR & $options)) { + return $decodedData; + } if (JSON_ERROR_NONE !== json_last_error()) { throw new NotEncodableValueException(json_last_error_msg()); diff --git a/src/Symfony/Component/Serializer/Encoder/JsonEncode.php b/src/Symfony/Component/Serializer/Encoder/JsonEncode.php index e5b48757dd0c2..76e532c4b7a34 100644 --- a/src/Symfony/Component/Serializer/Encoder/JsonEncode.php +++ b/src/Symfony/Component/Serializer/Encoder/JsonEncode.php @@ -36,13 +36,12 @@ public function encode($data, $format, array $context = []) { $context = $this->resolveContext($context); + $encodedJson = json_encode($data, $context['json_encode_options']); + if (\PHP_VERSION_ID >= 70300 && (JSON_THROW_ON_ERROR & $context['json_encode_options'])) { - // Work around https://bugs.php.net/77997 - json_encode(null); + return $encodedJson; } - $encodedJson = json_encode($data, $context['json_encode_options']); - if (JSON_ERROR_NONE !== json_last_error() && (false === $encodedJson || !($context['json_encode_options'] & JSON_PARTIAL_OUTPUT_ON_ERROR))) { throw new NotEncodableValueException(json_last_error_msg()); } diff --git a/src/Symfony/Component/Translation/Dumper/JsonFileDumper.php b/src/Symfony/Component/Translation/Dumper/JsonFileDumper.php index 2a8d23d477e21..3ee446dc73183 100644 --- a/src/Symfony/Component/Translation/Dumper/JsonFileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/JsonFileDumper.php @@ -31,11 +31,6 @@ public function formatCatalogue(MessageCatalogue $messages, $domain, array $opti $flags = \defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0; } - if (\PHP_VERSION_ID >= 70300 && (JSON_THROW_ON_ERROR & $flags)) { - // Work around https://bugs.php.net/77997 - json_encode(null); - } - return json_encode($messages->all($domain), $flags); } From a1619ccb955965c47b659151d245c6c4ba5be507 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 5 Jun 2019 11:38:47 +0200 Subject: [PATCH 45/59] [HttpKernel] Fix handling non-catchable fatal errors This reverts PR #27519 this commit 18c2dde08e52714666ff3a06ff9aa604fa80bfb0, reversing changes made to ac1189a61e74b83be17787473d1aa9ceabd050c9. --- .../FrameworkExtension.php | 3 -- .../Resources/config/debug_prod.xml | 5 +-- .../FrameworkBundle/Resources/config/web.xml | 10 ------ .../EventListener/DebugHandlersListener.php | 29 +++++++++++++++- .../EventListener/ExceptionListener.php | 33 +++---------------- .../DebugHandlersListenerTest.php | 1 + .../EventListener/ExceptionListenerTest.php | 19 ----------- 7 files changed, 37 insertions(+), 63 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 755566f45bdfa..4688c192a05cb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -721,9 +721,6 @@ private function registerDebugConfiguration(array $config, ContainerBuilder $con $container->setParameter('debug.error_handler.throw_at', 0); } - $definition->replaceArgument(4, $debug); - $definition->replaceArgument(6, $debug); - if ($debug && class_exists(DebugProcessor::class)) { $definition = new Definition(DebugProcessor::class); $definition->setPublic(false); diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug_prod.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug_prod.xml index 6810eadabe0e3..e19d453d36acf 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug_prod.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug_prod.xml @@ -18,9 +18,10 @@ null %debug.error_handler.throw_at% - true + %kernel.debug% - true + %kernel.debug% + %kernel.charset% diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/web.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/web.xml index 41c682c2111c7..fb797ff96b9e2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/web.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/web.xml @@ -67,16 +67,6 @@ - - - - null - null - %kernel.debug% - %kernel.charset% - %debug.file_link_format% - - diff --git a/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php b/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php index 6659e21793ffc..b28ad7b83e5e4 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php @@ -19,7 +19,10 @@ use Symfony\Component\Debug\ExceptionHandler; use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Debug\FileLinkFormatter; +use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; use Symfony\Component\HttpKernel\Event\KernelEvent; use Symfony\Component\HttpKernel\KernelEvents; @@ -37,6 +40,7 @@ class DebugHandlersListener implements EventSubscriberInterface private $scream; private $fileLinkFormat; private $scope; + private $charset; private $firstCall = true; private $hasTerminatedWithException; @@ -49,7 +53,7 @@ class DebugHandlersListener implements EventSubscriberInterface * @param string|FileLinkFormatter|null $fileLinkFormat The format for links to source files * @param bool $scope Enables/disables scoping mode */ - public function __construct(callable $exceptionHandler = null, LoggerInterface $logger = null, $levels = E_ALL, ?int $throwAt = E_ALL, bool $scream = true, $fileLinkFormat = null, bool $scope = true) + public function __construct(callable $exceptionHandler = null, LoggerInterface $logger = null, $levels = E_ALL, ?int $throwAt = E_ALL, bool $scream = true, $fileLinkFormat = null, bool $scope = true, string $charset = null) { $this->exceptionHandler = $exceptionHandler; $this->logger = $logger; @@ -58,6 +62,7 @@ public function __construct(callable $exceptionHandler = null, LoggerInterface $ $this->scream = $scream; $this->fileLinkFormat = $fileLinkFormat; $this->scope = $scope; + $this->charset = $charset; } /** @@ -144,6 +149,26 @@ public function configure(Event $event = null) } } + /** + * @internal + */ + public function onKernelException(GetResponseForExceptionEvent $event) + { + if (!$this->hasTerminatedWithException || !$event->isMasterRequest()) { + return; + } + + $debug = $this->scream && $this->scope; + $controller = function (Request $request) use ($debug) { + $e = $request->attributes->get('exception'); + $handler = new ExceptionHandler($debug, $this->charset, $this->fileLinkFormat); + + return new Response($handler->getHtml($e), $e->getStatusCode(), $e->getHeaders()); + }; + + (new ExceptionListener($controller, $this->logger, $debug))->onKernelException($event); + } + public static function getSubscribedEvents() { $events = [KernelEvents::REQUEST => ['configure', 2048]]; @@ -152,6 +177,8 @@ public static function getSubscribedEvents() $events[ConsoleEvents::COMMAND] = ['configure', 2048]; } + $events[KernelEvents::EXCEPTION] = ['onKernelException', -2048]; + return $events; } } diff --git a/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php b/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php index 811f99bd9de8f..d2b97e66276fe 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php @@ -13,11 +13,9 @@ use Psr\Log\LoggerInterface; use Symfony\Component\Debug\Exception\FlattenException; -use Symfony\Component\Debug\ExceptionHandler; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; @@ -35,17 +33,12 @@ class ExceptionListener implements EventSubscriberInterface protected $controller; protected $logger; protected $debug; - private $charset; - private $fileLinkFormat; - private $isTerminating = false; - public function __construct($controller, LoggerInterface $logger = null, $debug = false, string $charset = null, $fileLinkFormat = null) + public function __construct($controller, LoggerInterface $logger = null, $debug = false) { $this->controller = $controller; $this->logger = $logger; $this->debug = $debug; - $this->charset = $charset; - $this->fileLinkFormat = $fileLinkFormat; } public function logKernelException(GetResponseForExceptionEvent $event) @@ -58,16 +51,9 @@ public function logKernelException(GetResponseForExceptionEvent $event) public function onKernelException(GetResponseForExceptionEvent $event) { if (null === $this->controller) { - if (!$event->isMasterRequest()) { - return; - } - if (!$this->isTerminating) { - $this->isTerminating = true; - - return; - } - $this->isTerminating = false; + return; } + $exception = $event->getException(); $request = $this->duplicateRequest($exception, $event->getRequest()); $eventDispatcher = \func_num_args() > 2 ? func_get_arg(2) : null; @@ -104,11 +90,6 @@ public function onKernelException(GetResponseForExceptionEvent $event) } } - public function reset() - { - $this->isTerminating = false; - } - public static function getSubscribedEvents() { return [ @@ -147,12 +128,8 @@ protected function logException(\Exception $exception, $message) protected function duplicateRequest(\Exception $exception, Request $request) { $attributes = [ - 'exception' => $exception = FlattenException::create($exception), - '_controller' => $this->controller ?: function () use ($exception) { - $handler = new ExceptionHandler($this->debug, $this->charset, $this->fileLinkFormat); - - return new Response($handler->getHtml($exception), $exception->getStatusCode(), $exception->getHeaders()); - }, + '_controller' => $this->controller, + 'exception' => FlattenException::create($exception), 'logger' => $this->logger instanceof DebugLoggerInterface ? $this->logger : null, ]; $request = $request->duplicate(null, null, $attributes); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php index 44af0149f738f..d7077cb7e5036 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php @@ -104,6 +104,7 @@ public function testConsoleEvent() $xListeners = [ KernelEvents::REQUEST => [[$listener, 'configure']], ConsoleEvents::COMMAND => [[$listener, 'configure']], + KernelEvents::EXCEPTION => [[$listener, 'onKernelException']], ]; $this->assertSame($xListeners, $dispatcher->getListeners()); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php index 61231eb68b677..bc5a8c77c8f7f 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php @@ -155,25 +155,6 @@ public function testCSPHeaderIsRemoved() $this->assertFalse($response->headers->has('content-security-policy'), 'CSP header has been removed'); $this->assertFalse($dispatcher->hasListeners(KernelEvents::RESPONSE), 'CSP removal listener has been removed'); } - - public function testNullController() - { - $listener = new ExceptionListener(null); - $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); - $kernel->expects($this->once())->method('handle')->willReturnCallback(function (Request $request) { - $controller = $request->attributes->get('_controller'); - - return $controller(); - }); - $request = Request::create('/'); - $event = new GetResponseForExceptionEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, new \Exception('foo')); - - $listener->onKernelException($event); - $this->assertNull($event->getResponse()); - - $listener->onKernelException($event); - $this->assertContains('Whoops, looks like something went wrong.', $event->getResponse()->getContent()); - } } class TestLogger extends Logger implements DebugLoggerInterface From 846116edab4dd510441e69c5218b7bdc8cdac89f Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 5 Jun 2019 13:58:47 +0200 Subject: [PATCH 46/59] [HttpClient] revert bad logic around JSON_THROW_ON_ERROR --- src/Symfony/Component/HttpClient/HttpClientTrait.php | 8 +------- .../Component/HttpClient/Response/ResponseTrait.php | 2 +- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Component/HttpClient/HttpClientTrait.php b/src/Symfony/Component/HttpClient/HttpClientTrait.php index bea095134edf9..2df830e111304 100644 --- a/src/Symfony/Component/HttpClient/HttpClientTrait.php +++ b/src/Symfony/Component/HttpClient/HttpClientTrait.php @@ -301,13 +301,7 @@ private static function jsonEncode($value, int $flags = null, int $maxDepth = 51 } try { - if (\PHP_VERSION_ID >= 70300) { - // Work around https://bugs.php.net/77997 - json_encode(null); - $flags |= JSON_THROW_ON_ERROR; - } - - $value = json_encode($value, $flags, $maxDepth); + $value = json_encode($value, $flags | (\PHP_VERSION_ID >= 70300 ? \JSON_THROW_ON_ERROR : 0), $maxDepth); } catch (\JsonException $e) { throw new InvalidArgumentException(sprintf('Invalid value for "json" option: %s.', $e->getMessage())); } diff --git a/src/Symfony/Component/HttpClient/Response/ResponseTrait.php b/src/Symfony/Component/HttpClient/Response/ResponseTrait.php index 79cc40d5d847f..6b62b855360ee 100644 --- a/src/Symfony/Component/HttpClient/Response/ResponseTrait.php +++ b/src/Symfony/Component/HttpClient/Response/ResponseTrait.php @@ -148,7 +148,7 @@ public function toArray(bool $throw = true): array } try { - $content = json_decode($content, true, 512, JSON_BIGINT_AS_STRING | (\PHP_VERSION_ID >= 70300 ? JSON_THROW_ON_ERROR : 0)); + $content = json_decode($content, true, 512, JSON_BIGINT_AS_STRING | (\PHP_VERSION_ID >= 70300 ? \JSON_THROW_ON_ERROR : 0)); } catch (\JsonException $e) { throw new JsonException($e->getMessage(), $e->getCode()); } From 07603da06c609084c791674da9458af9c5443d57 Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Wed, 5 Jun 2019 15:18:16 +0200 Subject: [PATCH 47/59] [Messenger] Add runtime check for ext redis version --- .../Component/Messenger/Transport/RedisExt/Connection.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Symfony/Component/Messenger/Transport/RedisExt/Connection.php b/src/Symfony/Component/Messenger/Transport/RedisExt/Connection.php index 5757f0be7f623..7688503264d55 100644 --- a/src/Symfony/Component/Messenger/Transport/RedisExt/Connection.php +++ b/src/Symfony/Component/Messenger/Transport/RedisExt/Connection.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Messenger\Transport\RedisExt; use Symfony\Component\Messenger\Exception\InvalidArgumentException; +use Symfony\Component\Messenger\Exception\LogicException; use Symfony\Component\Messenger\Exception\TransportException; /** @@ -43,6 +44,10 @@ class Connection public function __construct(array $configuration, array $connectionCredentials = [], array $redisOptions = [], \Redis $redis = null) { + if (version_compare(phpversion('redis'), '4.3.0', '<')) { + throw new LogicException('The redis transport requires php-redis 4.3.0 or higher.'); + } + $this->connection = $redis ?: new \Redis(); $this->connection->connect($connectionCredentials['host'] ?? '127.0.0.1', $connectionCredentials['port'] ?? 6379); $this->connection->setOption(\Redis::OPT_SERIALIZER, $redisOptions['serializer'] ?? \Redis::SERIALIZER_PHP); From 856892349174146b1eda115fed627d7e4f1881d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacek=20J=C4=99drzejewski?= Date: Wed, 5 Jun 2019 10:23:19 +0200 Subject: [PATCH 48/59] [Cache] Fixed undefined variable in ArrayTrait --- src/Symfony/Component/Cache/Traits/ArrayTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Cache/Traits/ArrayTrait.php b/src/Symfony/Component/Cache/Traits/ArrayTrait.php index 8ae9cad59b1ae..d29b528b96c39 100644 --- a/src/Symfony/Component/Cache/Traits/ArrayTrait.php +++ b/src/Symfony/Component/Cache/Traits/ArrayTrait.php @@ -129,7 +129,7 @@ private function freeze($value, $key) } catch (\Exception $e) { $type = \is_object($value) ? \get_class($value) : \gettype($value); $message = sprintf('Failed to save key "{key}" of type %s: %s', $type, $e->getMessage()); - CacheItem::log($this->logger, $message, ['key' => substr($id, \strlen($this->namespace)), 'exception' => $e]); + CacheItem::log($this->logger, $message, ['key' => $key, 'exception' => $e]); return; } From fd17ff005de2c9ef17a0d7667e81cd177eb00db6 Mon Sep 17 00:00:00 2001 From: Julien Manganne Date: Wed, 5 Jun 2019 17:56:22 +0200 Subject: [PATCH 49/59] Add a missing quote in getValue() DocBlock --- .../Component/PropertyAccess/PropertyAccessorInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/PropertyAccess/PropertyAccessorInterface.php b/src/Symfony/Component/PropertyAccess/PropertyAccessorInterface.php index 51fa0cc76f7db..aa81bfc42d983 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyAccessorInterface.php +++ b/src/Symfony/Component/PropertyAccess/PropertyAccessorInterface.php @@ -58,7 +58,7 @@ public function setValue(&$objectOrArray, $propertyPath, $value); * * $propertyAccessor = PropertyAccess::createPropertyAccessor(); * - * echo $propertyAccessor->getValue($object, 'child.name); + * echo $propertyAccessor->getValue($object, 'child.name'); * // equals echo $object->getChild()->getName(); * * This method first tries to find a public getter for each property in the From 1a4c2548d5fd8fa0e8b0266a8fbe0e7063da75bb Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 5 Jun 2019 18:17:19 +0200 Subject: [PATCH 50/59] [FramworkBundle][HttpKernel] fix KernelBrowser BC layer --- src/Symfony/Bundle/FrameworkBundle/Client.php | 192 +++++++++++++++++- .../Bundle/FrameworkBundle/KernelBrowser.php | 187 +---------------- src/Symfony/Component/HttpKernel/Client.php | 187 ++++++++++++++++- .../HttpKernel/HttpKernelBrowser.php | 182 +---------------- 4 files changed, 377 insertions(+), 371 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Client.php b/src/Symfony/Bundle/FrameworkBundle/Client.php index e36f0cac68607..f33808db04f6a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Client.php +++ b/src/Symfony/Bundle/FrameworkBundle/Client.php @@ -11,8 +11,196 @@ namespace Symfony\Bundle\FrameworkBundle; -@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.3, use "%s" instead.', Client::class, KernelBrowser::class), E_USER_DEPRECATED); +use Symfony\Component\BrowserKit\CookieJar; +use Symfony\Component\BrowserKit\History; +use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\HttpKernelBrowser; +use Symfony\Component\HttpKernel\KernelInterface; +use Symfony\Component\HttpKernel\Profiler\Profile as HttpProfile; -class Client extends KernelBrowser +/** + * Client simulates a browser and makes requests to a Kernel object. + * + * @deprecated since Symfony 4.3, use KernelBrowser instead. + */ +class Client extends HttpKernelBrowser { + private $hasPerformedRequest = false; + private $profiler = false; + private $reboot = true; + + /** + * {@inheritdoc} + */ + public function __construct(KernelInterface $kernel, array $server = [], History $history = null, CookieJar $cookieJar = null) + { + parent::__construct($kernel, $server, $history, $cookieJar); + } + + /** + * Returns the container. + * + * @return ContainerInterface|null Returns null when the Kernel has been shutdown or not started yet + */ + public function getContainer() + { + return $this->kernel->getContainer(); + } + + /** + * Returns the kernel. + * + * @return KernelInterface + */ + public function getKernel() + { + return $this->kernel; + } + + /** + * Gets the profile associated with the current Response. + * + * @return HttpProfile|false A Profile instance + */ + public function getProfile() + { + if (!$this->kernel->getContainer()->has('profiler')) { + return false; + } + + return $this->kernel->getContainer()->get('profiler')->loadProfileFromResponse($this->response); + } + + /** + * Enables the profiler for the very next request. + * + * If the profiler is not enabled, the call to this method does nothing. + */ + public function enableProfiler() + { + if ($this->kernel->getContainer()->has('profiler')) { + $this->profiler = true; + } + } + + /** + * Disables kernel reboot between requests. + * + * By default, the Client reboots the Kernel for each request. This method + * allows to keep the same kernel across requests. + */ + public function disableReboot() + { + $this->reboot = false; + } + + /** + * Enables kernel reboot between requests. + */ + public function enableReboot() + { + $this->reboot = true; + } + + /** + * {@inheritdoc} + * + * @param Request $request A Request instance + * + * @return Response A Response instance + */ + protected function doRequest($request) + { + // avoid shutting down the Kernel if no request has been performed yet + // WebTestCase::createClient() boots the Kernel but do not handle a request + if ($this->hasPerformedRequest && $this->reboot) { + $this->kernel->shutdown(); + } else { + $this->hasPerformedRequest = true; + } + + if ($this->profiler) { + $this->profiler = false; + + $this->kernel->boot(); + $this->kernel->getContainer()->get('profiler')->enable(); + } + + return parent::doRequest($request); + } + + /** + * {@inheritdoc} + * + * @param Request $request A Request instance + * + * @return Response A Response instance + */ + protected function doRequestInProcess($request) + { + $response = parent::doRequestInProcess($request); + + $this->profiler = false; + + return $response; + } + + /** + * Returns the script to execute when the request must be insulated. + * + * It assumes that the autoloader is named 'autoload.php' and that it is + * stored in the same directory as the kernel (this is the case for the + * Symfony Standard Edition). If this is not your case, create your own + * client and override this method. + * + * @param Request $request A Request instance + * + * @return string The script content + */ + protected function getScript($request) + { + $kernel = var_export(serialize($this->kernel), true); + $request = var_export(serialize($request), true); + $errorReporting = error_reporting(); + + $requires = ''; + foreach (get_declared_classes() as $class) { + if (0 === strpos($class, 'ComposerAutoloaderInit')) { + $r = new \ReflectionClass($class); + $file = \dirname(\dirname($r->getFileName())).'/autoload.php'; + if (file_exists($file)) { + $requires .= 'require_once '.var_export($file, true).";\n"; + } + } + } + + if (!$requires) { + throw new \RuntimeException('Composer autoloader not found.'); + } + + $requires .= 'require_once '.var_export((new \ReflectionObject($this->kernel))->getFileName(), true).";\n"; + + $profilerCode = ''; + if ($this->profiler) { + $profilerCode = '$kernel->getContainer()->get(\'profiler\')->enable();'; + } + + $code = <<boot(); +$profilerCode + +\$request = unserialize($request); +EOF; + + return $code.$this->getHandleScript(); + } } diff --git a/src/Symfony/Bundle/FrameworkBundle/KernelBrowser.php b/src/Symfony/Bundle/FrameworkBundle/KernelBrowser.php index b86c1b5c34643..b05b60def12d1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/KernelBrowser.php +++ b/src/Symfony/Bundle/FrameworkBundle/KernelBrowser.php @@ -11,196 +11,11 @@ namespace Symfony\Bundle\FrameworkBundle; -use Symfony\Component\BrowserKit\CookieJar; -use Symfony\Component\BrowserKit\History; -use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\HttpKernelBrowser; -use Symfony\Component\HttpKernel\KernelInterface; -use Symfony\Component\HttpKernel\Profiler\Profile as HttpProfile; - /** * Client simulates a browser and makes requests to a Kernel object. * * @author Fabien Potencier */ -class KernelBrowser extends HttpKernelBrowser +class KernelBrowser extends Client { - private $hasPerformedRequest = false; - private $profiler = false; - private $reboot = true; - - /** - * {@inheritdoc} - */ - public function __construct(KernelInterface $kernel, array $server = [], History $history = null, CookieJar $cookieJar = null) - { - parent::__construct($kernel, $server, $history, $cookieJar); - } - - /** - * Returns the container. - * - * @return ContainerInterface|null Returns null when the Kernel has been shutdown or not started yet - */ - public function getContainer() - { - return $this->kernel->getContainer(); - } - - /** - * Returns the kernel. - * - * @return KernelInterface - */ - public function getKernel() - { - return $this->kernel; - } - - /** - * Gets the profile associated with the current Response. - * - * @return HttpProfile|false A Profile instance - */ - public function getProfile() - { - if (!$this->kernel->getContainer()->has('profiler')) { - return false; - } - - return $this->kernel->getContainer()->get('profiler')->loadProfileFromResponse($this->response); - } - - /** - * Enables the profiler for the very next request. - * - * If the profiler is not enabled, the call to this method does nothing. - */ - public function enableProfiler() - { - if ($this->kernel->getContainer()->has('profiler')) { - $this->profiler = true; - } - } - - /** - * Disables kernel reboot between requests. - * - * By default, the Client reboots the Kernel for each request. This method - * allows to keep the same kernel across requests. - */ - public function disableReboot() - { - $this->reboot = false; - } - - /** - * Enables kernel reboot between requests. - */ - public function enableReboot() - { - $this->reboot = true; - } - - /** - * {@inheritdoc} - * - * @param Request $request A Request instance - * - * @return Response A Response instance - */ - protected function doRequest($request) - { - // avoid shutting down the Kernel if no request has been performed yet - // WebTestCase::createClient() boots the Kernel but do not handle a request - if ($this->hasPerformedRequest && $this->reboot) { - $this->kernel->shutdown(); - } else { - $this->hasPerformedRequest = true; - } - - if ($this->profiler) { - $this->profiler = false; - - $this->kernel->boot(); - $this->kernel->getContainer()->get('profiler')->enable(); - } - - return parent::doRequest($request); - } - - /** - * {@inheritdoc} - * - * @param Request $request A Request instance - * - * @return Response A Response instance - */ - protected function doRequestInProcess($request) - { - $response = parent::doRequestInProcess($request); - - $this->profiler = false; - - return $response; - } - - /** - * Returns the script to execute when the request must be insulated. - * - * It assumes that the autoloader is named 'autoload.php' and that it is - * stored in the same directory as the kernel (this is the case for the - * Symfony Standard Edition). If this is not your case, create your own - * client and override this method. - * - * @param Request $request A Request instance - * - * @return string The script content - */ - protected function getScript($request) - { - $kernel = var_export(serialize($this->kernel), true); - $request = var_export(serialize($request), true); - $errorReporting = error_reporting(); - - $requires = ''; - foreach (get_declared_classes() as $class) { - if (0 === strpos($class, 'ComposerAutoloaderInit')) { - $r = new \ReflectionClass($class); - $file = \dirname(\dirname($r->getFileName())).'/autoload.php'; - if (file_exists($file)) { - $requires .= 'require_once '.var_export($file, true).";\n"; - } - } - } - - if (!$requires) { - throw new \RuntimeException('Composer autoloader not found.'); - } - - $requires .= 'require_once '.var_export((new \ReflectionObject($this->kernel))->getFileName(), true).";\n"; - - $profilerCode = ''; - if ($this->profiler) { - $profilerCode = '$kernel->getContainer()->get(\'profiler\')->enable();'; - } - - $code = <<boot(); -$profilerCode - -\$request = unserialize($request); -EOF; - - return $code.$this->getHandleScript(); - } } diff --git a/src/Symfony/Component/HttpKernel/Client.php b/src/Symfony/Component/HttpKernel/Client.php index ed1e1382ea0e8..66ce0649f06ca 100644 --- a/src/Symfony/Component/HttpKernel/Client.php +++ b/src/Symfony/Component/HttpKernel/Client.php @@ -11,8 +11,191 @@ namespace Symfony\Component\HttpKernel; -@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.3, use "%s" instead.', Client::class, HttpKernelBrowser::class), E_USER_DEPRECATED); +use Symfony\Component\BrowserKit\AbstractBrowser; +use Symfony\Component\BrowserKit\CookieJar; +use Symfony\Component\BrowserKit\History; +use Symfony\Component\BrowserKit\Request as DomRequest; +use Symfony\Component\BrowserKit\Response as DomResponse; +use Symfony\Component\HttpFoundation\File\UploadedFile; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; -class Client extends HttpKernelBrowser +/** + * Client simulates a browser and makes requests to an HttpKernel instance. + * + * @deprecated since Symfony 4.3, use HttpKernelBrowser instead. + */ +class Client extends AbstractBrowser { + protected $kernel; + private $catchExceptions = true; + + /** + * @param HttpKernelInterface $kernel An HttpKernel instance + * @param array $server The server parameters (equivalent of $_SERVER) + * @param History $history A History instance to store the browser history + * @param CookieJar $cookieJar A CookieJar instance to store the cookies + */ + public function __construct(HttpKernelInterface $kernel, array $server = [], History $history = null, CookieJar $cookieJar = null) + { + // These class properties must be set before calling the parent constructor, as it may depend on it. + $this->kernel = $kernel; + $this->followRedirects = false; + + parent::__construct($server, $history, $cookieJar); + } + + /** + * Sets whether to catch exceptions when the kernel is handling a request. + * + * @param bool $catchExceptions Whether to catch exceptions + */ + public function catchExceptions($catchExceptions) + { + $this->catchExceptions = $catchExceptions; + } + + /** + * Makes a request. + * + * @return Response A Response instance + */ + protected function doRequest($request) + { + $response = $this->kernel->handle($request, HttpKernelInterface::MASTER_REQUEST, $this->catchExceptions); + + if ($this->kernel instanceof TerminableInterface) { + $this->kernel->terminate($request, $response); + } + + return $response; + } + + /** + * Returns the script to execute when the request must be insulated. + * + * @return string + */ + protected function getScript($request) + { + $kernel = var_export(serialize($this->kernel), true); + $request = var_export(serialize($request), true); + + $errorReporting = error_reporting(); + + $requires = ''; + foreach (get_declared_classes() as $class) { + if (0 === strpos($class, 'ComposerAutoloaderInit')) { + $r = new \ReflectionClass($class); + $file = \dirname(\dirname($r->getFileName())).'/autoload.php'; + if (file_exists($file)) { + $requires .= 'require_once '.var_export($file, true).";\n"; + } + } + } + + if (!$requires) { + throw new \RuntimeException('Composer autoloader not found.'); + } + + $code = <<getHandleScript(); + } + + protected function getHandleScript() + { + return <<<'EOF' +$response = $kernel->handle($request); + +if ($kernel instanceof Symfony\Component\HttpKernel\TerminableInterface) { + $kernel->terminate($request, $response); +} + +echo serialize($response); +EOF; + } + + /** + * Converts the BrowserKit request to a HttpKernel request. + * + * @return Request A Request instance + */ + protected function filterRequest(DomRequest $request) + { + $httpRequest = Request::create($request->getUri(), $request->getMethod(), $request->getParameters(), $request->getCookies(), $request->getFiles(), $request->getServer(), $request->getContent()); + + foreach ($this->filterFiles($httpRequest->files->all()) as $key => $value) { + $httpRequest->files->set($key, $value); + } + + return $httpRequest; + } + + /** + * Filters an array of files. + * + * This method created test instances of UploadedFile so that the move() + * method can be called on those instances. + * + * If the size of a file is greater than the allowed size (from php.ini) then + * an invalid UploadedFile is returned with an error set to UPLOAD_ERR_INI_SIZE. + * + * @see UploadedFile + * + * @return array An array with all uploaded files marked as already moved + */ + protected function filterFiles(array $files) + { + $filtered = []; + foreach ($files as $key => $value) { + if (\is_array($value)) { + $filtered[$key] = $this->filterFiles($value); + } elseif ($value instanceof UploadedFile) { + if ($value->isValid() && $value->getSize() > UploadedFile::getMaxFilesize()) { + $filtered[$key] = new UploadedFile( + '', + $value->getClientOriginalName(), + $value->getClientMimeType(), + UPLOAD_ERR_INI_SIZE, + true + ); + } else { + $filtered[$key] = new UploadedFile( + $value->getPathname(), + $value->getClientOriginalName(), + $value->getClientMimeType(), + $value->getError(), + true + ); + } + } + } + + return $filtered; + } + + /** + * Converts the HttpKernel response to a BrowserKit response. + * + * @return DomResponse A DomResponse instance + */ + protected function filterResponse($response) + { + // this is needed to support StreamedResponse + ob_start(); + $response->sendContent(); + $content = ob_get_clean(); + + return new DomResponse($content, $response->getStatusCode(), $response->headers->all()); + } } diff --git a/src/Symfony/Component/HttpKernel/HttpKernelBrowser.php b/src/Symfony/Component/HttpKernel/HttpKernelBrowser.php index 76f964ce6a27b..ab52df14edfe3 100644 --- a/src/Symfony/Component/HttpKernel/HttpKernelBrowser.php +++ b/src/Symfony/Component/HttpKernel/HttpKernelBrowser.php @@ -11,15 +11,6 @@ namespace Symfony\Component\HttpKernel; -use Symfony\Component\BrowserKit\AbstractBrowser; -use Symfony\Component\BrowserKit\CookieJar; -use Symfony\Component\BrowserKit\History; -use Symfony\Component\BrowserKit\Request as DomRequest; -use Symfony\Component\BrowserKit\Response as DomResponse; -use Symfony\Component\HttpFoundation\File\UploadedFile; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - /** * Client simulates a browser and makes requests to an HttpKernel instance. * @@ -28,177 +19,6 @@ * @method Request getRequest() A Request instance * @method Response getResponse() A Response instance */ -class HttpKernelBrowser extends AbstractBrowser +class HttpKernelBrowser extends Client { - protected $kernel; - private $catchExceptions = true; - - /** - * @param HttpKernelInterface $kernel An HttpKernel instance - * @param array $server The server parameters (equivalent of $_SERVER) - * @param History $history A History instance to store the browser history - * @param CookieJar $cookieJar A CookieJar instance to store the cookies - */ - public function __construct(HttpKernelInterface $kernel, array $server = [], History $history = null, CookieJar $cookieJar = null) - { - // These class properties must be set before calling the parent constructor, as it may depend on it. - $this->kernel = $kernel; - $this->followRedirects = false; - - parent::__construct($server, $history, $cookieJar); - } - - /** - * Sets whether to catch exceptions when the kernel is handling a request. - * - * @param bool $catchExceptions Whether to catch exceptions - */ - public function catchExceptions($catchExceptions) - { - $this->catchExceptions = $catchExceptions; - } - - /** - * Makes a request. - * - * @return Response A Response instance - */ - protected function doRequest($request) - { - $response = $this->kernel->handle($request, HttpKernelInterface::MASTER_REQUEST, $this->catchExceptions); - - if ($this->kernel instanceof TerminableInterface) { - $this->kernel->terminate($request, $response); - } - - return $response; - } - - /** - * Returns the script to execute when the request must be insulated. - * - * @return string - */ - protected function getScript($request) - { - $kernel = var_export(serialize($this->kernel), true); - $request = var_export(serialize($request), true); - - $errorReporting = error_reporting(); - - $requires = ''; - foreach (get_declared_classes() as $class) { - if (0 === strpos($class, 'ComposerAutoloaderInit')) { - $r = new \ReflectionClass($class); - $file = \dirname(\dirname($r->getFileName())).'/autoload.php'; - if (file_exists($file)) { - $requires .= 'require_once '.var_export($file, true).";\n"; - } - } - } - - if (!$requires) { - throw new \RuntimeException('Composer autoloader not found.'); - } - - $code = <<getHandleScript(); - } - - protected function getHandleScript() - { - return <<<'EOF' -$response = $kernel->handle($request); - -if ($kernel instanceof Symfony\Component\HttpKernel\TerminableInterface) { - $kernel->terminate($request, $response); -} - -echo serialize($response); -EOF; - } - - /** - * Converts the BrowserKit request to a HttpKernel request. - * - * @return Request A Request instance - */ - protected function filterRequest(DomRequest $request) - { - $httpRequest = Request::create($request->getUri(), $request->getMethod(), $request->getParameters(), $request->getCookies(), $request->getFiles(), $request->getServer(), $request->getContent()); - - foreach ($this->filterFiles($httpRequest->files->all()) as $key => $value) { - $httpRequest->files->set($key, $value); - } - - return $httpRequest; - } - - /** - * Filters an array of files. - * - * This method created test instances of UploadedFile so that the move() - * method can be called on those instances. - * - * If the size of a file is greater than the allowed size (from php.ini) then - * an invalid UploadedFile is returned with an error set to UPLOAD_ERR_INI_SIZE. - * - * @see UploadedFile - * - * @return array An array with all uploaded files marked as already moved - */ - protected function filterFiles(array $files) - { - $filtered = []; - foreach ($files as $key => $value) { - if (\is_array($value)) { - $filtered[$key] = $this->filterFiles($value); - } elseif ($value instanceof UploadedFile) { - if ($value->isValid() && $value->getSize() > UploadedFile::getMaxFilesize()) { - $filtered[$key] = new UploadedFile( - '', - $value->getClientOriginalName(), - $value->getClientMimeType(), - UPLOAD_ERR_INI_SIZE, - true - ); - } else { - $filtered[$key] = new UploadedFile( - $value->getPathname(), - $value->getClientOriginalName(), - $value->getClientMimeType(), - $value->getError(), - true - ); - } - } - } - - return $filtered; - } - - /** - * Converts the HttpKernel response to a BrowserKit response. - * - * @return DomResponse A DomResponse instance - */ - protected function filterResponse($response) - { - // this is needed to support StreamedResponse - ob_start(); - $response->sendContent(); - $content = ob_get_clean(); - - return new DomResponse($content, $response->getStatusCode(), $response->headers->all()); - } } From 9f244a50ecee4f0721ae9341e8bdd8bd1f906152 Mon Sep 17 00:00:00 2001 From: Yonel Ceruto Date: Wed, 5 Jun 2019 18:09:42 -0400 Subject: [PATCH 51/59] Fix DoctrineBridge upgrade 5.0 --- UPGRADE-5.0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UPGRADE-5.0.md b/UPGRADE-5.0.md index c2abf4f8b7fd7..4f94883ae3fc5 100644 --- a/UPGRADE-5.0.md +++ b/UPGRADE-5.0.md @@ -75,7 +75,7 @@ DoctrineBridge * Deprecated injecting `ClassMetadataFactory` in `DoctrineExtractor`, an instance of `EntityManagerInterface` should be injected instead * Passing an `IdReader` to the `DoctrineChoiceLoader` when the query cannot be optimized with single id field will throw an exception, pass `null` instead - * Not passing an `IdReader` to the `DoctrineChoiceLoader` when the query can be optimized with single id field will throw an exception + * Not passing an `IdReader` to the `DoctrineChoiceLoader` when the query can be optimized with single id field will not apply any optimization DomCrawler From d03eb033bb413f310cdbe89005ba1b4ee7a88943 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Wed, 5 Jun 2019 18:16:43 +0200 Subject: [PATCH 52/59] [Cache] Pass arg to get callback everywhere --- .../Component/Cache/Adapter/ArrayAdapter.php | 3 ++- .../Component/Cache/Adapter/NullAdapter.php | 4 +++- .../Component/Cache/Adapter/ProxyAdapter.php | 4 ++-- .../Cache/Adapter/TraceableAdapter.php | 4 ++-- .../Cache/Tests/Adapter/AdapterTestCase.php | 19 +++++++++++++++++++ 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php b/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php index bbb1f846e4cf5..defa48eed96ad 100644 --- a/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php @@ -59,7 +59,8 @@ public function get(string $key, callable $callback, float $beta = null, array & // ArrayAdapter works in memory, we don't care about stampede protection if (INF === $beta || !$item->isHit()) { - $this->save($item->set($callback($item))); + $save = true; + $this->save($item->set($callback($item, $save))); } return $item->get(); diff --git a/src/Symfony/Component/Cache/Adapter/NullAdapter.php b/src/Symfony/Component/Cache/Adapter/NullAdapter.php index f1bdd2bf71916..54cd453565907 100644 --- a/src/Symfony/Component/Cache/Adapter/NullAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/NullAdapter.php @@ -42,7 +42,9 @@ function ($key) { */ public function get(string $key, callable $callback, float $beta = null, array &$metadata = null) { - return $callback(($this->createCacheItem)($key)); + $save = true; + + return $callback(($this->createCacheItem)($key), $save); } /** diff --git a/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php b/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php index 8340bdf034177..cf51b90d8d859 100644 --- a/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php @@ -103,9 +103,9 @@ public function get(string $key, callable $callback, float $beta = null, array & return $this->doGet($this, $key, $callback, $beta, $metadata); } - return $this->pool->get($this->getId($key), function ($innerItem) use ($key, $callback) { + return $this->pool->get($this->getId($key), function ($innerItem, bool &$save) use ($key, $callback) { $item = ($this->createCacheItem)($key, $innerItem); - $item->set($value = $callback($item)); + $item->set($value = $callback($item, $save)); ($this->setInnerItem)($innerItem, (array) $item); return $value; diff --git a/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php b/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php index 5c294d03fd530..660acf54d7bdb 100644 --- a/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php @@ -45,10 +45,10 @@ public function get(string $key, callable $callback, float $beta = null, array & } $isHit = true; - $callback = function (CacheItem $item) use ($callback, &$isHit) { + $callback = function (CacheItem $item, bool &$save) use ($callback, &$isHit) { $isHit = $item->isHit(); - return $callback($item); + return $callback($item, $save); }; $event = $this->start(__FUNCTION__); diff --git a/src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php b/src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php index 498c00ca643a4..2b4c9e95bf854 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php @@ -12,9 +12,12 @@ namespace Symfony\Component\Cache\Tests\Adapter; use Cache\IntegrationTests\CachePoolTest; +use PHPUnit\Framework\Assert; +use Psr\Cache\CacheItemInterface; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\CacheItem; use Symfony\Component\Cache\PruneableInterface; +use Symfony\Contracts\Cache\CallbackInterface; abstract class AdapterTestCase extends CachePoolTest { @@ -57,6 +60,22 @@ public function testGet() $this->assertSame($value, $item->get()); }, INF)); $this->assertFalse($isHit); + + $this->assertSame($value, $cache->get('bar', new class($value) implements CallbackInterface { + private $value; + + public function __construct(int $value) + { + $this->value = $value; + } + + public function __invoke(CacheItemInterface $item, bool &$save) + { + Assert::assertSame('bar', $item->getKey()); + + return $this->value; + } + })); } public function testRecursiveGet() From 625392669a1dfd6c4210b5c506d6d9392e78c21a Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 5 Jun 2019 18:16:08 +0200 Subject: [PATCH 53/59] [FrameworkBundle] fix BC-breaking property in WebTestAssertionsTrait --- .../Test/WebTestAssertionsTrait.php | 64 ++++++++++--------- .../FrameworkBundle/Test/WebTestCase.php | 8 +-- .../Tests/Test/WebTestCaseTest.php | 4 +- 3 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Test/WebTestAssertionsTrait.php b/src/Symfony/Bundle/FrameworkBundle/Test/WebTestAssertionsTrait.php index ce6c514518d76..e3e37a535931b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Test/WebTestAssertionsTrait.php +++ b/src/Symfony/Bundle/FrameworkBundle/Test/WebTestAssertionsTrait.php @@ -30,12 +30,12 @@ trait WebTestAssertionsTrait { public static function assertResponseIsSuccessful(string $message = ''): void { - self::assertThat(static::getResponse(), new ResponseConstraint\ResponseIsSuccessful(), $message); + self::assertThat(self::getResponse(), new ResponseConstraint\ResponseIsSuccessful(), $message); } public static function assertResponseStatusCodeSame(int $expectedCode, string $message = ''): void { - self::assertThat(static::getResponse(), new ResponseConstraint\ResponseStatusCodeSame($expectedCode), $message); + self::assertThat(self::getResponse(), new ResponseConstraint\ResponseStatusCodeSame($expectedCode), $message); } public static function assertResponseRedirects(string $expectedLocation = null, int $expectedCode = null, string $message = ''): void @@ -48,42 +48,42 @@ public static function assertResponseRedirects(string $expectedLocation = null, $constraint = LogicalAnd::fromConstraints($constraint, new ResponseConstraint\ResponseStatusCodeSame($expectedCode)); } - self::assertThat(static::getResponse(), $constraint, $message); + self::assertThat(self::getResponse(), $constraint, $message); } public static function assertResponseHasHeader(string $headerName, string $message = ''): void { - self::assertThat(static::getResponse(), new ResponseConstraint\ResponseHasHeader($headerName), $message); + self::assertThat(self::getResponse(), new ResponseConstraint\ResponseHasHeader($headerName), $message); } public static function assertResponseNotHasHeader(string $headerName, string $message = ''): void { - self::assertThat(static::getResponse(), new LogicalNot(new ResponseConstraint\ResponseHasHeader($headerName)), $message); + self::assertThat(self::getResponse(), new LogicalNot(new ResponseConstraint\ResponseHasHeader($headerName)), $message); } public static function assertResponseHeaderSame(string $headerName, string $expectedValue, string $message = ''): void { - self::assertThat(static::getResponse(), new ResponseConstraint\ResponseHeaderSame($headerName, $expectedValue), $message); + self::assertThat(self::getResponse(), new ResponseConstraint\ResponseHeaderSame($headerName, $expectedValue), $message); } public static function assertResponseHeaderNotSame(string $headerName, string $expectedValue, string $message = ''): void { - self::assertThat(static::getResponse(), new LogicalNot(new ResponseConstraint\ResponseHeaderSame($headerName, $expectedValue)), $message); + self::assertThat(self::getResponse(), new LogicalNot(new ResponseConstraint\ResponseHeaderSame($headerName, $expectedValue)), $message); } public static function assertResponseHasCookie(string $name, string $path = '/', string $domain = null, string $message = ''): void { - self::assertThat(static::getResponse(), new ResponseConstraint\ResponseHasCookie($name, $path, $domain), $message); + self::assertThat(self::getResponse(), new ResponseConstraint\ResponseHasCookie($name, $path, $domain), $message); } public static function assertResponseNotHasCookie(string $name, string $path = '/', string $domain = null, string $message = ''): void { - self::assertThat(static::getResponse(), new LogicalNot(new ResponseConstraint\ResponseHasCookie($name, $path, $domain)), $message); + self::assertThat(self::getResponse(), new LogicalNot(new ResponseConstraint\ResponseHasCookie($name, $path, $domain)), $message); } public static function assertResponseCookieValueSame(string $name, string $expectedValue, string $path = '/', string $domain = null, string $message = ''): void { - self::assertThat(static::getResponse(), LogicalAnd::fromConstraints( + self::assertThat(self::getResponse(), LogicalAnd::fromConstraints( new ResponseConstraint\ResponseHasCookie($name, $path, $domain), new ResponseConstraint\ResponseCookieValueSame($name, $expectedValue, $path, $domain) ), $message); @@ -91,17 +91,17 @@ public static function assertResponseCookieValueSame(string $name, string $expec public static function assertBrowserHasCookie(string $name, string $path = '/', string $domain = null, string $message = ''): void { - self::assertThat(static::getClient(), new BrowserKitConstraint\BrowserHasCookie($name, $path, $domain), $message); + self::assertThat(self::getClient(), new BrowserKitConstraint\BrowserHasCookie($name, $path, $domain), $message); } public static function assertBrowserNotHasCookie(string $name, string $path = '/', string $domain = null, string $message = ''): void { - self::assertThat(static::getClient(), new LogicalNot(new BrowserKitConstraint\BrowserHasCookie($name, $path, $domain)), $message); + self::assertThat(self::getClient(), new LogicalNot(new BrowserKitConstraint\BrowserHasCookie($name, $path, $domain)), $message); } public static function assertBrowserCookieValueSame(string $name, string $expectedValue, bool $raw = false, string $path = '/', string $domain = null, string $message = ''): void { - self::assertThat(static::getClient(), LogicalAnd::fromConstraints( + self::assertThat(self::getClient(), LogicalAnd::fromConstraints( new BrowserKitConstraint\BrowserHasCookie($name, $path, $domain), new BrowserKitConstraint\BrowserCookieValueSame($name, $expectedValue, $raw, $path, $domain) ), $message); @@ -109,17 +109,17 @@ public static function assertBrowserCookieValueSame(string $name, string $expect public static function assertSelectorExists(string $selector, string $message = ''): void { - self::assertThat(static::getCrawler(), new DomCrawlerConstraint\CrawlerSelectorExists($selector), $message); + self::assertThat(self::getCrawler(), new DomCrawlerConstraint\CrawlerSelectorExists($selector), $message); } public static function assertSelectorNotExists(string $selector, string $message = ''): void { - self::assertThat(static::getCrawler(), new LogicalNot(new DomCrawlerConstraint\CrawlerSelectorExists($selector)), $message); + self::assertThat(self::getCrawler(), new LogicalNot(new DomCrawlerConstraint\CrawlerSelectorExists($selector)), $message); } public static function assertSelectorTextContains(string $selector, string $text, string $message = ''): void { - self::assertThat(static::getCrawler(), LogicalAnd::fromConstraints( + self::assertThat(self::getCrawler(), LogicalAnd::fromConstraints( new DomCrawlerConstraint\CrawlerSelectorExists($selector), new DomCrawlerConstraint\CrawlerSelectorTextContains($selector, $text) ), $message); @@ -127,7 +127,7 @@ public static function assertSelectorTextContains(string $selector, string $text public static function assertSelectorTextSame(string $selector, string $text, string $message = ''): void { - self::assertThat(static::getCrawler(), LogicalAnd::fromConstraints( + self::assertThat(self::getCrawler(), LogicalAnd::fromConstraints( new DomCrawlerConstraint\CrawlerSelectorExists($selector), new DomCrawlerConstraint\CrawlerSelectorTextSame($selector, $text) ), $message); @@ -135,7 +135,7 @@ public static function assertSelectorTextSame(string $selector, string $text, st public static function assertSelectorTextNotContains(string $selector, string $text, string $message = ''): void { - self::assertThat(static::getCrawler(), LogicalAnd::fromConstraints( + self::assertThat(self::getCrawler(), LogicalAnd::fromConstraints( new DomCrawlerConstraint\CrawlerSelectorExists($selector), new LogicalNot(new DomCrawlerConstraint\CrawlerSelectorTextContains($selector, $text)) ), $message); @@ -153,7 +153,7 @@ public static function assertPageTitleContains(string $expectedTitle, string $me public static function assertInputValueSame(string $fieldName, string $expectedValue, string $message = ''): void { - self::assertThat(static::getCrawler(), LogicalAnd::fromConstraints( + self::assertThat(self::getCrawler(), LogicalAnd::fromConstraints( new DomCrawlerConstraint\CrawlerSelectorExists("input[name=\"$fieldName\"]"), new DomCrawlerConstraint\CrawlerSelectorAttributeValueSame("input[name=\"$fieldName\"]", 'value', $expectedValue) ), $message); @@ -161,7 +161,7 @@ public static function assertInputValueSame(string $fieldName, string $expectedV public static function assertInputValueNotSame(string $fieldName, string $expectedValue, string $message = ''): void { - self::assertThat(static::getCrawler(), LogicalAnd::fromConstraints( + self::assertThat(self::getCrawler(), LogicalAnd::fromConstraints( new DomCrawlerConstraint\CrawlerSelectorExists("input[name=\"$fieldName\"]"), new LogicalNot(new DomCrawlerConstraint\CrawlerSelectorAttributeValueSame("input[name=\"$fieldName\"]", 'value', $expectedValue)) ), $message); @@ -169,7 +169,7 @@ public static function assertInputValueNotSame(string $fieldName, string $expect public static function assertRequestAttributeValueSame(string $name, string $expectedValue, string $message = ''): void { - self::assertThat(static::getRequest(), new ResponseConstraint\RequestAttributeValueSame($name, $expectedValue), $message); + self::assertThat(self::getRequest(), new ResponseConstraint\RequestAttributeValueSame($name, $expectedValue), $message); } public static function assertRouteSame($expectedRoute, array $parameters = [], string $message = ''): void @@ -183,21 +183,27 @@ public static function assertRouteSame($expectedRoute, array $parameters = [], s $constraint = LogicalAnd::fromConstraints($constraint, ...$constraints); } - self::assertThat(static::getRequest(), $constraint, $message); + self::assertThat(self::getRequest(), $constraint, $message); } - private static function getClient(): KernelBrowser + private static function getClient(KernelBrowser $newClient = null): ?KernelBrowser { - if (!static::$client instanceof KernelBrowser) { - static::fail(\sprintf('A client must be set to make assertions on it. Did you forget to call "%s::createClient"?', __CLASS__)); + static $client; + + if (0 < \func_num_args()) { + return $client = $newClient; + } + + if (!$client instanceof KernelBrowser) { + static::fail(\sprintf('A client must be set to make assertions on it. Did you forget to call "%s::createClient()"?', __CLASS__)); } - return static::$client; + return $client; } private static function getCrawler(): Crawler { - if (!$crawler = static::getClient()->getCrawler()) { + if (!$crawler = self::getClient()->getCrawler()) { static::fail('A client must have a crawler to make assertions. Did you forget to make an HTTP request?'); } @@ -206,7 +212,7 @@ private static function getCrawler(): Crawler private static function getResponse(): Response { - if (!$response = static::getClient()->getResponse()) { + if (!$response = self::getClient()->getResponse()) { static::fail('A client must have an HTTP Response to make assertions. Did you forget to make an HTTP request?'); } @@ -215,7 +221,7 @@ private static function getResponse(): Response private static function getRequest(): Request { - if (!$request = static::getClient()->getRequest()) { + if (!$request = self::getClient()->getRequest()) { static::fail('A client must have an HTTP Request to make assertions. Did you forget to make an HTTP request?'); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php b/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php index caed6fe8a29cb..09ab5eeb66498 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php +++ b/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php @@ -23,14 +23,10 @@ abstract class WebTestCase extends KernelTestCase { use WebTestAssertionsTrait; - /** @var KernelBrowser|null */ - protected static $client; - protected function doTearDown(): void { parent::doTearDown(); - - static::$client = null; + self::getClient(null); } /** @@ -56,6 +52,6 @@ protected static function createClient(array $options = [], array $server = []) $client->setServerParameters($server); - return static::$client = $client; + return self::getClient($client); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Test/WebTestCaseTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Test/WebTestCaseTest.php index dc1bef152f579..c77e5a6f2def7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Test/WebTestCaseTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Test/WebTestCaseTest.php @@ -277,11 +277,9 @@ private function getTester(KernelBrowser $client): WebTestCase return new class($client) extends WebTestCase { use WebTestAssertionsTrait; - protected static $client; - public function __construct(KernelBrowser $client) { - static::$client = $client; + self::getClient($client); } }; } From 35e6df6bac3bbb35f71c57771ecf1dbbc510af38 Mon Sep 17 00:00:00 2001 From: Franco Traversaro Date: Wed, 5 Jun 2019 16:31:24 +0200 Subject: [PATCH 54/59] [Doctrine Bridge] Check field type before adding Length constraint --- .../Doctrine/Tests/Fixtures/DoctrineLoaderEntity.php | 9 +++++++++ .../Doctrine/Tests/Validator/DoctrineLoaderTest.php | 10 ++++++++++ .../Bridge/Doctrine/Validator/DoctrineLoader.php | 2 +- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/DoctrineLoaderEntity.php b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/DoctrineLoaderEntity.php index b6b6a681bd5f2..dc06d37fa33bb 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/DoctrineLoaderEntity.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/DoctrineLoaderEntity.php @@ -60,4 +60,13 @@ class DoctrineLoaderEntity extends DoctrineLoaderParentEntity * @ORM\Embedded(class=DoctrineLoaderEmbed::class) */ public $embedded; + + /** @ORM\Column(type="text", nullable=true, length=1000) */ + public $textField; + + /** @ORM\Id @ORM\Column(type="guid", length=50) */ + protected $guidField; + + /** @ORM\Column(type="simple_array", length=100) */ + public $simpleArrayField = []; } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php index e673d79210f85..c4c0d75fa7073 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php @@ -108,6 +108,16 @@ public function testLoadClassMetadata() $this->assertCount(1, $embeddedMaxLengthConstraints); $this->assertInstanceOf(Length::class, $embeddedMaxLengthConstraints[0]); $this->assertSame(25, $embeddedMaxLengthConstraints[0]->max); + + $this->assertCount(0, $classMetadata->getPropertyMetadata('guidField')); + $this->assertCount(0, $classMetadata->getPropertyMetadata('simpleArrayField')); + + $textFieldMetadata = $classMetadata->getPropertyMetadata('textField'); + $this->assertCount(1, $textFieldMetadata); + $textFieldConstraints = $textFieldMetadata[0]->getConstraints(); + $this->assertCount(1, $textFieldConstraints); + $this->assertInstanceOf(Length::class, $textFieldConstraints[0]); + $this->assertSame(1000, $textFieldConstraints[0]->max); } public function testFieldMappingsConfiguration() diff --git a/src/Symfony/Bridge/Doctrine/Validator/DoctrineLoader.php b/src/Symfony/Bridge/Doctrine/Validator/DoctrineLoader.php index b3993518dd344..53bf606ac36df 100644 --- a/src/Symfony/Bridge/Doctrine/Validator/DoctrineLoader.php +++ b/src/Symfony/Bridge/Doctrine/Validator/DoctrineLoader.php @@ -73,7 +73,7 @@ public function loadClassMetadata(ClassMetadata $metadata): bool $metadata->addConstraint(new UniqueEntity(['fields' => $mapping['fieldName']])); } - if (null === ($mapping['length'] ?? null)) { + if (null === ($mapping['length'] ?? null) || !\in_array($mapping['type'], ['string', 'text'], true)) { continue; } From 4a4b62bf4d012f4052a1127ef075a01809bc25be Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 6 Jun 2019 11:21:46 +0200 Subject: [PATCH 55/59] [HttpKernel] fix link to source generation --- .../Component/HttpKernel/Debug/FileLinkFormatter.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php b/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php index 54defbf1d1111..eb241675297a2 100644 --- a/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php +++ b/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php @@ -68,7 +68,7 @@ public function format($file, $line) */ public function __sleep(): array { - $this->getFileLinkFormat(); + $this->fileLinkFormat = $this->getFileLinkFormat(); return ['fileLinkFormat']; } @@ -87,17 +87,19 @@ public static function generateUrlFormat(UrlGeneratorInterface $router, $routeNa private function getFileLinkFormat() { + if ($this->fileLinkFormat) { + return $this->fileLinkFormat; + } + if ($this->requestStack && $this->baseDir && $this->urlFormat) { $request = $this->requestStack->getMasterRequest(); if ($request instanceof Request && (!$this->urlFormat instanceof \Closure || $this->urlFormat = ($this->urlFormat)())) { - $this->fileLinkFormat = [ + return [ $request->getSchemeAndHttpHost().$request->getBasePath().$this->urlFormat, $this->baseDir.\DIRECTORY_SEPARATOR, '', ]; } } - - return $this->fileLinkFormat; } } From a6025ab5ee0129329a4bc355edaa70743104293d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80=20?= =?UTF-8?q?=D0=9B=D0=B8?= Date: Thu, 6 Jun 2019 15:54:42 +0500 Subject: [PATCH 56/59] Change IntlTimeZone to DateTimeZone --- .../DateTimeToLocalizedStringTransformer.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php index 36c19970f280c..6ca20106fa399 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php @@ -162,11 +162,8 @@ protected function getIntlDateFormatter($ignoreTimezone = false) { $dateFormat = $this->dateFormat; $timeFormat = $this->timeFormat; - $timezone = $ignoreTimezone ? 'UTC' : $this->outputTimezone; - if (class_exists('IntlTimeZone', false)) { - // see https://bugs.php.net/bug.php?id=66323 - $timezone = \IntlTimeZone::createTimeZone($timezone); - } + $timezone = new \DateTimeZone($ignoreTimezone ? 'UTC' : $this->outputTimezone); + $calendar = $this->calendar; $pattern = $this->pattern; From ee98786365d979ee2797091879243abdab20e53a Mon Sep 17 00:00:00 2001 From: Henrik Volmer Date: Thu, 6 Jun 2019 12:10:36 +0200 Subject: [PATCH 57/59] Fix wrong requirements for ocramius/proxy-manager in root composer.json --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 71c597d122df6..dd8be073e4813 100644 --- a/composer.json +++ b/composer.json @@ -98,7 +98,7 @@ "doctrine/reflection": "~1.0", "doctrine/doctrine-bundle": "~1.4", "monolog/monolog": "~1.11", - "ocramius/proxy-manager": "~0.4|~1.0|~2.0", + "ocramius/proxy-manager": "^2.1", "predis/predis": "~1.1", "egulias/email-validator": "~1.2,>=1.2.8|~2.0", "symfony/phpunit-bridge": "~3.4|~4.0", @@ -108,6 +108,7 @@ "conflict": { "phpdocumentor/reflection-docblock": "<3.0||>=3.2.0,<3.2.2", "phpdocumentor/type-resolver": "<0.3.0", + "ocramius/proxy-manager": "<2.1", "phpunit/phpunit": "<5.4.3" }, "provide": { From 14bd3ed829bba6cb0724e9b22d8359b4b7f66856 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 6 Jun 2019 15:22:58 +0200 Subject: [PATCH 58/59] updated CHANGELOG for 4.3.1 --- CHANGELOG-4.3.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/CHANGELOG-4.3.md b/CHANGELOG-4.3.md index 8f905cd7afcc5..29037980b3d30 100644 --- a/CHANGELOG-4.3.md +++ b/CHANGELOG-4.3.md @@ -7,6 +7,46 @@ in 4.3 minor versions. To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v4.3.0...v4.3.1 +* 4.3.1 (2019-06-06) + + * bug #31894 Fix wrong requirements for ocramius/proxy-manager in root composer.json (henrikvolmer) + * bug #31865 [Form] Fix wrong DateTime on outdated ICU library (aweelex) + * bug #31893 [HttpKernel] fix link to source generation (nicolas-grekas) + * bug #31880 [FrameworkBundle] fix BC-breaking property in WebTestAssertionsTrait (nicolas-grekas) + * bug #31881 [FramworkBundle][HttpKernel] fix KernelBrowser BC layer (nicolas-grekas) + * bug #31879 [Cache] Pass arg to get callback everywhere (fancyweb) + * bug #31874 [Doctrine Bridge] Check field type before adding Length constraint (belinde) + * bug #31872 [Messenger] Add missing runtime check for ext redis version (chalasr) + * bug #31864 [Cache] Fixed undefined variable in ArrayTrait (eXtreme) + * bug #31863 [HttpFoundation] Fixed case-sensitive handling of cache-control header in RedirectResponse constructor (Ivo) + * bug #31850 [HttpClient] add $response->cancel() (nicolas-grekas) + * bug #31871 [HttpClient] revert bad logic around JSON_THROW_ON_ERROR (nicolas-grekas) + * bug #31869 Fix json-encoding when JSON_THROW_ON_ERROR is used (nicolas-grekas) + * bug #31868 [HttpKernel] Fix handling non-catchable fatal errors (nicolas-grekas) + * bug #31834 [HttpClient] Don't throw InvalidArgumentException on bad Location header (nicolas-grekas) + * bug #31846 [Mailer] Set default crypto method (bpolaszek) + * bug #31849 [Console] Add check for Konsole/Yakuake to disable hyperlinks (belinde) + * bug #31854 Rename the Symfony Mailer service implementation to avoid conflict with SwitMailer (tgalopin) + * bug #31856 [VarDumper] fix dumping the cloner itself (nicolas-grekas) + * bug #31861 [HttpClient] work around PHP 7.3 bug related to json_encode() (nicolas-grekas) + * bug #31860 [HttpFoundation] work around PHP 7.3 bug related to json_encode() (nicolas-grekas) + * bug #31852 [Form] add missing symfony/service-contracts dependency (nicolas-grekas) + * bug #31836 [DoctrineBridge] do not process private properties from parent class (xabbuh) + * bug #31790 [Messenger] set amqp content_type based on serialization format (Tobion) + * bug #31832 [HttpClient] fix unregistering the debug buffer when using curl (nicolas-grekas) + * bug #31407 [Security] added support for updated "distinguished name" format in x509 authentication (Robert Kopera) + * bug #31774 [Mailer] Fix the possibility to set a From header from MessageListener (fabpot) + * bug #31811 [DoctrineBridge] don't add embedded properties to wrapping class metadata (xabbuh) + * bug #31786 [Translation] Fixed case sensitivity of lint:xliff command (javiereguiluz) + * bug #31815 [Translator] Collect locale details earlier in the process (pierredup) + * bug #31761 [TwigBridge] suggest Translation Component when TranslationExtension is used (nicolas-grekas) + * bug #31748 [Messenger] Inject RoutableMessageBus instead of bus locator (chalasr) + * bug #31763 [Security\Core] Make SodiumPasswordEncoder validate BCrypt-ed passwords (nicolas-grekas) + * bug #31744 [Validator] Fix TimezoneValidator default option (ro0NL) + * bug #31749 [DoctrineBridge][Validator] do not enable validator auto mapping by default (xabbuh) + * bug #31757 [DomCrawler] Fix type error with null Form::$currentUri (chalasr) + * bug #31721 [PHPUnitBridge] Use a more appropriate group when deprecating mode (greg0ire) + * 4.3.0 (2019-05-30) * bug #31654 [HttpFoundation] Do not set X-Accel-Redirect for paths outside of X-Accel-Mapping (vilius-g) From 31e678cd3185d826f8e1f2b63cd7bd138b8fb3d0 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 6 Jun 2019 15:23:34 +0200 Subject: [PATCH 59/59] updated VERSION for 4.3.1 --- src/Symfony/Component/HttpKernel/Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 8b7b949cf4df0..9c62c087ec73c 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '4.3.1-DEV'; + const VERSION = '4.3.1'; const VERSION_ID = 40301; const MAJOR_VERSION = 4; const MINOR_VERSION = 3; const RELEASE_VERSION = 1; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '01/2020'; const END_OF_LIFE = '07/2020';