Updating Symfony lib and dependencies:

Package operations: 2 installs, 23 updates, 0 removals
  - Updating psr/log (1.1.0 => 1.1.2)
  - Updating symfony/debug (v3.4.30 => v3.4.35)
  - Updating symfony/console (v3.4.30 => v3.4.35)
  - Updating symfony/dotenv (v3.4.30 => v3.4.35)
  - Updating symfony/routing (v3.4.30 => v3.4.35)
  - Updating symfony/finder (v3.4.30 => v3.4.35)
  - Updating symfony/filesystem (v3.4.30 => v3.4.35)
  - Installing symfony/polyfill-util (v1.12.0)
  - Installing symfony/polyfill-php56 (v1.12.0)
  - Updating symfony/http-foundation (v3.4.30 => v3.4.35)
  - Updating symfony/event-dispatcher (v3.4.30 => v3.4.35)
  - Updating symfony/http-kernel (v3.4.30 => v3.4.35)
  - Updating symfony/config (v3.4.30 => v3.4.35)
  - Updating symfony/dependency-injection (v3.4.30 => v3.4.35)
  - Updating symfony/class-loader (v3.4.30 => v3.4.35)
  - Updating symfony/cache (v3.4.30 => v3.4.35)
  - Updating symfony/framework-bundle (v3.4.30 => v3.4.35)
  - Updating twig/twig (v1.42.2 => v1.42.4)
  - Updating symfony/twig-bridge (v3.4.30 => v3.4.35)
  - Updating symfony/twig-bundle (v3.4.30 => v3.4.35)
  - Updating symfony/yaml (v3.4.30 => v3.4.35)
  - Updating symfony/stopwatch (v3.4.30 => v3.4.35)
  - Updating symfony/var-dumper (v3.4.30 => v3.4.35)
  - Updating symfony/web-profiler-bundle (v3.4.30 => v3.4.35)
  - Updating symfony/css-selector (v3.4.30 => v3.4.35)
This commit is contained in:
Molkobain
2019-11-18 18:04:32 +01:00
parent 532eb466a1
commit c76cccd2e7
633 changed files with 4154 additions and 4093 deletions

View File

@@ -5,6 +5,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\CacheWarmer;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\CachedReader;
use Doctrine\Common\Annotations\Reader;
use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Bundle\FrameworkBundle\CacheWarmer\AnnotationsCacheWarmer;
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
@@ -86,7 +87,55 @@ class AnnotationsCacheWarmerTest extends TestCase
}
/**
* @return \PHPUnit_Framework_MockObject_MockObject|Reader
* Test that the cache warming process is not broken if a class loader
* throws an exception (on class / file not found for example).
*/
public function testClassAutoloadException()
{
$this->assertFalse(class_exists($annotatedClass = 'C\C\C', false));
file_put_contents($this->cacheDir.'/annotations.map', sprintf('<?php return %s;', var_export([$annotatedClass], true)));
$warmer = new AnnotationsCacheWarmer(new AnnotationReader(), tempnam($this->cacheDir, __FUNCTION__), new ArrayAdapter());
spl_autoload_register($classLoader = function ($class) use ($annotatedClass) {
if ($class === $annotatedClass) {
throw new \DomainException('This exception should be caught by the warmer.');
}
}, true, true);
$warmer->warmUp($this->cacheDir);
spl_autoload_unregister($classLoader);
}
/**
* Test that the cache warming process is broken if a class loader throws an
* exception but that is unrelated to the class load.
*/
public function testClassAutoloadExceptionWithUnrelatedException()
{
$this->expectException(\DomainException::class);
$this->expectExceptionMessage('This exception should not be caught by the warmer.');
$this->assertFalse(class_exists($annotatedClass = 'AClassThatDoesNotExist_FWB_CacheWarmer_AnnotationsCacheWarmerTest', false));
file_put_contents($this->cacheDir.'/annotations.map', sprintf('<?php return %s;', var_export([$annotatedClass], true)));
$warmer = new AnnotationsCacheWarmer(new AnnotationReader(), tempnam($this->cacheDir, __FUNCTION__), new ArrayAdapter());
spl_autoload_register($classLoader = function ($class) use ($annotatedClass) {
if ($class === $annotatedClass) {
eval('class '.$annotatedClass.'{}');
throw new \DomainException('This exception should not be caught by the warmer.');
}
}, true, true);
$warmer->warmUp($this->cacheDir);
spl_autoload_unregister($classLoader);
}
/**
* @return MockObject|Reader
*/
private function getReadOnlyReader()
{

View File

@@ -50,7 +50,7 @@ class SerializerCacheWarmerTest extends TestCase
$values = $fallbackPool->getValues();
$this->assertInternalType('array', $values);
$this->assertIsArray($values);
$this->assertCount(2, $values);
$this->assertArrayHasKey('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Person', $values);
$this->assertArrayHasKey('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Author', $values);
@@ -74,7 +74,61 @@ class SerializerCacheWarmerTest extends TestCase
$values = $fallbackPool->getValues();
$this->assertInternalType('array', $values);
$this->assertIsArray($values);
$this->assertCount(0, $values);
}
/**
* Test that the cache warming process is not broken if a class loader
* throws an exception (on class / file not found for example).
*/
public function testClassAutoloadException()
{
if (!class_exists(CacheClassMetadataFactory::class) || !method_exists(XmlFileLoader::class, 'getMappedClasses') || !method_exists(YamlFileLoader::class, 'getMappedClasses')) {
$this->markTestSkipped('The Serializer default cache warmer has been introduced in the Serializer Component version 3.2.');
}
$this->assertFalse(class_exists($mappedClass = 'AClassThatDoesNotExist_FWB_CacheWarmer_SerializerCacheWarmerTest', false));
$warmer = new SerializerCacheWarmer([new YamlFileLoader(__DIR__.'/../Fixtures/Serialization/Resources/does_not_exist.yaml')], tempnam(sys_get_temp_dir(), __FUNCTION__), new ArrayAdapter());
spl_autoload_register($classLoader = function ($class) use ($mappedClass) {
if ($class === $mappedClass) {
throw new \DomainException('This exception should be caught by the warmer.');
}
}, true, true);
$warmer->warmUp('foo');
spl_autoload_unregister($classLoader);
}
/**
* Test that the cache warming process is broken if a class loader throws an
* exception but that is unrelated to the class load.
*/
public function testClassAutoloadExceptionWithUnrelatedException()
{
$this->expectException(\DomainException::class);
$this->expectExceptionMessage('This exception should not be caught by the warmer.');
if (!class_exists(CacheClassMetadataFactory::class) || !method_exists(XmlFileLoader::class, 'getMappedClasses') || !method_exists(YamlFileLoader::class, 'getMappedClasses')) {
$this->markTestSkipped('The Serializer default cache warmer has been introduced in the Serializer Component version 3.2.');
}
$this->assertFalse(class_exists($mappedClass = 'AClassThatDoesNotExist_FWB_CacheWarmer_SerializerCacheWarmerTest', false));
$warmer = new SerializerCacheWarmer([new YamlFileLoader(__DIR__.'/../Fixtures/Serialization/Resources/does_not_exist.yaml')], tempnam(sys_get_temp_dir(), __FUNCTION__), new ArrayAdapter());
spl_autoload_register($classLoader = function ($class) use ($mappedClass) {
if ($class === $mappedClass) {
eval('class '.$mappedClass.'{}');
throw new \DomainException('This exception should not be caught by the warmer.');
}
}, true, true);
$warmer->warmUp('foo');
spl_autoload_unregister($classLoader);
}
}

View File

@@ -46,7 +46,7 @@ class ValidatorCacheWarmerTest extends TestCase
$values = $fallbackPool->getValues();
$this->assertInternalType('array', $values);
$this->assertIsArray($values);
$this->assertCount(2, $values);
$this->assertArrayHasKey('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Person', $values);
$this->assertArrayHasKey('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Author', $values);
@@ -77,7 +77,7 @@ class ValidatorCacheWarmerTest extends TestCase
$values = $fallbackPool->getValues();
$this->assertInternalType('array', $values);
$this->assertIsArray($values);
$this->assertCount(2, $values);
$this->assertArrayHasKey('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Category', $values);
$this->assertArrayHasKey('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.SubCategory', $values);
@@ -99,7 +99,57 @@ class ValidatorCacheWarmerTest extends TestCase
$values = $fallbackPool->getValues();
$this->assertInternalType('array', $values);
$this->assertIsArray($values);
$this->assertCount(0, $values);
}
/**
* Test that the cache warming process is not broken if a class loader
* throws an exception (on class / file not found for example).
*/
public function testClassAutoloadException()
{
$this->assertFalse(class_exists($mappedClass = 'AClassThatDoesNotExist_FWB_CacheWarmer_ValidatorCacheWarmerTest', false));
$validatorBuilder = new ValidatorBuilder();
$validatorBuilder->addYamlMapping(__DIR__.'/../Fixtures/Validation/Resources/does_not_exist.yaml');
$warmer = new ValidatorCacheWarmer($validatorBuilder, tempnam(sys_get_temp_dir(), __FUNCTION__), new ArrayAdapter());
spl_autoload_register($classloader = function ($class) use ($mappedClass) {
if ($class === $mappedClass) {
throw new \DomainException('This exception should be caught by the warmer.');
}
}, true, true);
$warmer->warmUp('foo');
spl_autoload_unregister($classloader);
}
/**
* Test that the cache warming process is broken if a class loader throws an
* exception but that is unrelated to the class load.
*/
public function testClassAutoloadExceptionWithUnrelatedException()
{
$this->expectException(\DomainException::class);
$this->expectExceptionMessage('This exception should not be caught by the warmer.');
$this->assertFalse(class_exists($mappedClass = 'AClassThatDoesNotExist_FWB_CacheWarmer_ValidatorCacheWarmerTest', false));
$validatorBuilder = new ValidatorBuilder();
$validatorBuilder->addYamlMapping(__DIR__.'/../Fixtures/Validation/Resources/does_not_exist.yaml');
$warmer = new ValidatorCacheWarmer($validatorBuilder, tempnam(sys_get_temp_dir(), __FUNCTION__), new ArrayAdapter());
spl_autoload_register($classLoader = function ($class) use ($mappedClass) {
if ($class === $mappedClass) {
eval('class '.$mappedClass.'{}');
throw new \DomainException('This exception should not be caught by the warmer.');
}
}, true, true);
$warmer->warmUp('foo');
spl_autoload_unregister($classLoader);
}
}

View File

@@ -11,6 +11,7 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Command;
use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Bundle\FrameworkBundle\Command\CachePoolPruneCommand;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
@@ -55,7 +56,7 @@ class CachePruneCommandTest extends TestCase
}
/**
* @return \PHPUnit_Framework_MockObject_MockObject|KernelInterface
* @return MockObject|KernelInterface
*/
private function getKernel()
{
@@ -81,7 +82,7 @@ class CachePruneCommandTest extends TestCase
}
/**
* @return \PHPUnit_Framework_MockObject_MockObject|PruneableInterface
* @return MockObject|PruneableInterface
*/
private function getPruneableInterfaceMock()
{

View File

@@ -27,7 +27,7 @@ class RouterDebugCommandTest extends TestCase
$ret = $tester->execute(['name' => null], ['decorated' => false]);
$this->assertEquals(0, $ret, 'Returns 0 in case of success');
$this->assertContains('Name Method Scheme Host Path', $tester->getDisplay());
$this->assertStringContainsString('Name Method Scheme Host Path', $tester->getDisplay());
}
public function testDebugSingleRoute()
@@ -36,14 +36,12 @@ class RouterDebugCommandTest extends TestCase
$ret = $tester->execute(['name' => 'foo'], ['decorated' => false]);
$this->assertEquals(0, $ret, 'Returns 0 in case of success');
$this->assertContains('Route Name | foo', $tester->getDisplay());
$this->assertStringContainsString('Route Name | foo', $tester->getDisplay());
}
/**
* @expectedException \InvalidArgumentException
*/
public function testDebugInvalidRoute()
{
$this->expectException('InvalidArgumentException');
$this->createCommandTester()->execute(['name' => 'test']);
}

View File

@@ -29,7 +29,7 @@ class RouterMatchCommandTest extends TestCase
$ret = $tester->execute(['path_info' => '/foo', 'foo'], ['decorated' => false]);
$this->assertEquals(0, $ret, 'Returns 0 in case of success');
$this->assertContains('Route Name | foo', $tester->getDisplay());
$this->assertStringContainsString('Route Name | foo', $tester->getDisplay());
}
public function testWithNotMatchPath()
@@ -38,7 +38,7 @@ class RouterMatchCommandTest extends TestCase
$ret = $tester->execute(['path_info' => '/test', 'foo'], ['decorated' => false]);
$this->assertEquals(1, $ret, 'Returns 1 in case of failure');
$this->assertContains('None of the routes match the path "/test"', $tester->getDisplay());
$this->assertStringContainsString('None of the routes match the path "/test"', $tester->getDisplay());
}
/**
@@ -56,7 +56,7 @@ class RouterMatchCommandTest extends TestCase
$tester->execute(['path_info' => '/']);
$this->assertContains('None of the routes match the path "/"', $tester->getDisplay());
$this->assertStringContainsString('None of the routes match the path "/"', $tester->getDisplay());
}
/**

View File

@@ -94,11 +94,9 @@ class TranslationDebugCommandTest extends TestCase
$this->assertRegExp('/unused/', $tester->getDisplay());
}
/**
* @expectedException \InvalidArgumentException
*/
public function testDebugInvalidDirectory()
{
$this->expectException('InvalidArgumentException');
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
$kernel->expects($this->once())
->method('getBundle')
@@ -241,7 +239,7 @@ class TranslationDebugCommandTest extends TestCase
$tester = new CommandTester($application->find('debug:translation'));
$tester->execute(['locale' => 'en']);
$this->assertContains('No defined or extracted', $tester->getDisplay());
$this->assertStringContainsString('No defined or extracted', $tester->getDisplay());
}
private function getBundle($path)

View File

@@ -231,7 +231,7 @@ class TranslationUpdateCommandTest extends TestCase
$tester = new CommandTester($application->find('translation:update'));
$tester->execute(['locale' => 'en']);
$this->assertContains('You must choose one of --force or --dump-messages', $tester->getDisplay());
$this->assertStringContainsString('You must choose one of --force or --dump-messages', $tester->getDisplay());
}
private function getBundle($path)

View File

@@ -41,7 +41,7 @@ class YamlLintCommandTest extends TestCase
);
$this->assertEquals(0, $tester->getStatusCode(), 'Returns 0 in case of success');
$this->assertContains('OK', trim($tester->getDisplay()));
$this->assertStringContainsString('OK', trim($tester->getDisplay()));
}
public function testLintIncorrectFile()
@@ -55,14 +55,12 @@ bar';
$tester->execute(['filename' => $filename], ['decorated' => false]);
$this->assertEquals(1, $tester->getStatusCode(), 'Returns 1 in case of error');
$this->assertContains('Unable to parse at line 3 (near "bar").', trim($tester->getDisplay()));
$this->assertStringContainsString('Unable to parse at line 3 (near "bar").', trim($tester->getDisplay()));
}
/**
* @expectedException \RuntimeException
*/
public function testLintFileNotReadable()
{
$this->expectException('RuntimeException');
$tester = $this->createCommandTester();
$filename = $this->createFile('');
unlink($filename);
@@ -74,29 +72,12 @@ bar';
{
$command = new YamlLintCommand();
$expected = <<<EOF
The <info>%command.name%</info> command lints a YAML file and outputs to STDOUT
the first encountered syntax error.
You can validates YAML contents passed from STDIN:
<info>cat filename | php %command.full_name%</info>
You can also validate the syntax of a file:
<info>php %command.full_name% filename</info>
Or of a whole directory:
<info>php %command.full_name% dirname</info>
<info>php %command.full_name% dirname --format=json</info>
Or find all files in a bundle:
<info>php %command.full_name% @AcmeDemoBundle</info>
EOF;
$this->assertEquals($expected, $command->getHelp());
$this->assertStringContainsString($expected, $command->getHelp());
}
public function testLintFilesFromBundleDirectory()
@@ -108,7 +89,7 @@ EOF;
);
$this->assertEquals(0, $tester->getStatusCode(), 'Returns 0 in case of success');
$this->assertContains('[OK] All 0 YAML files contain valid syntax', trim($tester->getDisplay()));
$this->assertStringContainsString('[OK] All 0 YAML files contain valid syntax', trim($tester->getDisplay()));
}
/**

View File

@@ -160,9 +160,9 @@ class ApplicationTest extends TestCase
$output = $tester->getDisplay();
$this->assertSame(0, $tester->getStatusCode());
$this->assertContains('Some commands could not be registered:', $output);
$this->assertContains('throwing', $output);
$this->assertContains('fine', $output);
$this->assertStringContainsString('Some commands could not be registered:', $output);
$this->assertStringContainsString('throwing', $output);
$this->assertStringContainsString('fine', $output);
}
public function testRegistrationErrorsAreDisplayedOnCommandNotFound()
@@ -188,8 +188,8 @@ class ApplicationTest extends TestCase
$output = $tester->getDisplay();
$this->assertSame(1, $tester->getStatusCode());
$this->assertContains('Some commands could not be registered:', $output);
$this->assertContains('Command "fine" is not defined.', $output);
$this->assertStringContainsString('Some commands could not be registered:', $output);
$this->assertStringContainsString('Command "fine" is not defined.', $output);
}
private function getKernel(array $bundles, $useDispatcher = false)

View File

@@ -127,9 +127,9 @@ class ControllerNameParserTest extends TestCase
if (false === $suggestedBundleName) {
// make sure we don't have a suggestion
$this->assertNotContains('Did you mean', $e->getMessage());
$this->assertStringNotContainsString('Did you mean', $e->getMessage());
} else {
$this->assertContains(sprintf('Did you mean "%s"', $suggestedBundleName), $e->getMessage());
$this->assertStringContainsString(sprintf('Did you mean "%s"', $suggestedBundleName), $e->getMessage());
}
}
}

View File

@@ -87,12 +87,10 @@ abstract class ControllerTraitTest extends TestCase
$this->assertNull($controller->getUser());
}
/**
* @expectedException \LogicException
* @expectedExceptionMessage The SecurityBundle is not registered in your application.
*/
public function testGetUserWithEmptyContainer()
{
$this->expectException('LogicException');
$this->expectExceptionMessage('The SecurityBundle is not registered in your application.');
$controller = $this->createController();
$controller->setContainer(new Container());
@@ -188,8 +186,8 @@ abstract class ControllerTraitTest extends TestCase
if ($response->headers->get('content-type')) {
$this->assertSame('text/x-php', $response->headers->get('content-type'));
}
$this->assertContains(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $response->headers->get('content-disposition'));
$this->assertContains(basename(__FILE__), $response->headers->get('content-disposition'));
$this->assertStringContainsString(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $response->headers->get('content-disposition'));
$this->assertStringContainsString(basename(__FILE__), $response->headers->get('content-disposition'));
}
public function testFileAsInline()
@@ -204,8 +202,8 @@ abstract class ControllerTraitTest extends TestCase
if ($response->headers->get('content-type')) {
$this->assertSame('text/x-php', $response->headers->get('content-type'));
}
$this->assertContains(ResponseHeaderBag::DISPOSITION_INLINE, $response->headers->get('content-disposition'));
$this->assertContains(basename(__FILE__), $response->headers->get('content-disposition'));
$this->assertStringContainsString(ResponseHeaderBag::DISPOSITION_INLINE, $response->headers->get('content-disposition'));
$this->assertStringContainsString(basename(__FILE__), $response->headers->get('content-disposition'));
}
public function testFileWithOwnFileName()
@@ -221,8 +219,8 @@ abstract class ControllerTraitTest extends TestCase
if ($response->headers->get('content-type')) {
$this->assertSame('text/x-php', $response->headers->get('content-type'));
}
$this->assertContains(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $response->headers->get('content-disposition'));
$this->assertContains($fileName, $response->headers->get('content-disposition'));
$this->assertStringContainsString(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $response->headers->get('content-disposition'));
$this->assertStringContainsString($fileName, $response->headers->get('content-disposition'));
}
public function testFileWithOwnFileNameAsInline()
@@ -238,8 +236,8 @@ abstract class ControllerTraitTest extends TestCase
if ($response->headers->get('content-type')) {
$this->assertSame('text/x-php', $response->headers->get('content-type'));
}
$this->assertContains(ResponseHeaderBag::DISPOSITION_INLINE, $response->headers->get('content-disposition'));
$this->assertContains($fileName, $response->headers->get('content-disposition'));
$this->assertStringContainsString(ResponseHeaderBag::DISPOSITION_INLINE, $response->headers->get('content-disposition'));
$this->assertStringContainsString($fileName, $response->headers->get('content-disposition'));
}
public function testFileFromPath()
@@ -254,8 +252,8 @@ abstract class ControllerTraitTest extends TestCase
if ($response->headers->get('content-type')) {
$this->assertSame('text/x-php', $response->headers->get('content-type'));
}
$this->assertContains(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $response->headers->get('content-disposition'));
$this->assertContains(basename(__FILE__), $response->headers->get('content-disposition'));
$this->assertStringContainsString(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $response->headers->get('content-disposition'));
$this->assertStringContainsString(basename(__FILE__), $response->headers->get('content-disposition'));
}
public function testFileFromPathWithCustomizedFileName()
@@ -270,19 +268,16 @@ abstract class ControllerTraitTest extends TestCase
if ($response->headers->get('content-type')) {
$this->assertSame('text/x-php', $response->headers->get('content-type'));
}
$this->assertContains(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $response->headers->get('content-disposition'));
$this->assertContains('test.php', $response->headers->get('content-disposition'));
$this->assertStringContainsString(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $response->headers->get('content-disposition'));
$this->assertStringContainsString('test.php', $response->headers->get('content-disposition'));
}
/**
* @expectedException \Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException
*/
public function testFileWhichDoesNotExist()
{
$this->expectException('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException');
$controller = $this->createController();
/* @var BinaryFileResponse $response */
$response = $controller->file('some-file.txt', 'test.php');
$controller->file('some-file.txt', 'test.php');
}
public function testIsGranted()
@@ -299,11 +294,9 @@ abstract class ControllerTraitTest extends TestCase
$this->assertTrue($controller->isGranted('foo'));
}
/**
* @expectedException \Symfony\Component\Security\Core\Exception\AccessDeniedException
*/
public function testdenyAccessUnlessGranted()
{
$this->expectException('Symfony\Component\Security\Core\Exception\AccessDeniedException');
$authorizationChecker = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface')->getMock();
$authorizationChecker->expects($this->once())->method('isGranted')->willReturn(false);
@@ -431,10 +424,10 @@ abstract class ControllerTraitTest extends TestCase
public function testRedirect()
{
$controller = $this->createController();
$response = $controller->redirect('http://dunglas.fr', 301);
$response = $controller->redirect('https://dunglas.fr', 301);
$this->assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $response);
$this->assertSame('http://dunglas.fr', $response->getTargetUrl());
$this->assertSame('https://dunglas.fr', $response->getTargetUrl());
$this->assertSame(301, $response->getStatusCode());
}

View File

@@ -77,12 +77,10 @@ class TemplateControllerTest extends TestCase
$this->assertEquals('bar', $controller->templateAction('mytemplate')->getContent());
}
/**
* @expectedException \LogicException
* @expectedExceptionMessage You can not use the TemplateController if the Templating Component or the Twig Bundle are not available.
*/
public function testNoTwigNorTemplating()
{
$this->expectException('LogicException');
$this->expectExceptionMessage('You can not use the TemplateController if the Templating Component or the Twig Bundle are not available.');
$controller = new TemplateController();
$controller->templateAction('mytemplate')->getContent();

View File

@@ -63,12 +63,10 @@ class AddConsoleCommandPassTest extends TestCase
];
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The service "my-command" tagged "console.command" must not be abstract.
*/
public function testProcessThrowAnExceptionIfTheServiceIsAbstract()
{
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage('The service "my-command" tagged "console.command" must not be abstract.');
$container = new ContainerBuilder();
$container->addCompilerPass(new AddConsoleCommandPass());
@@ -80,12 +78,10 @@ class AddConsoleCommandPassTest extends TestCase
$container->compile();
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The service "my-command" tagged "console.command" must be a subclass of "Symfony\Component\Console\Command\Command".
*/
public function testProcessThrowAnExceptionIfTheServiceIsNotASubclassOfCommand()
{
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage('The service "my-command" tagged "console.command" must be a subclass of "Symfony\Component\Console\Command\Command".');
$container = new ContainerBuilder();
$container->addCompilerPass(new AddConsoleCommandPass());

View File

@@ -46,14 +46,12 @@ class AddConstraintValidatorsPassTest extends TestCase
$this->assertEquals($expected, $container->getDefinition((string) $validatorFactory->getArgument(0)));
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The service "my_abstract_constraint_validator" tagged "validator.constraint_validator" must not be abstract.
*/
public function testAbstractConstraintValidator()
{
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage('The service "my_abstract_constraint_validator" tagged "validator.constraint_validator" must not be abstract.');
$container = new ContainerBuilder();
$validatorFactory = $container->register('validator.validator_factory')
$container->register('validator.validator_factory')
->addArgument([]);
$container->register('my_abstract_constraint_validator')

View File

@@ -93,12 +93,10 @@ class CachePoolPassTest extends TestCase
$this->assertSame(3, $cachePool->getArgument(2));
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Invalid "cache.pool" tag for service "app.cache_pool": accepted attributes are
*/
public function testThrowsExceptionWhenCachePoolTagHasUnknownAttributes()
{
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage('Invalid "cache.pool" tag for service "app.cache_pool": accepted attributes are');
$container = new ContainerBuilder();
$container->setParameter('kernel.debug', false);
$container->setParameter('kernel.name', 'app');

View File

@@ -56,12 +56,10 @@ class CachePoolPrunerPassTest extends TestCase
$this->assertCount($aliasesBefore, $container->getAliases());
}
/**
* @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
* @expectedExceptionMessage Class "Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\NotFound" used for service "pool.not-found" cannot be found.
*/
public function testCompilerPassThrowsOnInvalidDefinitionClass()
{
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
$this->expectExceptionMessage('Class "Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\NotFound" used for service "pool.not-found" cannot be found.');
$container = new ContainerBuilder();
$container->register('console.command.cache_pool_prune')->addArgument([]);
$container->register('pool.not-found', NotFound::class)->addTag('cache.pool');

View File

@@ -124,12 +124,10 @@ class FormPassTest extends TestCase
];
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage extended-type attribute, none was configured for the "my.type_extension" service
*/
public function testAddTaggedFormTypeExtensionWithoutExtendedTypeAttribute()
{
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage('extended-type attribute, none was configured for the "my.type_extension" service');
$container = new ContainerBuilder();
$container->addCompilerPass(new FormPass());

View File

@@ -24,11 +24,10 @@ class ProfilerPassTest extends TestCase
* Thus, a fully-valid tag looks something like this:
*
* <tag name="data_collector" template="YourBundle:Collector:templatename" id="your_collector_name" />
*
* @expectedException \InvalidArgumentException
*/
public function testTemplateNoIdThrowsException()
{
$this->expectException('InvalidArgumentException');
$builder = new ContainerBuilder();
$builder->register('profiler', 'ProfilerClass');
$builder->register('my_collector_service')

View File

@@ -25,12 +25,10 @@ use Symfony\Component\DependencyInjection\Reference;
*/
class SerializerPassTest extends TestCase
{
/**
* @expectedException \RuntimeException
* @expectedExceptionMessage You must tag at least one service as "serializer.normalizer" to use the "serializer" service
*/
public function testThrowExceptionWhenNoNormalizers()
{
$this->expectException('RuntimeException');
$this->expectExceptionMessage('You must tag at least one service as "serializer.normalizer" to use the "serializer" service');
$container = new ContainerBuilder();
$container->register('serializer');
@@ -38,12 +36,10 @@ class SerializerPassTest extends TestCase
$serializerPass->process($container);
}
/**
* @expectedException \RuntimeException
* @expectedExceptionMessage You must tag at least one service as "serializer.encoder" to use the "serializer" service
*/
public function testThrowExceptionWhenNoEncoders()
{
$this->expectException('RuntimeException');
$this->expectExceptionMessage('You must tag at least one service as "serializer.encoder" to use the "serializer" service');
$container = new ContainerBuilder();
$container->register('serializer')
->addArgument([])

View File

@@ -52,12 +52,10 @@ class WorkflowGuardListenerPassTest extends TestCase
$this->assertFalse($this->container->hasParameter('workflow.has_guard_listeners'));
}
/**
* @expectedException \Symfony\Component\DependencyInjection\Exception\LogicException
* @expectedExceptionMessage The "security.token_storage" service is needed to be able to use the workflow guard listener.
*/
public function testExceptionIfTheTokenStorageServiceIsNotPresent()
{
$this->expectException('Symfony\Component\DependencyInjection\Exception\LogicException');
$this->expectExceptionMessage('The "security.token_storage" service is needed to be able to use the workflow guard listener.');
$this->container->setParameter('workflow.has_guard_listeners', true);
$this->container->register('security.authorization_checker', AuthorizationCheckerInterface::class);
$this->container->register('security.authentication.trust_resolver', AuthenticationTrustResolverInterface::class);
@@ -66,12 +64,10 @@ class WorkflowGuardListenerPassTest extends TestCase
$this->compilerPass->process($this->container);
}
/**
* @expectedException \Symfony\Component\DependencyInjection\Exception\LogicException
* @expectedExceptionMessage The "security.authorization_checker" service is needed to be able to use the workflow guard listener.
*/
public function testExceptionIfTheAuthorizationCheckerServiceIsNotPresent()
{
$this->expectException('Symfony\Component\DependencyInjection\Exception\LogicException');
$this->expectExceptionMessage('The "security.authorization_checker" service is needed to be able to use the workflow guard listener.');
$this->container->setParameter('workflow.has_guard_listeners', true);
$this->container->register('security.token_storage', TokenStorageInterface::class);
$this->container->register('security.authentication.trust_resolver', AuthenticationTrustResolverInterface::class);
@@ -80,12 +76,10 @@ class WorkflowGuardListenerPassTest extends TestCase
$this->compilerPass->process($this->container);
}
/**
* @expectedException \Symfony\Component\DependencyInjection\Exception\LogicException
* @expectedExceptionMessage The "security.authentication.trust_resolver" service is needed to be able to use the workflow guard listener.
*/
public function testExceptionIfTheAuthenticationTrustResolverServiceIsNotPresent()
{
$this->expectException('Symfony\Component\DependencyInjection\Exception\LogicException');
$this->expectExceptionMessage('The "security.authentication.trust_resolver" service is needed to be able to use the workflow guard listener.');
$this->container->setParameter('workflow.has_guard_listeners', true);
$this->container->register('security.token_storage', TokenStorageInterface::class);
$this->container->register('security.authorization_checker', AuthorizationCheckerInterface::class);
@@ -94,12 +88,10 @@ class WorkflowGuardListenerPassTest extends TestCase
$this->compilerPass->process($this->container);
}
/**
* @expectedException \Symfony\Component\DependencyInjection\Exception\LogicException
* @expectedExceptionMessage The "security.role_hierarchy" service is needed to be able to use the workflow guard listener.
*/
public function testExceptionIfTheRoleHierarchyServiceIsNotPresent()
{
$this->expectException('Symfony\Component\DependencyInjection\Exception\LogicException');
$this->expectExceptionMessage('The "security.role_hierarchy" service is needed to be able to use the workflow guard listener.');
$this->container->setParameter('workflow.has_guard_listeners', true);
$this->container->register('security.token_storage', TokenStorageInterface::class);
$this->container->register('security.authorization_checker', AuthorizationCheckerInterface::class);

View File

@@ -104,10 +104,10 @@ class ConfigurationTest extends TestCase
/**
* @dataProvider getTestInvalidSessionName
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
*/
public function testInvalidSessionName($sessionName)
{
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException');
$processor = new Processor();
$processor->processConfiguration(
new Configuration(true),
@@ -160,10 +160,10 @@ class ConfigurationTest extends TestCase
/**
* @group legacy
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
*/
public function testInvalidTypeTrustedProxies()
{
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException');
$processor = new Processor();
$configuration = new Configuration(true);
$processor->processConfiguration($configuration, [
@@ -176,10 +176,10 @@ class ConfigurationTest extends TestCase
/**
* @group legacy
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
*/
public function testInvalidValueTrustedProxies()
{
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException');
$processor = new Processor();
$configuration = new Configuration(true);
@@ -245,12 +245,8 @@ class ConfigurationTest extends TestCase
*/
public function testInvalidAssetsConfiguration(array $assetConfig, $expectedMessage)
{
if (method_exists($this, 'expectException')) {
$this->expectException(InvalidConfigurationException::class);
$this->expectExceptionMessage($expectedMessage);
} else {
$this->setExpectedException(InvalidConfigurationException::class, $expectedMessage);
}
$this->expectException(InvalidConfigurationException::class);
$this->expectExceptionMessage($expectedMessage);
$processor = new Processor();
$configuration = new Configuration(true);
@@ -296,6 +292,69 @@ class ConfigurationTest extends TestCase
yield [$createPackageConfig($config), 'You cannot use both "version" and "json_manifest_path" at the same time under "assets" packages.'];
}
/**
* @dataProvider provideValidLockConfigurationTests
*/
public function testValidLockConfiguration($lockConfig, $processedConfig)
{
$processor = new Processor();
$configuration = new Configuration(true);
$config = $processor->processConfiguration($configuration, [
[
'lock' => $lockConfig,
],
]);
$this->assertArrayHasKey('lock', $config);
$this->assertEquals($processedConfig, $config['lock']);
}
public function provideValidLockConfigurationTests()
{
yield [null, ['enabled' => true, 'resources' => ['default' => [class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphore' : 'flock']]]];
yield ['flock', ['enabled' => true, 'resources' => ['default' => ['flock']]]];
yield [['flock', 'semaphore'], ['enabled' => true, 'resources' => ['default' => ['flock', 'semaphore']]]];
yield [['foo' => 'flock', 'bar' => 'semaphore'], ['enabled' => true, 'resources' => ['foo' => ['flock'], 'bar' => ['semaphore']]]];
yield [['foo' => ['flock', 'semaphore'], 'bar' => 'semaphore'], ['enabled' => true, 'resources' => ['foo' => ['flock', 'semaphore'], 'bar' => ['semaphore']]]];
yield [['default' => 'flock'], ['enabled' => true, 'resources' => ['default' => ['flock']]]];
yield [['enabled' => false, 'flock'], ['enabled' => false, 'resources' => ['default' => ['flock']]]];
yield [['enabled' => false, ['flock', 'semaphore']], ['enabled' => false, 'resources' => ['default' => ['flock', 'semaphore']]]];
yield [['enabled' => false, 'foo' => 'flock', 'bar' => 'semaphore'], ['enabled' => false, 'resources' => ['foo' => ['flock'], 'bar' => ['semaphore']]]];
yield [['enabled' => false, 'foo' => ['flock', 'semaphore']], ['enabled' => false, 'resources' => ['foo' => ['flock', 'semaphore']]]];
yield [['enabled' => false, 'default' => 'flock'], ['enabled' => false, 'resources' => ['default' => ['flock']]]];
yield [['resources' => 'flock'], ['enabled' => true, 'resources' => ['default' => ['flock']]]];
yield [['resources' => ['flock', 'semaphore']], ['enabled' => true, 'resources' => ['default' => ['flock', 'semaphore']]]];
yield [['resources' => ['foo' => 'flock', 'bar' => 'semaphore']], ['enabled' => true, 'resources' => ['foo' => ['flock'], 'bar' => ['semaphore']]]];
yield [['resources' => ['foo' => ['flock', 'semaphore'], 'bar' => 'semaphore']], ['enabled' => true, 'resources' => ['foo' => ['flock', 'semaphore'], 'bar' => ['semaphore']]]];
yield [['resources' => ['default' => 'flock']], ['enabled' => true, 'resources' => ['default' => ['flock']]]];
yield [['enabled' => false, 'resources' => 'flock'], ['enabled' => false, 'resources' => ['default' => ['flock']]]];
yield [['enabled' => false, 'resources' => ['flock', 'semaphore']], ['enabled' => false, 'resources' => ['default' => ['flock', 'semaphore']]]];
yield [['enabled' => false, 'resources' => ['foo' => 'flock', 'bar' => 'semaphore']], ['enabled' => false, 'resources' => ['foo' => ['flock'], 'bar' => ['semaphore']]]];
yield [['enabled' => false, 'resources' => ['foo' => ['flock', 'semaphore'], 'bar' => 'semaphore']], ['enabled' => false, 'resources' => ['foo' => ['flock', 'semaphore'], 'bar' => ['semaphore']]]];
yield [['enabled' => false, 'resources' => ['default' => 'flock']], ['enabled' => false, 'resources' => ['default' => ['flock']]]];
// xml
yield [['resource' => ['flock']], ['enabled' => true, 'resources' => ['default' => ['flock']]]];
yield [['resource' => ['flock', ['name' => 'foo', 'value' => 'semaphore']]], ['enabled' => true, 'resources' => ['default' => ['flock'], 'foo' => ['semaphore']]]];
yield [['resource' => [['name' => 'foo', 'value' => 'flock']]], ['enabled' => true, 'resources' => ['foo' => ['flock']]]];
yield [['resource' => [['name' => 'foo', 'value' => 'flock'], ['name' => 'foo', 'value' => 'semaphore']]], ['enabled' => true, 'resources' => ['foo' => ['flock', 'semaphore']]]];
yield [['resource' => [['name' => 'foo', 'value' => 'flock'], ['name' => 'bar', 'value' => 'semaphore']]], ['enabled' => true, 'resources' => ['foo' => ['flock'], 'bar' => ['semaphore']]]];
yield [['resource' => [['name' => 'foo', 'value' => 'flock'], ['name' => 'foo', 'value' => 'semaphore'], ['name' => 'bar', 'value' => 'semaphore']]], ['enabled' => true, 'resources' => ['foo' => ['flock', 'semaphore'], 'bar' => ['semaphore']]]];
yield [['enabled' => false, 'resource' => ['flock']], ['enabled' => false, 'resources' => ['default' => ['flock']]]];
yield [['enabled' => false, 'resource' => ['flock', ['name' => 'foo', 'value' => 'semaphore']]], ['enabled' => false, 'resources' => ['default' => ['flock'], 'foo' => ['semaphore']]]];
yield [['enabled' => false, 'resource' => [['name' => 'foo', 'value' => 'flock']]], ['enabled' => false, 'resources' => ['foo' => ['flock']]]];
yield [['enabled' => false, 'resource' => [['name' => 'foo', 'value' => 'flock'], ['name' => 'foo', 'value' => 'semaphore']]], ['enabled' => false, 'resources' => ['foo' => ['flock', 'semaphore']]]];
yield [['enabled' => false, 'resource' => [['name' => 'foo', 'value' => 'flock'], ['name' => 'bar', 'value' => 'semaphore']]], ['enabled' => false, 'resources' => ['foo' => ['flock'], 'bar' => ['semaphore']]]];
yield [['enabled' => false, 'resource' => [['name' => 'foo', 'value' => 'flock'], ['name' => 'foo', 'value' => 'semaphore'], ['name' => 'bar', 'value' => 'semaphore']]], ['enabled' => false, 'resources' => ['foo' => ['flock', 'semaphore'], 'bar' => ['semaphore']]]];
}
protected static function getBundleDefaultConfig()
{
return [
@@ -378,6 +437,7 @@ class ConfigurationTest extends TestCase
'handler_id' => 'session.handler.native_file',
'cookie_httponly' => true,
'gc_probability' => 1,
'save_path' => '%kernel.cache_dir%/sessions',
'metadata_update_threshold' => '0',
'use_strict_mode' => true,
],

View File

@@ -1,8 +0,0 @@
<?php
$container->loadFromExtension('framework', [
'session' => [
'handler_id' => null,
'save_path' => '/some/path',
],
]);

View File

@@ -1,12 +0,0 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
<framework:config>
<framework:session handler-id="null" save-path="/some/path"/>
</framework:config>
</container>

View File

@@ -1,4 +0,0 @@
framework:
session:
handler_id: null
save_path: /some/path

View File

@@ -85,7 +85,9 @@ abstract class FrameworkExtensionTest extends TestCase
$container = $this->createContainerFromFile('property_accessor');
if (!method_exists(PropertyAccessor::class, 'createCache')) {
return $this->assertFalse($container->hasDefinition('cache.property_access'));
$this->assertFalse($container->hasDefinition('cache.property_access'));
return;
}
$cache = $container->getDefinition('cache.property_access');
@@ -98,7 +100,9 @@ abstract class FrameworkExtensionTest extends TestCase
$container = $this->createContainerFromFile('property_accessor', ['kernel.debug' => true]);
if (!method_exists(PropertyAccessor::class, 'createCache')) {
return $this->assertFalse($container->hasDefinition('cache.property_access'));
$this->assertFalse($container->hasDefinition('cache.property_access'));
return;
}
$cache = $container->getDefinition('cache.property_access');
@@ -106,12 +110,10 @@ abstract class FrameworkExtensionTest extends TestCase
$this->assertSame(ArrayAdapter::class, $cache->getClass(), 'ArrayAdapter should be used in debug mode');
}
/**
* @expectedException \LogicException
* @expectedExceptionMessage CSRF protection needs sessions to be enabled.
*/
public function testCsrfProtectionNeedsSessionToBeEnabled()
{
$this->expectException('LogicException');
$this->expectExceptionMessage('CSRF protection needs sessions to be enabled.');
$this->createContainerFromFile('csrf_needs_session');
}
@@ -249,42 +251,34 @@ abstract class FrameworkExtensionTest extends TestCase
*/
public function testDeprecatedWorkflowMissingType()
{
$container = $this->createContainerFromFile('workflows_without_type');
$this->createContainerFromFile('workflows_without_type');
}
/**
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
* @expectedExceptionMessage "type" and "service" cannot be used together.
*/
public function testWorkflowCannotHaveBothTypeAndService()
{
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException');
$this->expectExceptionMessage('"type" and "service" cannot be used together.');
$this->createContainerFromFile('workflow_with_type_and_service');
}
/**
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
* @expectedExceptionMessage "supports" and "support_strategy" cannot be used together.
*/
public function testWorkflowCannotHaveBothSupportsAndSupportStrategy()
{
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException');
$this->expectExceptionMessage('"supports" and "support_strategy" cannot be used together.');
$this->createContainerFromFile('workflow_with_support_and_support_strategy');
}
/**
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
* @expectedExceptionMessage "supports" or "support_strategy" should be configured.
*/
public function testWorkflowShouldHaveOneOfSupportsAndSupportStrategy()
{
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException');
$this->expectExceptionMessage('"supports" or "support_strategy" should be configured.');
$this->createContainerFromFile('workflow_without_support_and_support_strategy');
}
/**
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
* @expectedExceptionMessage "arguments" and "service" cannot be used together.
*/
public function testWorkflowCannotHaveBothArgumentsAndService()
{
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException');
$this->expectExceptionMessage('"arguments" and "service" cannot be used together.');
$this->createContainerFromFile('workflow_with_arguments_and_service');
}
@@ -430,11 +424,9 @@ abstract class FrameworkExtensionTest extends TestCase
$this->assertEquals('xml', $arguments[2]['resource_type'], '->registerRouterConfiguration() sets routing resource type');
}
/**
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
*/
public function testRouterRequiresResourceOption()
{
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException');
$container = $this->createContainer();
$loader = new FrameworkExtension();
$loader->load([['router' => true]], $container);
@@ -473,14 +465,6 @@ abstract class FrameworkExtensionTest extends TestCase
$this->assertNull($container->getDefinition('session.storage.php_bridge')->getArgument(0));
}
/**
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
*/
public function testNullSessionHandlerWithSavePath()
{
$this->createContainerFromFile('session_savepath');
}
public function testRequest()
{
$container = $this->createContainerFromFile('full');
@@ -645,11 +629,9 @@ abstract class FrameworkExtensionTest extends TestCase
$this->assertFalse($container->has('templating.helper.translator'));
}
/**
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
*/
public function testTemplatingRequiresAtLeastOneEngine()
{
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException');
$container = $this->createContainer();
$loader = new FrameworkExtension();
$loader->load([['templating' => null]], $container);
@@ -840,9 +822,9 @@ abstract class FrameworkExtensionTest extends TestCase
$this->assertSame('addYamlMappings', $calls[4][0]);
$this->assertCount(3, $calls[4][1][0]);
$this->assertContains('foo.yml', $calls[4][1][0][0]);
$this->assertContains('validation.yml', $calls[4][1][0][1]);
$this->assertContains('validation.yaml', $calls[4][1][0][2]);
$this->assertStringContainsString('foo.yml', $calls[4][1][0][0]);
$this->assertStringContainsString('validation.yml', $calls[4][1][0][1]);
$this->assertStringContainsString('validation.yaml', $calls[4][1][0][2]);
}
public function testFormsCanBeEnabledWithoutCsrfProtection()

View File

@@ -23,11 +23,9 @@ class PhpFrameworkExtensionTest extends FrameworkExtensionTest
$loader->load($file.'.php');
}
/**
* @expectedException \LogicException
*/
public function testAssetsCannotHavePathAndUrl()
{
$this->expectException('LogicException');
$this->createContainerFromClosure(function ($container) {
$container->loadFromExtension('framework', [
'assets' => [
@@ -38,11 +36,9 @@ class PhpFrameworkExtensionTest extends FrameworkExtensionTest
});
}
/**
* @expectedException \LogicException
*/
public function testAssetPackageCannotHavePathAndUrl()
{
$this->expectException('LogicException');
$this->createContainerFromClosure(function ($container) {
$container->loadFromExtension('framework', [
'assets' => [

View File

@@ -26,7 +26,7 @@ class TestExtension extends Extension implements PrependExtensionInterface
public function load(array $configs, ContainerBuilder $container)
{
$configuration = $this->getConfiguration($configs, $container);
$config = $this->processConfiguration($configuration, $configs);
$this->processConfiguration($configuration, $configs);
$container->setAlias('test.annotation_reader', new Alias('annotation_reader', true));
}

View File

@@ -31,8 +31,8 @@ class CachePoolClearCommandTest extends AbstractWebTestCase
$tester->execute(['pools' => ['cache.private_pool']], ['decorated' => false]);
$this->assertSame(0, $tester->getStatusCode(), 'cache:pool:clear exits with 0 in case of success');
$this->assertContains('Clearing cache pool: cache.private_pool', $tester->getDisplay());
$this->assertContains('[OK] Cache was successfully cleared.', $tester->getDisplay());
$this->assertStringContainsString('Clearing cache pool: cache.private_pool', $tester->getDisplay());
$this->assertStringContainsString('[OK] Cache was successfully cleared.', $tester->getDisplay());
}
public function testClearPublicPool()
@@ -41,8 +41,8 @@ class CachePoolClearCommandTest extends AbstractWebTestCase
$tester->execute(['pools' => ['cache.public_pool']], ['decorated' => false]);
$this->assertSame(0, $tester->getStatusCode(), 'cache:pool:clear exits with 0 in case of success');
$this->assertContains('Clearing cache pool: cache.public_pool', $tester->getDisplay());
$this->assertContains('[OK] Cache was successfully cleared.', $tester->getDisplay());
$this->assertStringContainsString('Clearing cache pool: cache.public_pool', $tester->getDisplay());
$this->assertStringContainsString('[OK] Cache was successfully cleared.', $tester->getDisplay());
}
public function testClearPoolWithCustomClearer()
@@ -51,8 +51,8 @@ class CachePoolClearCommandTest extends AbstractWebTestCase
$tester->execute(['pools' => ['cache.pool_with_clearer']], ['decorated' => false]);
$this->assertSame(0, $tester->getStatusCode(), 'cache:pool:clear exits with 0 in case of success');
$this->assertContains('Clearing cache pool: cache.pool_with_clearer', $tester->getDisplay());
$this->assertContains('[OK] Cache was successfully cleared.', $tester->getDisplay());
$this->assertStringContainsString('Clearing cache pool: cache.pool_with_clearer', $tester->getDisplay());
$this->assertStringContainsString('[OK] Cache was successfully cleared.', $tester->getDisplay());
}
public function testCallClearer()
@@ -61,16 +61,14 @@ class CachePoolClearCommandTest extends AbstractWebTestCase
$tester->execute(['pools' => ['cache.app_clearer']], ['decorated' => false]);
$this->assertSame(0, $tester->getStatusCode(), 'cache:pool:clear exits with 0 in case of success');
$this->assertContains('Calling cache clearer: cache.app_clearer', $tester->getDisplay());
$this->assertContains('[OK] Cache was successfully cleared.', $tester->getDisplay());
$this->assertStringContainsString('Calling cache clearer: cache.app_clearer', $tester->getDisplay());
$this->assertStringContainsString('[OK] Cache was successfully cleared.', $tester->getDisplay());
}
/**
* @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException
* @expectedExceptionMessage You have requested a non-existent service "unknown_pool"
*/
public function testClearUnexistingPool()
{
$this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException');
$this->expectExceptionMessage('You have requested a non-existent service "unknown_pool"');
$this->createCommandTester()
->execute(['pools' => ['unknown_pool']], ['decorated' => false]);
}
@@ -88,7 +86,7 @@ class CachePoolClearCommandTest extends AbstractWebTestCase
$tester->execute(['pools' => []]);
$this->assertContains('Cache was successfully cleared', $tester->getDisplay());
$this->assertStringContainsString('Cache was successfully cleared', $tester->getDisplay());
}
private function createCommandTester()

View File

@@ -34,7 +34,7 @@ class CachePoolsTest extends AbstractWebTestCase
throw $e;
}
$this->markTestSkipped($e->getMessage());
} catch (\PHPUnit_Framework_Error_Warning $e) {
} catch (\PHPUnit\Framework\Error\Warning $e) {
if (0 !== strpos($e->getMessage(), 'unable to connect to')) {
throw $e;
}
@@ -59,7 +59,7 @@ class CachePoolsTest extends AbstractWebTestCase
throw $e;
}
$this->markTestSkipped($e->getMessage());
} catch (\PHPUnit_Framework_Error_Warning $e) {
} catch (\PHPUnit\Framework\Error\Warning $e) {
if (0 !== strpos($e->getMessage(), 'unable to connect to')) {
throw $e;
}

View File

@@ -36,7 +36,7 @@ class ConfigDebugCommandTest extends AbstractWebTestCase
$ret = $tester->execute(['name' => 'TestBundle']);
$this->assertSame(0, $ret, 'Returns 0 in case of success');
$this->assertContains('custom: foo', $tester->getDisplay());
$this->assertStringContainsString('custom: foo', $tester->getDisplay());
}
public function testDumpBundleOption()
@@ -45,7 +45,7 @@ class ConfigDebugCommandTest extends AbstractWebTestCase
$ret = $tester->execute(['name' => 'TestBundle', 'path' => 'custom']);
$this->assertSame(0, $ret, 'Returns 0 in case of success');
$this->assertContains('foo', $tester->getDisplay());
$this->assertStringContainsString('foo', $tester->getDisplay());
}
public function testParametersValuesAreResolved()
@@ -54,8 +54,8 @@ class ConfigDebugCommandTest extends AbstractWebTestCase
$ret = $tester->execute(['name' => 'framework']);
$this->assertSame(0, $ret, 'Returns 0 in case of success');
$this->assertContains("locale: '%env(LOCALE)%'", $tester->getDisplay());
$this->assertContains('secret: test', $tester->getDisplay());
$this->assertStringContainsString("locale: '%env(LOCALE)%'", $tester->getDisplay());
$this->assertStringContainsString('secret: test', $tester->getDisplay());
}
public function testDumpUndefinedBundleOption()
@@ -63,7 +63,7 @@ class ConfigDebugCommandTest extends AbstractWebTestCase
$tester = $this->createCommandTester();
$tester->execute(['name' => 'TestBundle', 'path' => 'foo']);
$this->assertContains('Unable to find configuration for "test.foo"', $tester->getDisplay());
$this->assertStringContainsString('Unable to find configuration for "test.foo"', $tester->getDisplay());
}
/**

View File

@@ -36,8 +36,8 @@ class ConfigDumpReferenceCommandTest extends AbstractWebTestCase
$ret = $tester->execute(['name' => 'TestBundle']);
$this->assertSame(0, $ret, 'Returns 0 in case of success');
$this->assertContains('test:', $tester->getDisplay());
$this->assertContains(' custom:', $tester->getDisplay());
$this->assertStringContainsString('test:', $tester->getDisplay());
$this->assertStringContainsString(' custom:', $tester->getDisplay());
}
public function testDumpAtPath()
@@ -70,7 +70,7 @@ EOL
]);
$this->assertSame(1, $ret);
$this->assertContains('[ERROR] The "path" option is only available for the "yaml" format.', $tester->getDisplay());
$this->assertStringContainsString('[ERROR] The "path" option is only available for the "yaml" format.', $tester->getDisplay());
}
/**

View File

@@ -44,7 +44,7 @@ class ContainerDebugCommandTest extends AbstractWebTestCase
$tester = new ApplicationTester($application);
$tester->run(['command' => 'debug:container']);
$this->assertContains('public', $tester->getDisplay());
$this->assertStringContainsString('public', $tester->getDisplay());
}
public function testPrivateAlias()
@@ -56,11 +56,11 @@ class ContainerDebugCommandTest extends AbstractWebTestCase
$tester = new ApplicationTester($application);
$tester->run(['command' => 'debug:container', '--show-private' => true]);
$this->assertContains('public', $tester->getDisplay());
$this->assertContains('private_alias', $tester->getDisplay());
$this->assertStringContainsString('public', $tester->getDisplay());
$this->assertStringContainsString('private_alias', $tester->getDisplay());
$tester->run(['command' => 'debug:container']);
$this->assertContains('public', $tester->getDisplay());
$this->assertNotContains('private_alias', $tester->getDisplay());
$this->assertStringContainsString('public', $tester->getDisplay());
$this->assertStringNotContainsString('private_alias', $tester->getDisplay());
}
}

View File

@@ -29,8 +29,8 @@ class DebugAutowiringCommandTest extends AbstractWebTestCase
$tester = new ApplicationTester($application);
$tester->run(['command' => 'debug:autowiring']);
$this->assertContains('Symfony\Component\HttpKernel\HttpKernelInterface', $tester->getDisplay());
$this->assertContains('alias to http_kernel', $tester->getDisplay());
$this->assertStringContainsString('Symfony\Component\HttpKernel\HttpKernelInterface', $tester->getDisplay());
$this->assertStringContainsString('alias to http_kernel', $tester->getDisplay());
}
public function testSearchArgument()
@@ -43,8 +43,8 @@ class DebugAutowiringCommandTest extends AbstractWebTestCase
$tester = new ApplicationTester($application);
$tester->run(['command' => 'debug:autowiring', 'search' => 'kern']);
$this->assertContains('Symfony\Component\HttpKernel\HttpKernelInterface', $tester->getDisplay());
$this->assertNotContains('Symfony\Component\Routing\RouterInterface', $tester->getDisplay());
$this->assertStringContainsString('Symfony\Component\HttpKernel\HttpKernelInterface', $tester->getDisplay());
$this->assertStringNotContainsString('Symfony\Component\Routing\RouterInterface', $tester->getDisplay());
}
public function testSearchNoResults()
@@ -57,7 +57,7 @@ class DebugAutowiringCommandTest extends AbstractWebTestCase
$tester = new ApplicationTester($application);
$tester->run(['command' => 'debug:autowiring', 'search' => 'foo_fake'], ['capture_stderr_separately' => true]);
$this->assertContains('No autowirable classes or interfaces found matching "foo_fake"', $tester->getErrorOutput());
$this->assertStringContainsString('No autowirable classes or interfaces found matching "foo_fake"', $tester->getErrorOutput());
$this->assertEquals(1, $tester->getStatusCode());
}
}

View File

@@ -24,16 +24,16 @@ class ProfilerTest extends AbstractWebTestCase
}
$client->request('GET', '/profiler');
$this->assertFalse($client->getProfile());
$this->assertNull($client->getProfile());
// enable the profiler for the next request
$client->enableProfiler();
$this->assertFalse($client->getProfile());
$this->assertNull($client->getProfile());
$client->request('GET', '/profiler');
$this->assertInternalType('object', $client->getProfile());
$this->assertIsObject($client->getProfile());
$client->request('GET', '/profiler');
$this->assertFalse($client->getProfile());
$this->assertNull($client->getProfile());
}
public function getConfigs()

View File

@@ -27,23 +27,23 @@ class SessionTest extends AbstractWebTestCase
// no session
$crawler = $client->request('GET', '/session');
$this->assertContains('You are new here and gave no name.', $crawler->text());
$this->assertStringContainsString('You are new here and gave no name.', $crawler->text());
// remember name
$crawler = $client->request('GET', '/session/drak');
$this->assertContains('Hello drak, nice to meet you.', $crawler->text());
$this->assertStringContainsString('Hello drak, nice to meet you.', $crawler->text());
// prove remembered name
$crawler = $client->request('GET', '/session');
$this->assertContains('Welcome back drak, nice to meet you.', $crawler->text());
$this->assertStringContainsString('Welcome back drak, nice to meet you.', $crawler->text());
// clear session
$crawler = $client->request('GET', '/session_logout');
$this->assertContains('Session cleared.', $crawler->text());
$this->assertStringContainsString('Session cleared.', $crawler->text());
// prove cleared session
$crawler = $client->request('GET', '/session');
$this->assertContains('You are new here and gave no name.', $crawler->text());
$this->assertStringContainsString('You are new here and gave no name.', $crawler->text());
}
/**
@@ -59,14 +59,14 @@ class SessionTest extends AbstractWebTestCase
}
// set flash
$crawler = $client->request('GET', '/session_setflash/Hello%20world.');
$client->request('GET', '/session_setflash/Hello%20world.');
// check flash displays on redirect
$this->assertContains('Hello world.', $client->followRedirect()->text());
$this->assertStringContainsString('Hello world.', $client->followRedirect()->text());
// check flash is gone
$crawler = $client->request('GET', '/session_showflash');
$this->assertContains('No flash was set.', $crawler->text());
$this->assertStringContainsString('No flash was set.', $crawler->text());
}
/**
@@ -91,39 +91,39 @@ class SessionTest extends AbstractWebTestCase
// new session, so no name set.
$crawler1 = $client1->request('GET', '/session');
$this->assertContains('You are new here and gave no name.', $crawler1->text());
$this->assertStringContainsString('You are new here and gave no name.', $crawler1->text());
// set name of client1
$crawler1 = $client1->request('GET', '/session/client1');
$this->assertContains('Hello client1, nice to meet you.', $crawler1->text());
$this->assertStringContainsString('Hello client1, nice to meet you.', $crawler1->text());
// no session for client2
$crawler2 = $client2->request('GET', '/session');
$this->assertContains('You are new here and gave no name.', $crawler2->text());
$this->assertStringContainsString('You are new here and gave no name.', $crawler2->text());
// remember name client2
$crawler2 = $client2->request('GET', '/session/client2');
$this->assertContains('Hello client2, nice to meet you.', $crawler2->text());
$this->assertStringContainsString('Hello client2, nice to meet you.', $crawler2->text());
// prove remembered name of client1
$crawler1 = $client1->request('GET', '/session');
$this->assertContains('Welcome back client1, nice to meet you.', $crawler1->text());
$this->assertStringContainsString('Welcome back client1, nice to meet you.', $crawler1->text());
// prove remembered name of client2
$crawler2 = $client2->request('GET', '/session');
$this->assertContains('Welcome back client2, nice to meet you.', $crawler2->text());
$this->assertStringContainsString('Welcome back client2, nice to meet you.', $crawler2->text());
// clear client1
$crawler1 = $client1->request('GET', '/session_logout');
$this->assertContains('Session cleared.', $crawler1->text());
$this->assertStringContainsString('Session cleared.', $crawler1->text());
// prove client1 data is cleared
$crawler1 = $client1->request('GET', '/session');
$this->assertContains('You are new here and gave no name.', $crawler1->text());
$this->assertStringContainsString('You are new here and gave no name.', $crawler1->text());
// prove remembered name of client2 remains untouched.
$crawler2 = $client2->request('GET', '/session');
$this->assertContains('Welcome back client2, nice to meet you.', $crawler2->text());
$this->assertStringContainsString('Welcome back client2, nice to meet you.', $crawler2->text());
}
/**

View File

@@ -14,6 +14,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Routing;
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\FrameworkBundle\Routing\Router;
use Symfony\Component\DependencyInjection\Config\ContainerParametersResource;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
@@ -122,23 +123,21 @@ class RouterTest extends TestCase
$routes->add('foo', new Route('/before/%parameter.foo%/after/%%escaped%%'));
$sc = $this->getServiceContainer($routes);
$sc->setParameter('parameter.foo', 'foo');
$sc->setParameter('parameter.foo', 'foo-%%escaped%%');
$router = new Router($sc, 'foo');
$route = $router->getRouteCollection()->get('foo');
$this->assertEquals(
'/before/foo/after/%escaped%',
'/before/foo-%escaped%/after/%escaped%',
$route->getPath()
);
}
/**
* @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
* @expectedExceptionMessage Using "%env(FOO)%" is not allowed in routing configuration.
*/
public function testEnvPlaceholders()
{
$this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
$this->expectExceptionMessage('Using "%env(FOO)%" is not allowed in routing configuration.');
$routes = new RouteCollection();
$routes->add('foo', new Route('/%env(FOO)%'));
@@ -147,6 +146,22 @@ class RouterTest extends TestCase
$router->getRouteCollection();
}
public function testIndirectEnvPlaceholders()
{
$routes = new RouteCollection();
$routes->add('foo', new Route('/%foo%'));
$router = new Router($container = $this->getServiceContainer($routes), 'foo');
$container->setParameter('foo', 'foo-%bar%');
$container->setParameter('bar', '%env(string:FOO)%');
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('Using "%env(string:FOO)%" is not allowed in routing configuration.');
$router->getRouteCollection();
}
public function testHostPlaceholders()
{
$routes = new RouteCollection();
@@ -168,12 +183,10 @@ class RouterTest extends TestCase
);
}
/**
* @expectedException \Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException
* @expectedExceptionMessage You have requested a non-existent parameter "nope".
*/
public function testExceptionOnNonExistentParameter()
{
$this->expectException('Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException');
$this->expectExceptionMessage('You have requested a non-existent parameter "nope".');
$routes = new RouteCollection();
$routes->add('foo', new Route('/%nope%'));
@@ -184,12 +197,10 @@ class RouterTest extends TestCase
$router->getRouteCollection()->get('foo');
}
/**
* @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
* @expectedExceptionMessage The container parameter "object", used in the route configuration value "/%object%", must be a string or numeric, but it is of type object.
*/
public function testExceptionOnNonStringParameter()
{
$this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
$this->expectExceptionMessage('The container parameter "object", used in the route configuration value "/%object%", must be a string or numeric, but it is of type object.');
$routes = new RouteCollection();
$routes->add('foo', new Route('/%object%'));

View File

@@ -43,12 +43,10 @@ class DelegatingEngineTest extends TestCase
$this->assertSame($secondEngine, $delegatingEngine->getEngine('template.php'));
}
/**
* @expectedException \RuntimeException
* @expectedExceptionMessage No engine is able to work with the template "template.php"
*/
public function testGetInvalidEngine()
{
$this->expectException('RuntimeException');
$this->expectExceptionMessage('No engine is able to work with the template "template.php"');
$firstEngine = $this->getEngineMock('template.php', false);
$secondEngine = $this->getEngineMock('template.php', false);
$container = $this->getContainerMock([

View File

@@ -52,11 +52,12 @@ class FormHelperDivLayoutTest extends AbstractDivLayoutTest
]);
}
protected function tearDown()
/**
* @after
*/
public function doTearDown()
{
$this->engine = null;
parent::tearDown();
}
public function testStartTagHasNoActionAttributeWhenActionIsEmpty()

View File

@@ -77,11 +77,12 @@ class FormHelperTableLayoutTest extends AbstractTableLayoutTest
]);
}
protected function tearDown()
/**
* @after
*/
public function doTearDown()
{
$this->engine = null;
parent::tearDown();
}
protected function renderForm(FormView $view, array $vars = [])

View File

@@ -69,7 +69,7 @@ class TemplateLocatorTest extends TestCase
$locator->locate($template);
$this->fail('->locate() should throw an exception when the file is not found.');
} catch (\InvalidArgumentException $e) {
$this->assertContains(
$this->assertStringContainsString(
$errorMessage,
$e->getMessage(),
'TemplateLocator exception should propagate the FileLocator exception message'
@@ -77,11 +77,9 @@ class TemplateLocatorTest extends TestCase
}
}
/**
* @expectedException \InvalidArgumentException
*/
public function testThrowsAnExceptionWhenTemplateIsNotATemplateReferenceInterface()
{
$this->expectException('InvalidArgumentException');
$locator = new TemplateLocator($this->getFileLocator());
$locator->locate('template');
}

View File

@@ -43,11 +43,9 @@ class PhpEngineTest extends TestCase
$this->assertEmpty($globals['app']->getRequest());
}
/**
* @expectedException \InvalidArgumentException
*/
public function testGetInvalidHelper()
{
$this->expectException('InvalidArgumentException');
$container = $this->getContainer();
$loader = $this->getMockForAbstractClass('Symfony\Component\Templating\Loader\Loader');
$engine = new PhpEngine(new TemplateNameParser(), $container, $loader);

View File

@@ -74,11 +74,9 @@ class TemplateNameParserTest extends TestCase
];
}
/**
* @expectedException \InvalidArgumentException
*/
public function testParseValidNameWithNotFoundBundle()
{
$this->expectException('InvalidArgumentException');
$this->parser->parse('BarBundle:Post:index.html.php');
}

View File

@@ -107,10 +107,10 @@ class TranslatorTest extends TestCase
/**
* @group legacy
* @expectedDeprecation The "Symfony\Bundle\FrameworkBundle\Translation\Translator::__construct()" method takes the default locale as the 3rd argument since Symfony 3.3. Not passing it is deprecated and will trigger an error in 4.0.
* @expectedException \InvalidArgumentException
*/
public function testTransWithCachingWithInvalidLocaleOmittingLocale()
{
$this->expectException('InvalidArgumentException');
$loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock();
$translator = $this->getTranslator($loader, ['cache_dir' => $this->tmpDir], 'loader', '\Symfony\Bundle\FrameworkBundle\Tests\Translation\TranslatorWithInvalidLocale', null);
@@ -156,13 +156,13 @@ class TranslatorTest extends TestCase
/**
* @group legacy
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Missing third $defaultLocale argument.
*/
public function testGetDefaultLocaleOmittingLocaleWithPsrContainer()
{
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage('Missing third $defaultLocale argument.');
$container = $this->getMockBuilder(ContainerInterface::class)->getMock();
$translator = new Translator($container, new MessageFormatter());
new Translator($container, new MessageFormatter());
}
/**
@@ -247,12 +247,10 @@ class TranslatorTest extends TestCase
$this->assertEquals('foobarbax (sr@latin)', $translator->trans('foobarbax'));
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Invalid "invalid locale" locale.
*/
public function testTransWithCachingWithInvalidLocale()
{
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage('Invalid "invalid locale" locale.');
$loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock();
$translator = $this->getTranslator($loader, ['cache_dir' => $this->tmpDir], 'loader', '\Symfony\Bundle\FrameworkBundle\Tests\Translation\TranslatorWithInvalidLocale');
@@ -282,12 +280,10 @@ class TranslatorTest extends TestCase
$this->assertSame('en', $translator->getLocale());
}
/**
* @expectedException \Symfony\Component\Translation\Exception\InvalidArgumentException
* @expectedExceptionMessage The Translator does not support the following options: 'foo'
*/
public function testInvalidOptions()
{
$this->expectException('Symfony\Component\Translation\Exception\InvalidArgumentException');
$this->expectExceptionMessage('The Translator does not support the following options: \'foo\'');
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
(new Translator($container, new MessageFormatter(), 'en', [], ['foo' => 'bar']));

View File

@@ -59,11 +59,9 @@ class ConstraintValidatorFactoryTest extends TestCase
$this->assertSame($validator, $factory->getInstance(new ConstraintAliasStub()));
}
/**
* @expectedException \Symfony\Component\Validator\Exception\ValidatorException
*/
public function testGetInstanceInvalidValidatorClass()
{
$this->expectException('Symfony\Component\Validator\Exception\ValidatorException');
$constraint = $this->getMockBuilder('Symfony\\Component\\Validator\\Constraint')->getMock();
$constraint
->expects($this->exactly(2))