From b7487f476b0bc2ceb534c310e0273ae04001d539 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 18 Dec 2018 09:15:13 +0100 Subject: [PATCH 1/6] [Yaml] detect circular references --- src/Symfony/Component/Yaml/Parser.php | 14 +++++++ .../Component/Yaml/Tests/ParserTest.php | 42 +++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index 36c9f1d913..8b3b6992e5 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -35,6 +35,7 @@ class Parser private $refs = array(); private $skippedLineNumbers = array(); private $locallySkippedLineNumbers = array(); + private $refsBeingParsed = array(); public function __construct() { @@ -212,6 +213,7 @@ class Parser if (isset($values['value']) && self::preg_match('#^&(?P[^ ]+) *(?P.*)#u', $values['value'], $matches)) { $isRef = $matches['ref']; + $this->refsBeingParsed[] = $isRef; $values['value'] = $matches['value']; } @@ -244,6 +246,7 @@ class Parser } if ($isRef) { $this->refs[$isRef] = end($data); + array_pop($this->refsBeingParsed); } } elseif ( self::preg_match('#^(?P(?:![^\s]++\s++)?(?:'.Inline::REGEX_QUOTED_STRING.'|(?:!?!php/const:)?[^ \'"\[\{!].*?)) *\:(\s++(?P.+))?$#u', rtrim($this->currentLine), $values) @@ -287,6 +290,10 @@ class Parser if (isset($values['value'][0]) && '*' === $values['value'][0]) { $refName = substr(rtrim($values['value']), 1); if (!array_key_exists($refName, $this->refs)) { + if (false !== $pos = array_search($refName, $this->refsBeingParsed, true)) { + throw new ParseException(sprintf('Circular reference [%s, %s] detected for reference "%s".', implode(', ', \array_slice($this->refsBeingParsed, $pos)), $refName, $refName), $this->currentLineNb + 1, $this->currentLine, $this->filename); + } + throw new ParseException(sprintf('Reference "%s" does not exist.', $refName), $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename); } @@ -340,6 +347,7 @@ class Parser } } elseif ('<<' !== $key && isset($values['value']) && self::preg_match('#^&(?P[^ ]++) *+(?P.*)#u', $values['value'], $matches)) { $isRef = $matches['ref']; + $this->refsBeingParsed[] = $isRef; $values['value'] = $matches['value']; } @@ -395,6 +403,7 @@ class Parser } if ($isRef) { $this->refs[$isRef] = $data[$key]; + array_pop($this->refsBeingParsed); } } else { // multiple documents are not supported @@ -500,6 +509,7 @@ class Parser $parser->totalNumberOfLines = $this->totalNumberOfLines; $parser->skippedLineNumbers = $skippedLineNumbers; $parser->refs = &$this->refs; + $parser->refsBeingParsed = $this->refsBeingParsed; return $parser->doParse($yaml, $flags); } @@ -689,6 +699,10 @@ class Parser } if (!array_key_exists($value, $this->refs)) { + if (false !== $pos = array_search($value, $this->refsBeingParsed, true)) { + throw new ParseException(sprintf('Circular reference [%s, %s] detected for reference "%s".', implode(', ', \array_slice($this->refsBeingParsed, $pos)), $value, $value), $this->currentLineNb + 1, $this->currentLine, $this->filename); + } + throw new ParseException(sprintf('Reference "%s" does not exist.', $value), $this->currentLineNb + 1, $this->currentLine, $this->filename); } diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php index 6372fe45ee..38ed1b340d 100644 --- a/src/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php @@ -2177,6 +2177,48 @@ EOE; $this->parser->parse($yaml); } + /** + * @dataProvider circularReferenceProvider + * @expectedException \Symfony\Component\Yaml\Exception\ParseException + * @expectedExceptionMessage Circular reference [foo, bar, foo] detected + */ + public function testDetectCircularReferences($yaml) + { + $this->parser->parse($yaml, Yaml::PARSE_CUSTOM_TAGS); + } + + public function circularReferenceProvider() + { + $tests = array(); + + $yaml = << Date: Tue, 18 Dec 2018 13:59:24 +0000 Subject: [PATCH 2/6] Allow running PHPUnit with "xdebug.scream" ON Since https://github.com/symfony/symfony/pull/25733 the Kernel attempts to unlink the legacy container while being built. This throws an error if the file did not exist, for example on a clean install, on the build, which is then silenced. That's fine on production systems, but on our build we have enabled "xdebug.scream" in order to visualise every errors, which basically un-silences the errors. I believe there should not be a need to silence anything on a usual, clean usage of the system. Making this `unlink` conditional fixes it. Could you please approve and merge this PR? Thanks --- src/Symfony/Component/HttpKernel/Kernel.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 8635c2dfc4..3d28967ed0 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -862,7 +862,10 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl $fs->dumpFile($dir.$file, $code); @chmod($dir.$file, 0666 & ~umask()); } - @unlink(\dirname($dir.$file).'.legacy'); + $legacyFile = \dirname($dir.$file).'.legacy'; + if (file_exists($legacyFile)) { + @unlink($legacyFile); + } $cache->write($rootCode, $container->getResources()); } From c76c23e6fee181c44fe628cbc1ae727c5b644d93 Mon Sep 17 00:00:00 2001 From: Tri Pham Date: Mon, 17 Dec 2018 09:47:47 +0700 Subject: [PATCH 3/6] Add Vietnamese translation for validators --- .../Resources/translations/validators.vi.xlf | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/Symfony/Component/Form/Resources/translations/validators.vi.xlf diff --git a/src/Symfony/Component/Form/Resources/translations/validators.vi.xlf b/src/Symfony/Component/Form/Resources/translations/validators.vi.xlf new file mode 100644 index 0000000000..b5b2f83a9a --- /dev/null +++ b/src/Symfony/Component/Form/Resources/translations/validators.vi.xlf @@ -0,0 +1,19 @@ + + + + + + This form should not contain extra fields. + Mẫu này không nên chứa trường mở rộng + + + The uploaded file was too large. Please try to upload a smaller file. + Tập tin tải lên quá lớn. Vui lòng thử lại với tập tin nhỏ hơn. + + + The CSRF token is invalid. Please try to resubmit the form. + CSRF token không hợp lệ. Vui lòng thử lại. + + + + From 596b9812e3682ae7029f2993675708abd31ecbb7 Mon Sep 17 00:00:00 2001 From: Andreas Braun Date: Sat, 22 Dec 2018 14:25:23 +0100 Subject: [PATCH 4/6] Fix wrong calls to clearstatcache --- src/Symfony/Component/Finder/Tests/FinderTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Finder/Tests/FinderTest.php b/src/Symfony/Component/Finder/Tests/FinderTest.php index fbdcc36e6b..f64919920e 100644 --- a/src/Symfony/Component/Finder/Tests/FinderTest.php +++ b/src/Symfony/Component/Finder/Tests/FinderTest.php @@ -697,7 +697,7 @@ class FinderTest extends Iterator\RealIteratorTestCase // restore original permissions chmod($testDir, 0777); - clearstatcache($testDir); + clearstatcache(true, $testDir); if ($couldRead) { $this->markTestSkipped('could read test files while test requires unreadable'); @@ -723,7 +723,7 @@ class FinderTest extends Iterator\RealIteratorTestCase // restore original permissions chmod($testDir, 0777); - clearstatcache($testDir); + clearstatcache(true, $testDir); if ($couldRead) { $this->markTestSkipped('could read test files while test requires unreadable'); From 13bcd6ae9f0e22f4e92b8b9b8f432579f3f45bc0 Mon Sep 17 00:00:00 2001 From: Martin Hujer Date: Sun, 23 Dec 2018 10:19:07 +0100 Subject: [PATCH 5/6] [Console] fix PHPDoc in Command Issue was introduced #28714 --- src/Symfony/Component/Console/Command/Command.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index c8dcf3befe..d15dce3abb 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -369,9 +369,9 @@ class Command * Adds an argument. * * @param string $name The argument name - * @param int|null $mode The argument mode: self::REQUIRED or self::OPTIONAL + * @param int|null $mode The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL * @param string $description A description text - * @param string|string[]|null $default The default value (for self::OPTIONAL mode only) + * @param string|string[]|null $default The default value (for InputArgument::OPTIONAL mode only) * * @throws InvalidArgumentException When argument mode is not valid * @@ -389,9 +389,9 @@ class Command * * @param string $name The option name * @param string|array $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts - * @param int|null $mode The option mode: One of the VALUE_* constants + * @param int|null $mode The option mode: One of the InputOption::VALUE_* constants * @param string $description A description text - * @param string|string[]|int|bool|null $default The default value (must be null for self::VALUE_NONE) + * @param string|string[]|int|bool|null $default The default value (must be null for InputOption::VALUE_NONE) * * @throws InvalidArgumentException If option mode is invalid or incompatible * From 0695834657d1cba44681ee1b71432018963ca76c Mon Sep 17 00:00:00 2001 From: George Mponos Date: Sat, 22 Dec 2018 21:54:00 +0200 Subject: [PATCH 6/6] [Tests] Change to willThrowException --- .../Command/TranslationDebugCommandTest.php | 2 +- .../Templating/Loader/TemplateLocatorTest.php | 2 +- .../Tests/Loader/FilesystemLoaderTest.php | 2 +- .../WebDebugToolbarListenerTest.php | 4 ++-- .../Component/Console/Tests/ApplicationTest.php | 4 ++-- .../Component/Form/Tests/SimpleFormTest.php | 4 ++-- .../EventListener/TranslatorListenerTest.php | 4 ++-- .../Fragment/HIncludeFragmentRendererTest.php | 4 ++-- .../Data/Bundle/Reader/BundleEntryReaderTest.php | 4 ++-- .../AuthenticationProviderManagerTest.php | 2 +- .../Provider/DaoAuthenticationProviderTest.php | 4 ++-- .../LdapBindAuthenticationProviderTest.php | 2 +- ...reAuthenticatedAuthenticationProviderTest.php | 2 +- .../RememberMeAuthenticationProviderTest.php | 2 +- .../SimpleAuthenticationProviderTest.php | 4 ++-- .../Provider/UserAuthenticationProviderTest.php | 12 ++++++------ .../Core/Tests/User/ChainUserProviderTest.php | 16 ++++++++-------- .../Core/Tests/User/LdapUserProviderTest.php | 2 +- .../Firewall/GuardAuthenticationListenerTest.php | 2 +- .../AbstractPreAuthenticatedListenerTest.php | 6 +++--- .../Tests/Firewall/RememberMeListenerTest.php | 6 +++--- .../SimplePreAuthenticationListenerTest.php | 2 +- .../Security/Http/Tests/HttpUtilsTest.php | 6 +++--- ...ersistentTokenBasedRememberMeServicesTest.php | 4 ++-- .../TokenBasedRememberMeServicesTest.php | 2 +- 25 files changed, 52 insertions(+), 52 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php index f08921a56d..f026945bcd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php @@ -103,7 +103,7 @@ class TranslationDebugCommandTest extends TestCase $kernel->expects($this->once()) ->method('getBundle') ->with($this->equalTo('dir')) - ->will($this->throwException(new \InvalidArgumentException())); + ->willThrowException(new \InvalidArgumentException()); $tester = $this->createCommandTester(array(), array(), $kernel); $tester->execute(array('locale' => 'en', 'bundle' => 'dir')); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php index 96d75e3c3e..37ea5b484b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php @@ -60,7 +60,7 @@ class TemplateLocatorTest extends TestCase $fileLocator ->expects($this->once()) ->method('locate') - ->will($this->throwException(new \InvalidArgumentException($errorMessage))) + ->willThrowException(new \InvalidArgumentException($errorMessage)) ; $locator = new TemplateLocator($fileLocator); diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php index b9294e35b3..a73921a8c7 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php @@ -68,7 +68,7 @@ class FilesystemLoaderTest extends TestCase $locator ->expects($this->once()) ->method('locate') - ->will($this->throwException(new \InvalidArgumentException('Unable to find template "NonExistent".'))) + ->willThrowException(new \InvalidArgumentException('Unable to find template "NonExistent".')) ; $loader = new FilesystemLoader($locator, $parser); diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php index ec420107df..9917ff211d 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php @@ -252,7 +252,7 @@ class WebDebugToolbarListenerTest extends TestCase ->expects($this->once()) ->method('generate') ->with('_profiler', array('token' => 'xxxxxxxx')) - ->will($this->throwException(new \Exception('foo'))) + ->willThrowException(new \Exception('foo')) ; $event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); @@ -273,7 +273,7 @@ class WebDebugToolbarListenerTest extends TestCase ->expects($this->once()) ->method('generate') ->with('_profiler', array('token' => 'xxxxxxxx')) - ->will($this->throwException(new \Exception("This\nmultiline\r\ntabbed text should\tcome out\r on\n \ta single plain\r\nline"))) + ->willThrowException(new \Exception("This\nmultiline\r\ntabbed text should\tcome out\r on\n \ta single plain\r\nline")) ; $event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php index 7922ce273b..7cd473e5dd 100644 --- a/src/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php @@ -919,7 +919,7 @@ class ApplicationTest extends TestCase $application->setAutoExit(false); $application->expects($this->once()) ->method('doRun') - ->will($this->throwException($exception)); + ->willThrowException($exception); $exitCode = $application->run(new ArrayInput(array()), new NullOutput()); @@ -958,7 +958,7 @@ class ApplicationTest extends TestCase $application->setAutoExit(false); $application->expects($this->once()) ->method('doRun') - ->will($this->throwException($exception)); + ->willThrowException($exception); $exitCode = $application->run(new ArrayInput(array()), new NullOutput()); diff --git a/src/Symfony/Component/Form/Tests/SimpleFormTest.php b/src/Symfony/Component/Form/Tests/SimpleFormTest.php index 30d8b79274..6ec6986e18 100644 --- a/src/Symfony/Component/Form/Tests/SimpleFormTest.php +++ b/src/Symfony/Component/Form/Tests/SimpleFormTest.php @@ -629,7 +629,7 @@ class SimpleFormTest extends AbstractFormTest $transformer = $this->getDataTransformer(); $transformer->expects($this->once()) ->method('reverseTransform') - ->will($this->throwException(new TransformationFailedException())); + ->willThrowException(new TransformationFailedException()); $form = $this->getBuilder() ->addViewTransformer($transformer) @@ -645,7 +645,7 @@ class SimpleFormTest extends AbstractFormTest $transformer = $this->getDataTransformer(); $transformer->expects($this->once()) ->method('reverseTransform') - ->will($this->throwException(new TransformationFailedException())); + ->willThrowException(new TransformationFailedException()); $form = $this->getBuilder() ->addModelTransformer($transformer) diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/TranslatorListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/TranslatorListenerTest.php index 23b833177a..c1d56ec85d 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/TranslatorListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/TranslatorListenerTest.php @@ -47,7 +47,7 @@ class TranslatorListenerTest extends TestCase $this->translator ->expects($this->at(0)) ->method('setLocale') - ->will($this->throwException(new \InvalidArgumentException())); + ->willThrowException(new \InvalidArgumentException()); $this->translator ->expects($this->at(1)) ->method('setLocale') @@ -84,7 +84,7 @@ class TranslatorListenerTest extends TestCase $this->translator ->expects($this->at(0)) ->method('setLocale') - ->will($this->throwException(new \InvalidArgumentException())); + ->willThrowException(new \InvalidArgumentException()); $this->translator ->expects($this->at(1)) ->method('setLocale') diff --git a/src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php b/src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php index 10fbccf0fa..e3926708c1 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php @@ -80,7 +80,7 @@ class HIncludeFragmentRendererTest extends TestCase $engine->expects($this->once()) ->method('exists') ->with('default') - ->will($this->throwException(new \InvalidArgumentException())); + ->willThrowException(new \InvalidArgumentException()); // only default $strategy = new HIncludeFragmentRenderer($engine); @@ -93,7 +93,7 @@ class HIncludeFragmentRendererTest extends TestCase $engine->expects($this->once()) ->method('exists') ->with('loading...') - ->will($this->throwException(new \RuntimeException())); + ->willThrowException(new \RuntimeException()); // only default $strategy = new HIncludeFragmentRenderer($engine); 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 aedc18d384..7578b8b787 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/BundleEntryReaderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/BundleEntryReaderTest.php @@ -148,7 +148,7 @@ class BundleEntryReaderTest extends TestCase $this->readerImpl->expects($this->at(0)) ->method('read') ->with(self::RES_DIR, 'en_GB') - ->will($this->throwException(new ResourceBundleNotFoundException())); + ->willThrowException(new ResourceBundleNotFoundException()); $this->readerImpl->expects($this->at(1)) ->method('read') @@ -166,7 +166,7 @@ class BundleEntryReaderTest extends TestCase $this->readerImpl->expects($this->once()) ->method('read') ->with(self::RES_DIR, 'en_GB') - ->will($this->throwException(new ResourceBundleNotFoundException())); + ->willThrowException(new ResourceBundleNotFoundException()); $this->reader->readEntry(self::RES_DIR, 'en_GB', array('Entries', 'Bam'), false); } diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationProviderManagerTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationProviderManagerTest.php index 947bd4f694..0f82d3ce34 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationProviderManagerTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationProviderManagerTest.php @@ -188,7 +188,7 @@ class AuthenticationProviderManagerTest extends TestCase } elseif (null !== $exception) { $provider->expects($this->once()) ->method('authenticate') - ->will($this->throwException($this->getMockBuilder($exception)->setMethods(null)->getMock())) + ->willThrowException($this->getMockBuilder($exception)->setMethods(null)->getMock()) ; } 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 10e6eb78d8..b657925343 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php @@ -38,7 +38,7 @@ class DaoAuthenticationProviderTest extends TestCase $userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock(); $userProvider->expects($this->once()) ->method('loadUserByUsername') - ->will($this->throwException(new UsernameNotFoundException())) + ->willThrowException(new UsernameNotFoundException()) ; $provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock()); @@ -56,7 +56,7 @@ class DaoAuthenticationProviderTest extends TestCase $userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock(); $userProvider->expects($this->once()) ->method('loadUserByUsername') - ->will($this->throwException(new \RuntimeException())) + ->willThrowException(new \RuntimeException()) ; $provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock()); 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 68b4657fab..7897a5bf0a 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php @@ -73,7 +73,7 @@ class LdapBindAuthenticationProviderTest extends TestCase $ldap ->expects($this->once()) ->method('bind') - ->will($this->throwException(new ConnectionException())) + ->willThrowException(new ConnectionException()) ; $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 5a6b04d5b4..8f19a8d18e 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php @@ -85,7 +85,7 @@ class PreAuthenticatedAuthenticationProviderTest extends TestCase $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); $userChecker->expects($this->once()) ->method('checkPostAuth') - ->will($this->throwException(new LockedException())) + ->willThrowException(new LockedException()) ; $provider = $this->getProvider($user, $userChecker); 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 497f315c33..1b98a7d9d9 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php @@ -57,7 +57,7 @@ class RememberMeAuthenticationProviderTest extends TestCase $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); $userChecker->expects($this->once()) ->method('checkPreAuth') - ->will($this->throwException(new DisabledException())); + ->willThrowException(new DisabledException()); $provider = $this->getProvider($userChecker); 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 3694d996fe..661d23a4e7 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/SimpleAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/SimpleAuthenticationProviderTest.php @@ -34,7 +34,7 @@ class SimpleAuthenticationProviderTest extends TestCase $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); $userChecker->expects($this->once()) ->method('checkPreAuth') - ->will($this->throwException(new DisabledException())); + ->willThrowException(new DisabledException()); $authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock(); $authenticator->expects($this->once()) @@ -61,7 +61,7 @@ class SimpleAuthenticationProviderTest extends TestCase $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); $userChecker->expects($this->once()) ->method('checkPostAuth') - ->will($this->throwException(new LockedException())); + ->willThrowException(new LockedException()); $authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock(); $authenticator->expects($this->once()) 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 a08ca3f813..e861a20094 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php @@ -48,7 +48,7 @@ class UserAuthenticationProviderTest extends TestCase $provider = $this->getProvider(false, false); $provider->expects($this->once()) ->method('retrieveUser') - ->will($this->throwException(new UsernameNotFoundException())) + ->willThrowException(new UsernameNotFoundException()) ; $provider->authenticate($this->getSupportedToken()); @@ -62,7 +62,7 @@ class UserAuthenticationProviderTest extends TestCase $provider = $this->getProvider(false, true); $provider->expects($this->once()) ->method('retrieveUser') - ->will($this->throwException(new UsernameNotFoundException())) + ->willThrowException(new UsernameNotFoundException()) ; $provider->authenticate($this->getSupportedToken()); @@ -90,7 +90,7 @@ class UserAuthenticationProviderTest extends TestCase $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); $userChecker->expects($this->once()) ->method('checkPreAuth') - ->will($this->throwException(new CredentialsExpiredException())) + ->willThrowException(new CredentialsExpiredException()) ; $provider = $this->getProvider($userChecker); @@ -110,7 +110,7 @@ class UserAuthenticationProviderTest extends TestCase $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); $userChecker->expects($this->once()) ->method('checkPostAuth') - ->will($this->throwException(new AccountExpiredException())) + ->willThrowException(new AccountExpiredException()) ; $provider = $this->getProvider($userChecker); @@ -135,7 +135,7 @@ class UserAuthenticationProviderTest extends TestCase ; $provider->expects($this->once()) ->method('checkAuthentication') - ->will($this->throwException(new BadCredentialsException())) + ->willThrowException(new BadCredentialsException()) ; $provider->authenticate($this->getSupportedToken()); @@ -154,7 +154,7 @@ class UserAuthenticationProviderTest extends TestCase ; $provider->expects($this->once()) ->method('checkAuthentication') - ->will($this->throwException(new BadCredentialsException('Foo'))) + ->willThrowException(new BadCredentialsException('Foo')) ; $provider->authenticate($this->getSupportedToken()); diff --git a/src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php b/src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php index 3759273564..74bc42d624 100644 --- a/src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php @@ -25,7 +25,7 @@ class ChainUserProviderTest extends TestCase ->expects($this->once()) ->method('loadUserByUsername') ->with($this->equalTo('foo')) - ->will($this->throwException(new UsernameNotFoundException('not found'))) + ->willThrowException(new UsernameNotFoundException('not found')) ; $provider2 = $this->getProvider(); @@ -50,7 +50,7 @@ class ChainUserProviderTest extends TestCase ->expects($this->once()) ->method('loadUserByUsername') ->with($this->equalTo('foo')) - ->will($this->throwException(new UsernameNotFoundException('not found'))) + ->willThrowException(new UsernameNotFoundException('not found')) ; $provider2 = $this->getProvider(); @@ -58,7 +58,7 @@ class ChainUserProviderTest extends TestCase ->expects($this->once()) ->method('loadUserByUsername') ->with($this->equalTo('foo')) - ->will($this->throwException(new UsernameNotFoundException('not found'))) + ->willThrowException(new UsernameNotFoundException('not found')) ; $provider = new ChainUserProvider(array($provider1, $provider2)); @@ -71,7 +71,7 @@ class ChainUserProviderTest extends TestCase $provider1 ->expects($this->once()) ->method('refreshUser') - ->will($this->throwException(new UnsupportedUserException('unsupported'))) + ->willThrowException(new UnsupportedUserException('unsupported')) ; $provider2 = $this->getProvider(); @@ -91,7 +91,7 @@ class ChainUserProviderTest extends TestCase $provider1 ->expects($this->once()) ->method('refreshUser') - ->will($this->throwException(new UsernameNotFoundException('not found'))) + ->willThrowException(new UsernameNotFoundException('not found')) ; $provider2 = $this->getProvider(); @@ -114,14 +114,14 @@ class ChainUserProviderTest extends TestCase $provider1 ->expects($this->once()) ->method('refreshUser') - ->will($this->throwException(new UnsupportedUserException('unsupported'))) + ->willThrowException(new UnsupportedUserException('unsupported')) ; $provider2 = $this->getProvider(); $provider2 ->expects($this->once()) ->method('refreshUser') - ->will($this->throwException(new UnsupportedUserException('unsupported'))) + ->willThrowException(new UnsupportedUserException('unsupported')) ; $provider = new ChainUserProvider(array($provider1, $provider2)); @@ -178,7 +178,7 @@ class ChainUserProviderTest extends TestCase $provider1 ->expects($this->once()) ->method('refreshUser') - ->will($this->throwException(new UnsupportedUserException('unsupported'))) + ->willThrowException(new UnsupportedUserException('unsupported')) ; $provider2 = $this->getProvider(); diff --git a/src/Symfony/Component/Security/Core/Tests/User/LdapUserProviderTest.php b/src/Symfony/Component/Security/Core/Tests/User/LdapUserProviderTest.php index 7d1da7c408..2cecf70728 100644 --- a/src/Symfony/Component/Security/Core/Tests/User/LdapUserProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/User/LdapUserProviderTest.php @@ -33,7 +33,7 @@ class LdapUserProviderTest extends TestCase $ldap ->expects($this->once()) ->method('bind') - ->will($this->throwException(new ConnectionException())) + ->willThrowException(new ConnectionException()) ; $provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com'); diff --git a/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php b/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php index ba874bcba6..e2bcec310e 100644 --- a/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php @@ -185,7 +185,7 @@ class GuardAuthenticationListenerTest extends TestCase $authenticator ->expects($this->once()) ->method('getCredentials') - ->will($this->throwException($authException)); + ->willThrowException($authException); // this is not called $this->authenticationManager diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php index dd7f75e67e..32ea6e1025 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php @@ -90,7 +90,7 @@ class AbstractPreAuthenticatedListenerTest extends TestCase ->expects($this->once()) ->method('authenticate') ->with($this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken')) - ->will($this->throwException($exception)) + ->willThrowException($exception) ; $listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', array( @@ -138,7 +138,7 @@ class AbstractPreAuthenticatedListenerTest extends TestCase ->expects($this->once()) ->method('authenticate') ->with($this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken')) - ->will($this->throwException($exception)) + ->willThrowException($exception) ; $listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', array( @@ -228,7 +228,7 @@ class AbstractPreAuthenticatedListenerTest extends TestCase ->expects($this->once()) ->method('authenticate') ->with($this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken')) - ->will($this->throwException($exception)) + ->willThrowException($exception) ; $listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', array( diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php index 9acb804132..29a2c6f5c9 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php @@ -90,7 +90,7 @@ class RememberMeListenerTest extends TestCase $manager ->expects($this->once()) ->method('authenticate') - ->will($this->throwException($exception)) + ->willThrowException($exception) ; $event = $this->getGetResponseEvent(); @@ -132,7 +132,7 @@ class RememberMeListenerTest extends TestCase $manager ->expects($this->once()) ->method('authenticate') - ->will($this->throwException($exception)) + ->willThrowException($exception) ; $event = $this->getGetResponseEvent(); @@ -159,7 +159,7 @@ class RememberMeListenerTest extends TestCase $service ->expects($this->once()) ->method('autoLogin') - ->will($this->throwException($exception)) + ->willThrowException($exception) ; $service diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php index 0c4229856b..6d53e0719f 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php @@ -72,7 +72,7 @@ class SimplePreAuthenticationListenerTest extends TestCase ->expects($this->once()) ->method('authenticate') ->with($this->equalTo($this->token)) - ->will($this->throwException($exception)) + ->willThrowException($exception) ; $this->tokenStorage->expects($this->once()) diff --git a/src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php b/src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php index a0d6f79714..ace88e328a 100644 --- a/src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php +++ b/src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php @@ -200,7 +200,7 @@ class HttpUtilsTest extends TestCase ->expects($this->any()) ->method('match') ->with('/') - ->will($this->throwException(new ResourceNotFoundException())) + ->willThrowException(new ResourceNotFoundException()) ; $utils = new HttpUtils(null, $urlMatcher); @@ -215,7 +215,7 @@ class HttpUtilsTest extends TestCase ->expects($this->any()) ->method('matchRequest') ->with($request) - ->will($this->throwException(new MethodNotAllowedException(array()))) + ->willThrowException(new MethodNotAllowedException(array())) ; $utils = new HttpUtils(null, $urlMatcher); @@ -260,7 +260,7 @@ class HttpUtilsTest extends TestCase $urlMatcher ->expects($this->any()) ->method('match') - ->will($this->throwException(new \RuntimeException())) + ->willThrowException(new \RuntimeException()) ; $utils = new HttpUtils(null, $urlMatcher); diff --git a/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php b/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php index cf142ea2ad..494723fb29 100644 --- a/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php +++ b/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php @@ -65,7 +65,7 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase $tokenProvider ->expects($this->once()) ->method('loadTokenBySeries') - ->will($this->throwException(new TokenNotFoundException('Token not found.'))) + ->willThrowException(new TokenNotFoundException('Token not found.')) ; $service->setTokenProvider($tokenProvider); @@ -91,7 +91,7 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase $userProvider ->expects($this->once()) ->method('loadUserByUsername') - ->will($this->throwException(new UsernameNotFoundException('user not found'))) + ->willThrowException(new UsernameNotFoundException('user not found')) ; $this->assertNull($service->autoLogin($request)); diff --git a/src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php b/src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php index e30d68ba69..31854142a5 100644 --- a/src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php +++ b/src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php @@ -49,7 +49,7 @@ class TokenBasedRememberMeServicesTest extends TestCase $userProvider ->expects($this->once()) ->method('loadUserByUsername') - ->will($this->throwException(new UsernameNotFoundException('user not found'))) + ->willThrowException(new UsernameNotFoundException('user not found')) ; $this->assertNull($service->autoLogin($request));