');
@@ -36,11 +37,9 @@ class LinkTest extends TestCase
$this->assertSame('https://example.com/foo', $link->getUri());
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testAbsoluteBaseUriIsMandatoryWhenLinkUrlIsRelative()
{
+ $this->expectException('InvalidArgumentException');
$dom = new \DOMDocument();
$dom->loadHTML('
foo');
diff --git a/src/Symfony/Component/Dotenv/Tests/DotenvTest.php b/src/Symfony/Component/Dotenv/Tests/DotenvTest.php
index 208f6a99c2..f151973cec 100644
--- a/src/Symfony/Component/Dotenv/Tests/DotenvTest.php
+++ b/src/Symfony/Component/Dotenv/Tests/DotenvTest.php
@@ -12,11 +12,14 @@
namespace Symfony\Component\Dotenv\Tests;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Dotenv\Dotenv;
use Symfony\Component\Dotenv\Exception\FormatException;
class DotenvTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
/**
* @dataProvider getEnvDataWithFormatErrors
*/
@@ -305,11 +308,9 @@ class DotenvTest extends TestCase
$this->assertSame('BAZ', $bar);
}
- /**
- * @expectedException \Symfony\Component\Dotenv\Exception\PathException
- */
public function testLoadDirectory()
{
+ $this->expectException('Symfony\Component\Dotenv\Exception\PathException');
$dotenv = new Dotenv(true);
$dotenv->load(__DIR__);
}
diff --git a/src/Symfony/Component/ErrorHandler/Tests/DebugClassLoaderTest.php b/src/Symfony/Component/ErrorHandler/Tests/DebugClassLoaderTest.php
index 5944cf6fec..a0d92a680a 100644
--- a/src/Symfony/Component/ErrorHandler/Tests/DebugClassLoaderTest.php
+++ b/src/Symfony/Component/ErrorHandler/Tests/DebugClassLoaderTest.php
@@ -58,12 +58,10 @@ class DebugClassLoaderTest extends TestCase
$this->fail('DebugClassLoader did not register');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage boo
- */
public function testThrowingClass()
{
+ $this->expectException('Exception');
+ $this->expectExceptionMessage('boo');
try {
class_exists(__NAMESPACE__.'\Fixtures\Throwing');
$this->fail('Exception expected');
@@ -75,20 +73,16 @@ class DebugClassLoaderTest extends TestCase
class_exists(__NAMESPACE__.'\Fixtures\Throwing');
}
- /**
- * @expectedException \RuntimeException
- */
public function testNameCaseMismatch()
{
+ $this->expectException('RuntimeException');
class_exists(__NAMESPACE__.'\TestingCaseMismatch', true);
}
- /**
- * @expectedException \RuntimeException
- * @expectedExceptionMessage Case mismatch between class and real file names
- */
public function testFileCaseMismatch()
{
+ $this->expectException('RuntimeException');
+ $this->expectExceptionMessage('Case mismatch between class and real file names');
if (!file_exists(__DIR__.'/Fixtures/CaseMismatch.php')) {
$this->markTestSkipped('Can only be run on case insensitive filesystems');
}
@@ -96,11 +90,9 @@ class DebugClassLoaderTest extends TestCase
class_exists(__NAMESPACE__.'\Fixtures\CaseMismatch', true);
}
- /**
- * @expectedException \RuntimeException
- */
public function testPsr4CaseMismatch()
{
+ $this->expectException('RuntimeException');
class_exists(__NAMESPACE__.'\Fixtures\Psr4CaseMismatch', true);
}
diff --git a/src/Symfony/Component/ErrorHandler/Tests/ErrorHandlerTest.php b/src/Symfony/Component/ErrorHandler/Tests/ErrorHandlerTest.php
index a23c96a785..fbece7707b 100644
--- a/src/Symfony/Component/ErrorHandler/Tests/ErrorHandlerTest.php
+++ b/src/Symfony/Component/ErrorHandler/Tests/ErrorHandlerTest.php
@@ -491,11 +491,9 @@ class ErrorHandlerTest extends TestCase
$this->assertStringStartsWith("Attempted to load class \"IReallyReallyDoNotExistAnywhereInTheRepositoryISwear\" from the global namespace.\nDid you forget a \"use\" statement", $args[0]->getMessage());
}
- /**
- * @expectedException \Exception
- */
public function testCustomExceptionHandler()
{
+ $this->expectException('Exception');
$handler = new ErrorHandler();
$handler->setExceptionHandler(function ($e) use ($handler) {
$handler->handleException($e);
diff --git a/src/Symfony/Component/ErrorRenderer/Tests/Command/DebugCommandTest.php b/src/Symfony/Component/ErrorRenderer/Tests/Command/DebugCommandTest.php
index 2a9174727d..383de253e1 100644
--- a/src/Symfony/Component/ErrorRenderer/Tests/Command/DebugCommandTest.php
+++ b/src/Symfony/Component/ErrorRenderer/Tests/Command/DebugCommandTest.php
@@ -78,12 +78,10 @@ TXT
return new CommandTester($application->find('debug:error-renderer'));
}
- /**
- * @expectedException \Symfony\Component\Console\Exception\InvalidArgumentException
- * @expectedExceptionMessage No error renderer found for format "foo". Known format are json, xml, txt.
- */
public function testInvalidFormat()
{
+ $this->expectException('Symfony\Component\Console\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('No error renderer found for format "foo". Known format are json, xml, txt.');
$tester = $this->createCommandTester();
$tester->execute(['format' => 'foo'], ['decorated' => false]);
}
diff --git a/src/Symfony/Component/ErrorRenderer/Tests/DependencyInjection/LazyLoadingErrorRendererTest.php b/src/Symfony/Component/ErrorRenderer/Tests/DependencyInjection/LazyLoadingErrorRendererTest.php
index 3ee8e5aca7..5811a0c026 100644
--- a/src/Symfony/Component/ErrorRenderer/Tests/DependencyInjection/LazyLoadingErrorRendererTest.php
+++ b/src/Symfony/Component/ErrorRenderer/Tests/DependencyInjection/LazyLoadingErrorRendererTest.php
@@ -19,12 +19,10 @@ use Symfony\Component\ErrorRenderer\Exception\FlattenException;
class LazyLoadingErrorRendererTest extends TestCase
{
- /**
- * @expectedException \Symfony\Component\ErrorRenderer\Exception\ErrorRendererNotFoundException
- * @expectedExceptionMessage No error renderer found for format "foo".
- */
public function testInvalidErrorRenderer()
{
+ $this->expectException('Symfony\Component\ErrorRenderer\Exception\ErrorRendererNotFoundException');
+ $this->expectExceptionMessage('No error renderer found for format "foo".');
$container = $this->getMockBuilder(ContainerInterface::class)->getMock();
$container->expects($this->once())->method('has')->with('foo')->willReturn(false);
diff --git a/src/Symfony/Component/ErrorRenderer/Tests/ErrorRendererTest.php b/src/Symfony/Component/ErrorRenderer/Tests/ErrorRendererTest.php
index 6664b6008b..11ef6a7d7e 100644
--- a/src/Symfony/Component/ErrorRenderer/Tests/ErrorRendererTest.php
+++ b/src/Symfony/Component/ErrorRenderer/Tests/ErrorRendererTest.php
@@ -18,21 +18,17 @@ use Symfony\Component\ErrorRenderer\Exception\FlattenException;
class ErrorRendererTest extends TestCase
{
- /**
- * @expectedException \Symfony\Component\ErrorRenderer\Exception\ErrorRendererNotFoundException
- * @expectedExceptionMessage No error renderer found for format "foo".
- */
public function testErrorRendererNotFound()
{
+ $this->expectException('Symfony\Component\ErrorRenderer\Exception\ErrorRendererNotFoundException');
+ $this->expectExceptionMessage('No error renderer found for format "foo".');
$exception = FlattenException::createFromThrowable(new \Exception('foo'));
(new ErrorRenderer([]))->render($exception, 'foo');
}
- /**
- * @expectedException \TypeError
- */
public function testInvalidErrorRenderer()
{
+ $this->expectException('TypeError');
new ErrorRenderer([new \stdClass()]);
}
diff --git a/src/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php b/src/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php
index d665f426e0..e56d49dc4b 100644
--- a/src/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php
+++ b/src/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\EventDispatcher\Tests\DependencyInjection;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
@@ -19,14 +20,15 @@ use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass;
class RegisterListenersPassTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
/**
* Tests that event subscribers not implementing EventSubscriberInterface
* trigger an exception.
- *
- * @expectedException \InvalidArgumentException
*/
public function testEventSubscriberWithoutInterface()
{
+ $this->expectException('InvalidArgumentException');
$builder = new ContainerBuilder();
$builder->register('event_dispatcher');
$builder->register('my_event_subscriber', 'stdClass')
@@ -63,12 +65,10 @@ class RegisterListenersPassTest extends TestCase
$this->assertEquals($expectedCalls, $eventDispatcherDefinition->getMethodCalls());
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage The service "foo" tagged "kernel.event_listener" must not be abstract.
- */
public function testAbstractEventListener()
{
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('The service "foo" tagged "kernel.event_listener" must not be abstract.');
$container = new ContainerBuilder();
$container->register('foo', 'stdClass')->setAbstract(true)->addTag('kernel.event_listener', []);
$container->register('event_dispatcher', 'stdClass');
@@ -77,12 +77,10 @@ class RegisterListenersPassTest extends TestCase
$registerListenersPass->process($container);
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage The service "foo" tagged "kernel.event_subscriber" must not be abstract.
- */
public function testAbstractEventSubscriber()
{
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('The service "foo" tagged "kernel.event_subscriber" must not be abstract.');
$container = new ContainerBuilder();
$container->register('foo', 'stdClass')->setAbstract(true)->addTag('kernel.event_subscriber', []);
$container->register('event_dispatcher', 'stdClass');
@@ -128,12 +126,10 @@ class RegisterListenersPassTest extends TestCase
$this->assertTrue($container->getDefinition('foo')->hasTag('container.hot_path'));
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage You have requested a non-existent parameter "subscriber.class"
- */
public function testEventSubscriberUnresolvableClassName()
{
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('You have requested a non-existent parameter "subscriber.class"');
$container = new ContainerBuilder();
$container->register('foo', '%subscriber.class%')->addTag('kernel.event_subscriber', []);
$container->register('event_dispatcher', 'stdClass');
diff --git a/src/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php b/src/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php
index dfcd2431ec..fb9e1620a7 100644
--- a/src/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php
+++ b/src/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php
@@ -81,11 +81,9 @@ class GenericEventTest extends TestCase
$this->assertEquals('Event', $this->event->getArgument('name'));
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testGetArgException()
{
+ $this->expectException('\InvalidArgumentException');
$this->event->getArgument('nameNotExist');
}
diff --git a/src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php
index 3b519dd45f..fc5b1228a8 100644
--- a/src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php
+++ b/src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php
@@ -73,37 +73,29 @@ class ImmutableEventDispatcherTest extends TestCase
$this->assertSame('result', $this->dispatcher->hasListeners('event'));
}
- /**
- * @expectedException \BadMethodCallException
- */
public function testAddListenerDisallowed()
{
+ $this->expectException('\BadMethodCallException');
$this->dispatcher->addListener('event', function () { return 'foo'; });
}
- /**
- * @expectedException \BadMethodCallException
- */
public function testAddSubscriberDisallowed()
{
+ $this->expectException('\BadMethodCallException');
$subscriber = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventSubscriberInterface')->getMock();
$this->dispatcher->addSubscriber($subscriber);
}
- /**
- * @expectedException \BadMethodCallException
- */
public function testRemoveListenerDisallowed()
{
+ $this->expectException('\BadMethodCallException');
$this->dispatcher->removeListener('event', function () { return 'foo'; });
}
- /**
- * @expectedException \BadMethodCallException
- */
public function testRemoveSubscriberDisallowed()
{
+ $this->expectException('\BadMethodCallException');
$subscriber = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventSubscriberInterface')->getMock();
$this->dispatcher->removeSubscriber($subscriber);
diff --git a/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionFunctionTest.php b/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionFunctionTest.php
index f2710fb1e5..8d81c2b9d9 100644
--- a/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionFunctionTest.php
+++ b/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionFunctionTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\ExpressionLanguage\Tests;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\ExpressionLanguage\ExpressionFunction;
/**
@@ -21,21 +22,19 @@ use Symfony\Component\ExpressionLanguage\ExpressionFunction;
*/
class ExpressionFunctionTest extends TestCase
{
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage PHP function "fn_does_not_exist" does not exist.
- */
+ use ForwardCompatTestTrait;
+
public function testFunctionDoesNotExist()
{
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('PHP function "fn_does_not_exist" does not exist.');
ExpressionFunction::fromPhp('fn_does_not_exist');
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage An expression function name must be defined when PHP function "Symfony\Component\ExpressionLanguage\Tests\fn_namespaced" is namespaced.
- */
public function testFunctionNamespaced()
{
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('An expression function name must be defined when PHP function "Symfony\Component\ExpressionLanguage\Tests\fn_namespaced" is namespaced.');
ExpressionFunction::fromPhp('Symfony\Component\ExpressionLanguage\Tests\fn_namespaced');
}
}
diff --git a/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php b/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php
index 41a1f578d4..e19d7968fb 100644
--- a/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php
+++ b/src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\ExpressionLanguage\Tests;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\ExpressionLanguage\ExpressionFunction;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
use Symfony\Component\ExpressionLanguage\ParsedExpression;
@@ -19,6 +20,8 @@ use Symfony\Component\ExpressionLanguage\Tests\Fixtures\TestProvider;
class ExpressionLanguageTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testCachedParse()
{
$cacheMock = $this->getMockBuilder('Psr\Cache\CacheItemPoolInterface')->getMock();
@@ -105,12 +108,10 @@ class ExpressionLanguageTest extends TestCase
$this->assertSame($expected, $result);
}
- /**
- * @expectedException \Symfony\Component\ExpressionLanguage\SyntaxError
- * @expectedExceptionMessage Unexpected end of expression around position 6 for expression `node.`.
- */
public function testParseThrowsInsteadOfNotice()
{
+ $this->expectException('Symfony\Component\ExpressionLanguage\SyntaxError');
+ $this->expectExceptionMessage('Unexpected end of expression around position 6 for expression `node.`.');
$expressionLanguage = new ExpressionLanguage();
$expressionLanguage->parse('node.', ['node']);
}
@@ -199,10 +200,10 @@ class ExpressionLanguageTest extends TestCase
/**
* @dataProvider getRegisterCallbacks
- * @expectedException \LogicException
*/
public function testRegisterAfterParse($registerCallback)
{
+ $this->expectException('LogicException');
$el = new ExpressionLanguage();
$el->parse('1 + 1', []);
$registerCallback($el);
@@ -210,31 +211,29 @@ class ExpressionLanguageTest extends TestCase
/**
* @dataProvider getRegisterCallbacks
- * @expectedException \LogicException
*/
public function testRegisterAfterEval($registerCallback)
{
+ $this->expectException('LogicException');
$el = new ExpressionLanguage();
$el->evaluate('1 + 1');
$registerCallback($el);
}
- /**
- * @expectedException \RuntimeException
- * @expectedExceptionMessageRegExp /Unable to call method "\w+" of object "\w+"./
- */
public function testCallBadCallable()
{
+ $this->expectException('RuntimeException');
+ $this->expectExceptionMessageRegExp('/Unable to call method "\w+" of object "\w+"./');
$el = new ExpressionLanguage();
$el->evaluate('foo.myfunction()', ['foo' => new \stdClass()]);
}
/**
* @dataProvider getRegisterCallbacks
- * @expectedException \LogicException
*/
public function testRegisterAfterCompile($registerCallback)
{
+ $this->expectException('LogicException');
$el = new ExpressionLanguage();
$el->compile('1 + 1');
$registerCallback($el);
diff --git a/src/Symfony/Component/ExpressionLanguage/Tests/LexerTest.php b/src/Symfony/Component/ExpressionLanguage/Tests/LexerTest.php
index d94dd74f06..b26f925cf0 100644
--- a/src/Symfony/Component/ExpressionLanguage/Tests/LexerTest.php
+++ b/src/Symfony/Component/ExpressionLanguage/Tests/LexerTest.php
@@ -40,22 +40,18 @@ class LexerTest extends TestCase
$this->assertEquals(new TokenStream($tokens, $expression), $this->lexer->tokenize($expression));
}
- /**
- * @expectedException \Symfony\Component\ExpressionLanguage\SyntaxError
- * @expectedExceptionMessage Unexpected character "'" around position 33 for expression `service(faulty.expression.example').dummyMethod()`.
- */
public function testTokenizeThrowsErrorWithMessage()
{
+ $this->expectException('Symfony\Component\ExpressionLanguage\SyntaxError');
+ $this->expectExceptionMessage('Unexpected character "\'" around position 33 for expression `service(faulty.expression.example\').dummyMethod()`.');
$expression = "service(faulty.expression.example').dummyMethod()";
$this->lexer->tokenize($expression);
}
- /**
- * @expectedException \Symfony\Component\ExpressionLanguage\SyntaxError
- * @expectedExceptionMessage Unclosed "(" around position 7 for expression `service(unclosed.expression.dummyMethod()`.
- */
public function testTokenizeThrowsErrorOnUnclosedBrace()
{
+ $this->expectException('Symfony\Component\ExpressionLanguage\SyntaxError');
+ $this->expectExceptionMessage('Unclosed "(" around position 7 for expression `service(unclosed.expression.dummyMethod()`.');
$expression = 'service(unclosed.expression.dummyMethod()';
$this->lexer->tokenize($expression);
}
diff --git a/src/Symfony/Component/ExpressionLanguage/Tests/ParserTest.php b/src/Symfony/Component/ExpressionLanguage/Tests/ParserTest.php
index d030600fe8..8fcddeb606 100644
--- a/src/Symfony/Component/ExpressionLanguage/Tests/ParserTest.php
+++ b/src/Symfony/Component/ExpressionLanguage/Tests/ParserTest.php
@@ -12,29 +12,28 @@
namespace Symfony\Component\ExpressionLanguage\Tests;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\ExpressionLanguage\Lexer;
use Symfony\Component\ExpressionLanguage\Node;
use Symfony\Component\ExpressionLanguage\Parser;
class ParserTest extends TestCase
{
- /**
- * @expectedException \Symfony\Component\ExpressionLanguage\SyntaxError
- * @expectedExceptionMessage Variable "foo" is not valid around position 1 for expression `foo`.
- */
+ use ForwardCompatTestTrait;
+
public function testParseWithInvalidName()
{
+ $this->expectException('Symfony\Component\ExpressionLanguage\SyntaxError');
+ $this->expectExceptionMessage('Variable "foo" is not valid around position 1 for expression `foo`.');
$lexer = new Lexer();
$parser = new Parser([]);
$parser->parse($lexer->tokenize('foo'));
}
- /**
- * @expectedException \Symfony\Component\ExpressionLanguage\SyntaxError
- * @expectedExceptionMessage Variable "foo" is not valid around position 1 for expression `foo`.
- */
public function testParseWithZeroInNames()
{
+ $this->expectException('Symfony\Component\ExpressionLanguage\SyntaxError');
+ $this->expectExceptionMessage('Variable "foo" is not valid around position 1 for expression `foo`.');
$lexer = new Lexer();
$parser = new Parser([]);
$parser->parse($lexer->tokenize('foo'), [0]);
@@ -165,10 +164,10 @@ class ParserTest extends TestCase
/**
* @dataProvider getInvalidPostfixData
- * @expectedException \Symfony\Component\ExpressionLanguage\SyntaxError
*/
public function testParseWithInvalidPostfixData($expr, $names = [])
{
+ $this->expectException('Symfony\Component\ExpressionLanguage\SyntaxError');
$lexer = new Lexer();
$parser = new Parser([]);
$parser->parse($lexer->tokenize($expr), $names);
@@ -196,12 +195,10 @@ class ParserTest extends TestCase
];
}
- /**
- * @expectedException \Symfony\Component\ExpressionLanguage\SyntaxError
- * @expectedExceptionMessage Did you mean "baz"?
- */
public function testNameProposal()
{
+ $this->expectException('Symfony\Component\ExpressionLanguage\SyntaxError');
+ $this->expectExceptionMessage('Did you mean "baz"?');
$lexer = new Lexer();
$parser = new Parser([]);
diff --git a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php
index 320644fa00..05723f2836 100644
--- a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php
+++ b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php
@@ -11,11 +11,15 @@
namespace Symfony\Component\Filesystem\Tests;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
+
/**
* Test class for Filesystem.
*/
class FilesystemTest extends FilesystemTestCase
{
+ use ForwardCompatTestTrait;
+
public function testCopyCreatesNewFile()
{
$sourceFilePath = $this->workspace.\DIRECTORY_SEPARATOR.'copy_source_file';
@@ -29,22 +33,18 @@ class FilesystemTest extends FilesystemTestCase
$this->assertStringEqualsFile($targetFilePath, 'SOURCE FILE');
}
- /**
- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
- */
public function testCopyFails()
{
+ $this->expectException('Symfony\Component\Filesystem\Exception\IOException');
$sourceFilePath = $this->workspace.\DIRECTORY_SEPARATOR.'copy_source_file';
$targetFilePath = $this->workspace.\DIRECTORY_SEPARATOR.'copy_target_file';
$this->filesystem->copy($sourceFilePath, $targetFilePath);
}
- /**
- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
- */
public function testCopyUnreadableFileFails()
{
+ $this->expectException('Symfony\Component\Filesystem\Exception\IOException');
// skip test on Windows; PHP can't easily set file as unreadable on Windows
if ('\\' === \DIRECTORY_SEPARATOR) {
$this->markTestSkipped('This test cannot run on Windows.');
@@ -118,11 +118,9 @@ class FilesystemTest extends FilesystemTestCase
$this->assertStringEqualsFile($targetFilePath, 'SOURCE FILE');
}
- /**
- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
- */
public function testCopyWithOverrideWithReadOnlyTargetFails()
{
+ $this->expectException('Symfony\Component\Filesystem\Exception\IOException');
// skip test on Windows; PHP can't easily set file as unwritable on Windows
if ('\\' === \DIRECTORY_SEPARATOR) {
$this->markTestSkipped('This test cannot run on Windows.');
@@ -222,11 +220,9 @@ class FilesystemTest extends FilesystemTestCase
$this->assertTrue(is_dir($basePath.'3'));
}
- /**
- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
- */
public function testMkdirCreatesDirectoriesFails()
{
+ $this->expectException('Symfony\Component\Filesystem\Exception\IOException');
$basePath = $this->workspace.\DIRECTORY_SEPARATOR;
$dir = $basePath.'2';
@@ -244,11 +240,9 @@ class FilesystemTest extends FilesystemTestCase
$this->assertFileExists($file);
}
- /**
- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
- */
public function testTouchFails()
{
+ $this->expectException('Symfony\Component\Filesystem\Exception\IOException');
$file = $this->workspace.\DIRECTORY_SEPARATOR.'1'.\DIRECTORY_SEPARATOR.'2';
$this->filesystem->touch($file);
@@ -380,11 +374,9 @@ class FilesystemTest extends FilesystemTestCase
$this->assertTrue($this->filesystem->exists($basePath.'folder'));
}
- /**
- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
- */
public function testFilesExistsFails()
{
+ $this->expectException('Symfony\Component\Filesystem\Exception\IOException');
if ('\\' !== \DIRECTORY_SEPARATOR) {
$this->markTestSkipped('Long file names are an issue on Windows');
}
@@ -595,11 +587,9 @@ class FilesystemTest extends FilesystemTestCase
$this->assertSame($owner, $this->getFileOwner($link));
}
- /**
- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
- */
public function testChownSymlinkFails()
{
+ $this->expectException('Symfony\Component\Filesystem\Exception\IOException');
$this->markAsSkippedIfSymlinkIsMissing();
$file = $this->workspace.\DIRECTORY_SEPARATOR.'file';
@@ -612,11 +602,9 @@ class FilesystemTest extends FilesystemTestCase
$this->filesystem->chown($link, 'user'.time().mt_rand(1000, 9999));
}
- /**
- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
- */
public function testChownLinkFails()
{
+ $this->expectException('Symfony\Component\Filesystem\Exception\IOException');
$this->markAsSkippedIfLinkIsMissing();
$file = $this->workspace.\DIRECTORY_SEPARATOR.'file';
@@ -629,11 +617,9 @@ class FilesystemTest extends FilesystemTestCase
$this->filesystem->chown($link, 'user'.time().mt_rand(1000, 9999));
}
- /**
- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
- */
public function testChownFail()
{
+ $this->expectException('Symfony\Component\Filesystem\Exception\IOException');
$this->markAsSkippedIfPosixIsMissing();
$dir = $this->workspace.\DIRECTORY_SEPARATOR.'dir';
@@ -704,11 +690,9 @@ class FilesystemTest extends FilesystemTestCase
$this->assertSame($group, $this->getFileGroup($link));
}
- /**
- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
- */
public function testChgrpSymlinkFails()
{
+ $this->expectException('Symfony\Component\Filesystem\Exception\IOException');
$this->markAsSkippedIfSymlinkIsMissing();
$file = $this->workspace.\DIRECTORY_SEPARATOR.'file';
@@ -721,11 +705,9 @@ class FilesystemTest extends FilesystemTestCase
$this->filesystem->chgrp($link, 'user'.time().mt_rand(1000, 9999));
}
- /**
- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
- */
public function testChgrpLinkFails()
{
+ $this->expectException('Symfony\Component\Filesystem\Exception\IOException');
$this->markAsSkippedIfLinkIsMissing();
$file = $this->workspace.\DIRECTORY_SEPARATOR.'file';
@@ -738,11 +720,9 @@ class FilesystemTest extends FilesystemTestCase
$this->filesystem->chgrp($link, 'user'.time().mt_rand(1000, 9999));
}
- /**
- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
- */
public function testChgrpFail()
{
+ $this->expectException('Symfony\Component\Filesystem\Exception\IOException');
$this->markAsSkippedIfPosixIsMissing();
$dir = $this->workspace.\DIRECTORY_SEPARATOR.'dir';
@@ -763,11 +743,9 @@ class FilesystemTest extends FilesystemTestCase
$this->assertFileExists($newPath);
}
- /**
- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
- */
public function testRenameThrowsExceptionIfTargetAlreadyExists()
{
+ $this->expectException('Symfony\Component\Filesystem\Exception\IOException');
$file = $this->workspace.\DIRECTORY_SEPARATOR.'file';
$newPath = $this->workspace.\DIRECTORY_SEPARATOR.'new_file';
@@ -791,11 +769,9 @@ class FilesystemTest extends FilesystemTestCase
$this->assertFileExists($newPath);
}
- /**
- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
- */
public function testRenameThrowsExceptionOnError()
{
+ $this->expectException('Symfony\Component\Filesystem\Exception\IOException');
$file = $this->workspace.\DIRECTORY_SEPARATOR.uniqid('fs_test_', true);
$newPath = $this->workspace.\DIRECTORY_SEPARATOR.'new_file';
@@ -1134,21 +1110,17 @@ class FilesystemTest extends FilesystemTestCase
return $paths;
}
- /**
- * @expectedException \Symfony\Component\Filesystem\Exception\InvalidArgumentException
- * @expectedExceptionMessage The start path "var/lib/symfony/src/Symfony/Component" is not absolute.
- */
public function testMakePathRelativeWithRelativeStartPath()
{
+ $this->expectException('Symfony\Component\Filesystem\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('The start path "var/lib/symfony/src/Symfony/Component" is not absolute.');
$this->assertSame('../../../', $this->filesystem->makePathRelative('/var/lib/symfony/', 'var/lib/symfony/src/Symfony/Component'));
}
- /**
- * @expectedException \Symfony\Component\Filesystem\Exception\InvalidArgumentException
- * @expectedExceptionMessage The end path "var/lib/symfony/" is not absolute.
- */
public function testMakePathRelativeWithRelativeEndPath()
{
+ $this->expectException('Symfony\Component\Filesystem\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('The end path "var/lib/symfony/" is not absolute.');
$this->assertSame('../../../', $this->filesystem->makePathRelative('var/lib/symfony/', '/var/lib/symfony/src/Symfony/Component'));
}
@@ -1419,11 +1391,9 @@ class FilesystemTest extends FilesystemTestCase
$this->assertFileExists($filename);
}
- /**
- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
- */
public function testTempnamWithZlibSchemeFails()
{
+ $this->expectException('Symfony\Component\Filesystem\Exception\IOException');
$scheme = 'compress.zlib://';
$dirname = $scheme.$this->workspace;
@@ -1444,11 +1414,9 @@ class FilesystemTest extends FilesystemTestCase
$this->assertFileNotExists($filename);
}
- /**
- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
- */
public function testTempnamWithPharSchemeFails()
{
+ $this->expectException('Symfony\Component\Filesystem\Exception\IOException');
// Skip test if Phar disabled phar.readonly must be 0 in php.ini
if (!\Phar::canWrite()) {
$this->markTestSkipped('This test cannot run when phar.readonly is 1.');
@@ -1463,11 +1431,9 @@ class FilesystemTest extends FilesystemTestCase
$this->filesystem->tempnam($dirname, $pharname.'/bar');
}
- /**
- * @expectedException \Symfony\Component\Filesystem\Exception\IOException
- */
public function testTempnamWithHTTPSchemeFails()
{
+ $this->expectException('Symfony\Component\Filesystem\Exception\IOException');
$scheme = 'http://';
$dirname = $scheme.$this->workspace;
diff --git a/src/Symfony/Component/Finder/Tests/FinderTest.php b/src/Symfony/Component/Finder/Tests/FinderTest.php
index d4a1cb306d..6fb77d6bef 100644
--- a/src/Symfony/Component/Finder/Tests/FinderTest.php
+++ b/src/Symfony/Component/Finder/Tests/FinderTest.php
@@ -11,10 +11,13 @@
namespace Symfony\Component\Finder\Tests;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Finder\Finder;
class FinderTest extends Iterator\RealIteratorTestCase
{
+ use ForwardCompatTestTrait;
+
public function testCreate()
{
$this->assertInstanceOf('Symfony\Component\Finder\Finder', Finder::create());
@@ -887,20 +890,16 @@ class FinderTest extends Iterator\RealIteratorTestCase
$this->assertIterator($expected, $iterator);
}
- /**
- * @expectedException \Symfony\Component\Finder\Exception\DirectoryNotFoundException
- */
public function testInWithNonExistentDirectory()
{
+ $this->expectException('Symfony\Component\Finder\Exception\DirectoryNotFoundException');
$finder = new Finder();
$finder->in('foobar');
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testInWithNonExistentDirectoryLegacyException()
{
+ $this->expectException('InvalidArgumentException');
$finder = new Finder();
$finder->in('foobar');
}
@@ -913,11 +912,9 @@ class FinderTest extends Iterator\RealIteratorTestCase
$this->assertIterator($this->toAbsoluteFixtures(['A/B/C/abc.dat', 'copy/A/B/C/abc.dat.copy']), $finder);
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testInWithNonDirectoryGlob()
{
+ $this->expectException('InvalidArgumentException');
$finder = new Finder();
$finder->in(__DIR__.'/Fixtures/A/a*');
}
@@ -934,11 +931,9 @@ class FinderTest extends Iterator\RealIteratorTestCase
$this->assertIterator($this->toAbsoluteFixtures(['A/B/C/abc.dat', 'copy/A/B/C/abc.dat.copy']), $finder);
}
- /**
- * @expectedException \LogicException
- */
public function testGetIteratorWithoutIn()
{
+ $this->expectException('LogicException');
$finder = Finder::create();
$finder->getIterator();
}
@@ -1116,11 +1111,9 @@ class FinderTest extends Iterator\RealIteratorTestCase
$this->assertCount($i, $files);
}
- /**
- * @expectedException \LogicException
- */
public function testCountWithoutIn()
{
+ $this->expectException('LogicException');
$finder = Finder::create()->files();
\count($finder);
}
@@ -1374,7 +1367,7 @@ class FinderTest extends Iterator\RealIteratorTestCase
$this->fail('Finder should throw an exception when opening a non-readable directory.');
} catch (\Exception $e) {
$expectedExceptionClass = 'Symfony\\Component\\Finder\\Exception\\AccessDeniedException';
- if ($e instanceof \PHPUnit_Framework_ExpectationFailedException) {
+ if ($e instanceof \PHPUnit\Framework\ExpectationFailedException) {
$this->fail(sprintf("Expected exception:\n%s\nGot:\n%s\nWith comparison failure:\n%s", $expectedExceptionClass, 'PHPUnit_Framework_ExpectationFailedException', $e->getComparisonFailure()->getExpectedAsString()));
}
diff --git a/src/Symfony/Component/Finder/Tests/Iterator/CustomFilterIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/CustomFilterIteratorTest.php
index ad0187e032..9c6e7db03f 100644
--- a/src/Symfony/Component/Finder/Tests/Iterator/CustomFilterIteratorTest.php
+++ b/src/Symfony/Component/Finder/Tests/Iterator/CustomFilterIteratorTest.php
@@ -11,15 +11,16 @@
namespace Symfony\Component\Finder\Tests\Iterator;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Finder\Iterator\CustomFilterIterator;
class CustomFilterIteratorTest extends IteratorTestCase
{
- /**
- * @expectedException \InvalidArgumentException
- */
+ use ForwardCompatTestTrait;
+
public function testWithInvalidFilter()
{
+ $this->expectException('InvalidArgumentException');
new CustomFilterIterator(new Iterator(), ['foo']);
}
diff --git a/src/Symfony/Component/Form/Tests/ButtonBuilderTest.php b/src/Symfony/Component/Form/Tests/ButtonBuilderTest.php
index b3a56d63b9..4052c7c3dd 100644
--- a/src/Symfony/Component/Form/Tests/ButtonBuilderTest.php
+++ b/src/Symfony/Component/Form/Tests/ButtonBuilderTest.php
@@ -42,12 +42,11 @@ class ButtonBuilderTest extends TestCase
$this->assertInstanceOf('\Symfony\Component\Form\ButtonBuilder', new ButtonBuilder($name));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException
- * @expectedExceptionMessage The name "button[]" contains illegal characters. Names should start with a letter, digit or underscore and only contain letters, digits, numbers, underscores ("_"), hyphens ("-") and colons (":").
- */
public function testNameContainingIllegalCharacters()
{
+ $this->expectException('Symfony\Component\Form\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('The name "button[]" contains illegal characters. Names should start with a letter, digit or underscore and only contain letters, digits, numbers, underscores ("_"), hyphens ("-") and colons (":").');
+
$this->assertInstanceOf('\Symfony\Component\Form\ButtonBuilder', new ButtonBuilder('button[]'));
}
diff --git a/src/Symfony/Component/Form/Tests/ButtonTest.php b/src/Symfony/Component/Form/Tests/ButtonTest.php
index 7f4344fe63..9243006995 100644
--- a/src/Symfony/Component/Form/Tests/ButtonTest.php
+++ b/src/Symfony/Component/Form/Tests/ButtonTest.php
@@ -33,11 +33,9 @@ class ButtonTest extends TestCase
$this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock();
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\AlreadySubmittedException
- */
public function testSetParentOnSubmittedButton()
{
+ $this->expectException('Symfony\Component\Form\Exception\AlreadySubmittedException');
$button = $this->getButtonBuilder('button')
->getForm()
;
diff --git a/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php b/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php
index ab4b0c1a46..acd7e969f1 100644
--- a/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php
+++ b/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php
@@ -82,12 +82,10 @@ TXT
$this->assertContains('Symfony\Component\Form\Extension\Core\Type\FormType (method)', $tester->getDisplay());
}
- /**
- * @expectedException \Symfony\Component\Console\Exception\InvalidArgumentException
- * @expectedExceptionMessage Could not find type "NonExistentType"
- */
public function testDebugSingleFormTypeNotFound()
{
+ $this->expectException('Symfony\Component\Console\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Could not find type "NonExistentType"');
$tester = $this->createCommandTester();
$tester->execute(['class' => 'NonExistentType'], ['decorated' => false, 'interactive' => false]);
}
@@ -139,11 +137,9 @@ TXT
, $output);
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testDebugInvalidFormType()
{
+ $this->expectException('InvalidArgumentException');
$this->createCommandTester()->execute(['class' => 'test']);
}
diff --git a/src/Symfony/Component/Form/Tests/CompoundFormTest.php b/src/Symfony/Component/Form/Tests/CompoundFormTest.php
index 2fb535ae7e..de108e7dba 100644
--- a/src/Symfony/Component/Form/Tests/CompoundFormTest.php
+++ b/src/Symfony/Component/Form/Tests/CompoundFormTest.php
@@ -11,6 +11,7 @@
namespace Symfony\Component\Form\Tests;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\Form\Extension\Core\DataMapper\PropertyPathMapper;
use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationRequestHandler;
@@ -26,6 +27,8 @@ use Symfony\Component\HttpFoundation\Request;
class CompoundFormTest extends AbstractFormTest
{
+ use ForwardCompatTestTrait;
+
public function testValidIfAllChildrenAreValid()
{
$this->form->add($this->getBuilder('firstName')->getForm());
@@ -269,11 +272,9 @@ class CompoundFormTest extends AbstractFormTest
$this->assertSame(['foo' => $child], $this->form->all());
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\AlreadySubmittedException
- */
public function testAddThrowsExceptionIfAlreadySubmitted()
{
+ $this->expectException('Symfony\Component\Form\Exception\AlreadySubmittedException');
$this->form->submit([]);
$this->form->add($this->getBuilder('foo')->getForm());
}
@@ -288,11 +289,9 @@ class CompoundFormTest extends AbstractFormTest
$this->assertCount(0, $this->form);
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\AlreadySubmittedException
- */
public function testRemoveThrowsExceptionIfAlreadySubmitted()
{
+ $this->expectException('Symfony\Component\Form\Exception\AlreadySubmittedException');
$this->form->add($this->getBuilder('foo')->setCompound(false)->getForm());
$this->form->submit(['foo' => 'bar']);
$this->form->remove('foo');
diff --git a/src/Symfony/Component/Form/Tests/DependencyInjection/FormPassTest.php b/src/Symfony/Component/Form/Tests/DependencyInjection/FormPassTest.php
index b494bb3b17..cc2e9efded 100644
--- a/src/Symfony/Component/Form/Tests/DependencyInjection/FormPassTest.php
+++ b/src/Symfony/Component/Form/Tests/DependencyInjection/FormPassTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\Form\Tests\DependencyInjection;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -28,6 +29,8 @@ use Symfony\Component\Form\FormRegistry;
*/
class FormPassTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testDoNothingIfFormExtensionNotLoaded()
{
$container = $this->createContainerBuilder();
@@ -218,12 +221,10 @@ class FormPassTest extends TestCase
];
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage The getExtendedTypes() method for service "my.type_extension" does not return any extended types.
- */
public function testAddTaggedFormTypeExtensionWithoutExtendingAnyType()
{
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('The getExtendedTypes() method for service "my.type_extension" does not return any extended types.');
$container = $this->createContainerBuilder();
$container->setDefinition('form.extension', $this->createExtensionDefinition());
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ArrayToPartsTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ArrayToPartsTransformerTest.php
index 09b81fc5e1..e1e7ad0eee 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ArrayToPartsTransformerTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ArrayToPartsTransformerTest.php
@@ -71,11 +71,9 @@ class ArrayToPartsTransformerTest extends TestCase
$this->assertSame($output, $this->transformer->transform(null));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testTransformRequiresArray()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$this->transformer->transform('12345');
}
@@ -126,11 +124,9 @@ class ArrayToPartsTransformerTest extends TestCase
$this->assertNull($this->transformer->reverseTransform($input));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformPartiallyNull()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$input = [
'first' => [
'a' => '1',
@@ -143,11 +139,9 @@ class ArrayToPartsTransformerTest extends TestCase
$this->transformer->reverseTransform($input);
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformRequiresArray()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$this->transformer->reverseTransform('12345');
}
}
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BaseDateTimeTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BaseDateTimeTransformerTest.php
index 283dd4a81d..d3dc7e3a26 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BaseDateTimeTransformerTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BaseDateTimeTransformerTest.php
@@ -12,24 +12,23 @@
namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
class BaseDateTimeTransformerTest extends TestCase
{
- /**
- * @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException
- * @expectedExceptionMessage this_timezone_does_not_exist
- */
+ use ForwardCompatTestTrait;
+
public function testConstructFailsIfInputTimezoneIsInvalid()
{
+ $this->expectException('Symfony\Component\Form\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('this_timezone_does_not_exist');
$this->getMockBuilder('Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer')->setConstructorArgs(['this_timezone_does_not_exist'])->getMock();
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException
- * @expectedExceptionMessage that_timezone_does_not_exist
- */
public function testConstructFailsIfOutputTimezoneIsInvalid()
{
+ $this->expectException('Symfony\Component\Form\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('that_timezone_does_not_exist');
$this->getMockBuilder('Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer')->setConstructorArgs([null, 'that_timezone_does_not_exist'])->getMock();
}
}
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BooleanToStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BooleanToStringTransformerTest.php
index 54c7fe1293..a42a9525f9 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BooleanToStringTransformerTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BooleanToStringTransformerTest.php
@@ -48,19 +48,15 @@ class BooleanToStringTransformerTest extends TestCase
$this->assertNull($this->transformer->transform(null));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testTransformFailsIfString()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$this->transformer->transform('1');
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformFailsIfInteger()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$this->transformer->reverseTransform(1);
}
@@ -80,11 +76,9 @@ class BooleanToStringTransformerTest extends TestCase
$this->assertFalse($customFalseTransformer->reverseTransform(true));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException
- */
public function testTrueValueContainedInFalseValues()
{
+ $this->expectException('Symfony\Component\Form\Exception\InvalidArgumentException');
new BooleanToStringTransformer('0', [null, '0']);
}
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoiceToValueTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoiceToValueTransformerTest.php
index 37d383490f..ee007b40d1 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoiceToValueTransformerTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoiceToValueTransformerTest.php
@@ -91,10 +91,10 @@ class ChoiceToValueTransformerTest extends TestCase
/**
* @dataProvider reverseTransformExpectsStringOrNullProvider
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
*/
public function testReverseTransformExpectsStringOrNull($value)
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$this->transformer->reverseTransform($value);
}
}
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoicesToValuesTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoicesToValuesTransformerTest.php
index e741a3e11f..6f008ba187 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoicesToValuesTransformerTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoicesToValuesTransformerTest.php
@@ -56,11 +56,9 @@ class ChoicesToValuesTransformerTest extends TestCase
$this->assertSame([], $this->transformer->transform(null));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testTransformExpectsArray()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$this->transformer->transform('foobar');
}
@@ -84,11 +82,9 @@ class ChoicesToValuesTransformerTest extends TestCase
$this->assertSame([], $this->transformerWithNull->reverseTransform(null));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformExpectsArray()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$this->transformer->reverseTransform('foobar');
}
}
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeImmutableToDateTimeTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeImmutableToDateTimeTransformerTest.php
index 244ef0f790..9313e4f178 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeImmutableToDateTimeTransformerTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeImmutableToDateTimeTransformerTest.php
@@ -35,12 +35,10 @@ class DateTimeImmutableToDateTimeTransformerTest extends TestCase
$this->assertNull($transformer->transform(null));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- * @expectedExceptionMessage Expected a \DateTimeImmutable.
- */
public function testTransformFail()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
+ $this->expectExceptionMessage('Expected a \DateTimeImmutable.');
$transformer = new DateTimeImmutableToDateTimeTransformer();
$transformer->transform(new \DateTime());
}
@@ -64,12 +62,10 @@ class DateTimeImmutableToDateTimeTransformerTest extends TestCase
$this->assertNull($transformer->reverseTransform(null));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- * @expectedExceptionMessage Expected a \DateTime.
- */
public function testReverseTransformFail()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
+ $this->expectExceptionMessage('Expected a \DateTime.');
$transformer = new DateTimeImmutableToDateTimeTransformer();
$transformer->reverseTransform(new \DateTimeImmutable());
}
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToArrayTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToArrayTransformerTest.php
index 2669d3d4af..5460203fc6 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToArrayTransformerTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToArrayTransformerTest.php
@@ -12,10 +12,13 @@
namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToArrayTransformer;
class DateTimeToArrayTransformerTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testTransform()
{
$transformer = new DateTimeToArrayTransformer('UTC', 'UTC');
@@ -137,11 +140,9 @@ class DateTimeToArrayTransformerTest extends TestCase
$this->assertSame($output, $transformer->transform($input));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testTransformRequiresDateTime()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new DateTimeToArrayTransformer();
$transformer->reverseTransform('12345');
}
@@ -211,11 +212,9 @@ class DateTimeToArrayTransformerTest extends TestCase
$this->assertNull($transformer->reverseTransform($input));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformPartiallyEmptyYear()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new DateTimeToArrayTransformer();
$transformer->reverseTransform([
'month' => '2',
@@ -226,11 +225,9 @@ class DateTimeToArrayTransformerTest extends TestCase
]);
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformPartiallyEmptyMonth()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new DateTimeToArrayTransformer();
$transformer->reverseTransform([
'year' => '2010',
@@ -241,11 +238,9 @@ class DateTimeToArrayTransformerTest extends TestCase
]);
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformPartiallyEmptyDay()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new DateTimeToArrayTransformer();
$transformer->reverseTransform([
'year' => '2010',
@@ -256,11 +251,9 @@ class DateTimeToArrayTransformerTest extends TestCase
]);
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformPartiallyEmptyHour()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new DateTimeToArrayTransformer();
$transformer->reverseTransform([
'year' => '2010',
@@ -271,11 +264,9 @@ class DateTimeToArrayTransformerTest extends TestCase
]);
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformPartiallyEmptyMinute()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new DateTimeToArrayTransformer();
$transformer->reverseTransform([
'year' => '2010',
@@ -286,11 +277,9 @@ class DateTimeToArrayTransformerTest extends TestCase
]);
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformPartiallyEmptySecond()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new DateTimeToArrayTransformer();
$transformer->reverseTransform([
'year' => '2010',
@@ -346,20 +335,16 @@ class DateTimeToArrayTransformerTest extends TestCase
$this->assertEquals($output, $transformer->reverseTransform($input));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformRequiresArray()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new DateTimeToArrayTransformer();
$transformer->reverseTransform('12345');
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformWithNegativeYear()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new DateTimeToArrayTransformer();
$transformer->reverseTransform([
'year' => '-1',
@@ -371,11 +356,9 @@ class DateTimeToArrayTransformerTest extends TestCase
]);
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformWithNegativeMonth()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new DateTimeToArrayTransformer();
$transformer->reverseTransform([
'year' => '2010',
@@ -387,11 +370,9 @@ class DateTimeToArrayTransformerTest extends TestCase
]);
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformWithNegativeDay()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new DateTimeToArrayTransformer();
$transformer->reverseTransform([
'year' => '2010',
@@ -403,11 +384,9 @@ class DateTimeToArrayTransformerTest extends TestCase
]);
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformWithNegativeHour()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new DateTimeToArrayTransformer();
$transformer->reverseTransform([
'year' => '2010',
@@ -419,11 +398,9 @@ class DateTimeToArrayTransformerTest extends TestCase
]);
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformWithNegativeMinute()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new DateTimeToArrayTransformer();
$transformer->reverseTransform([
'year' => '2010',
@@ -435,11 +412,9 @@ class DateTimeToArrayTransformerTest extends TestCase
]);
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformWithNegativeSecond()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new DateTimeToArrayTransformer();
$transformer->reverseTransform([
'year' => '2010',
@@ -451,11 +426,9 @@ class DateTimeToArrayTransformerTest extends TestCase
]);
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformWithInvalidMonth()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new DateTimeToArrayTransformer();
$transformer->reverseTransform([
'year' => '2010',
@@ -467,11 +440,9 @@ class DateTimeToArrayTransformerTest extends TestCase
]);
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformWithInvalidDay()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new DateTimeToArrayTransformer();
$transformer->reverseTransform([
'year' => '2010',
@@ -483,11 +454,9 @@ class DateTimeToArrayTransformerTest extends TestCase
]);
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformWithStringDay()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new DateTimeToArrayTransformer();
$transformer->reverseTransform([
'year' => '2010',
@@ -499,11 +468,9 @@ class DateTimeToArrayTransformerTest extends TestCase
]);
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformWithStringMonth()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new DateTimeToArrayTransformer();
$transformer->reverseTransform([
'year' => '2010',
@@ -515,11 +482,9 @@ class DateTimeToArrayTransformerTest extends TestCase
]);
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformWithStringYear()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new DateTimeToArrayTransformer();
$transformer->reverseTransform([
'year' => 'bazinga',
@@ -531,11 +496,9 @@ class DateTimeToArrayTransformerTest extends TestCase
]);
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformWithEmptyStringHour()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new DateTimeToArrayTransformer();
$transformer->reverseTransform([
'year' => '2010',
@@ -547,11 +510,9 @@ class DateTimeToArrayTransformerTest extends TestCase
]);
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformWithEmptyStringMinute()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new DateTimeToArrayTransformer();
$transformer->reverseTransform([
'year' => '2010',
@@ -563,11 +524,9 @@ class DateTimeToArrayTransformerTest extends TestCase
]);
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformWithEmptyStringSecond()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new DateTimeToArrayTransformer();
$transformer->reverseTransform([
'year' => '2010',
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToHtml5LocalDateTimeTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToHtml5LocalDateTimeTransformerTest.php
index 0db210a3c1..776009938d 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToHtml5LocalDateTimeTransformerTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToHtml5LocalDateTimeTransformerTest.php
@@ -12,11 +12,13 @@
namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToHtml5LocalDateTimeTransformer;
use Symfony\Component\Form\Tests\Extension\Core\DataTransformer\Traits\DateTimeEqualsTrait;
class DateTimeToHtml5LocalDateTimeTransformerTest extends TestCase
{
+ use ForwardCompatTestTrait;
use DateTimeEqualsTrait;
public function transformProvider()
@@ -71,11 +73,9 @@ class DateTimeToHtml5LocalDateTimeTransformerTest extends TestCase
$this->assertSame($to, $transformer->transform(null !== $from ? new \DateTimeImmutable($from) : null));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testTransformRequiresValidDateTime()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new DateTimeToHtml5LocalDateTimeTransformer();
$transformer->transform('2010-01-01');
}
@@ -94,30 +94,24 @@ class DateTimeToHtml5LocalDateTimeTransformerTest extends TestCase
}
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformRequiresString()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new DateTimeToHtml5LocalDateTimeTransformer();
$transformer->reverseTransform(12345);
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformWithNonExistingDate()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new DateTimeToHtml5LocalDateTimeTransformer('UTC', 'UTC');
$transformer->reverseTransform('2010-04-31T04:05');
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformExpectsValidDateString()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new DateTimeToHtml5LocalDateTimeTransformer('UTC', 'UTC');
$transformer->reverseTransform('2010-2010-2010');
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php
index 0248e9809d..b1287bbbca 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php
@@ -175,11 +175,9 @@ class DateTimeToLocalizedStringTransformerTest extends TestCase
$this->assertEquals($dateTime->format('d.m.Y, H:i'), $transformer->transform($input));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testTransformRequiresValidDateTime()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new DateTimeToLocalizedStringTransformer();
$transformer->transform('2010-01-01');
}
@@ -285,57 +283,45 @@ class DateTimeToLocalizedStringTransformerTest extends TestCase
$this->assertNull($transformer->reverseTransform(''));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformRequiresString()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new DateTimeToLocalizedStringTransformer();
$transformer->reverseTransform(12345);
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformWrapsIntlErrors()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new DateTimeToLocalizedStringTransformer();
$transformer->reverseTransform('12345');
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformWithNonExistingDate()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', \IntlDateFormatter::SHORT);
$this->assertDateTimeEquals($this->dateTimeWithoutSeconds, $transformer->reverseTransform('31.04.10 04:05'));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformOutOfTimestampRange()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC');
$transformer->reverseTransform('1789-07-14');
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformFiveDigitYears()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', null, null, \IntlDateFormatter::GREGORIAN, 'yyyy-MM-dd');
$transformer->reverseTransform('20107-03-21');
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformFiveDigitYearsWithTimestamp()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', null, null, \IntlDateFormatter::GREGORIAN, 'yyyy-MM-dd HH:mm:ss');
$transformer->reverseTransform('20107-03-21 12:34:56');
}
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php
index ec251d8f35..3a2d9ab8bb 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php
@@ -87,11 +87,9 @@ class DateTimeToRfc3339TransformerTest extends TestCase
$this->assertSame($to, $transformer->transform(null !== $from ? new \DateTimeImmutable($from) : null));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testTransformRequiresValidDateTime()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new DateTimeToRfc3339Transformer();
$transformer->transform('2010-01-01');
}
@@ -110,20 +108,16 @@ class DateTimeToRfc3339TransformerTest extends TestCase
}
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformRequiresString()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new DateTimeToRfc3339Transformer();
$transformer->reverseTransform(12345);
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformWithNonExistingDate()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new DateTimeToRfc3339Transformer('UTC', 'UTC');
$transformer->reverseTransform('2010-04-31T04:05Z');
@@ -131,10 +125,10 @@ class DateTimeToRfc3339TransformerTest extends TestCase
/**
* @dataProvider invalidDateStringProvider
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
*/
public function testReverseTransformExpectsValidDateString($date)
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new DateTimeToRfc3339Transformer('UTC', 'UTC');
$transformer->reverseTransform($date);
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeZoneToStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeZoneToStringTransformerTest.php
index 6aefe3cab5..6bc0cd9a54 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeZoneToStringTransformerTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeZoneToStringTransformerTest.php
@@ -12,10 +12,13 @@
namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeZoneToStringTransformer;
class DateTimeZoneToStringTransformerTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testSingle()
{
$transformer = new DateTimeZoneToStringTransformer();
@@ -38,19 +41,15 @@ class DateTimeZoneToStringTransformerTest extends TestCase
$this->assertEquals([new \DateTimeZone('Europe/Amsterdam')], $transformer->reverseTransform(['Europe/Amsterdam']));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testInvalidTimezone()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
(new DateTimeZoneToStringTransformer())->transform(1);
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testUnknownTimezone()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
(new DateTimeZoneToStringTransformer(true))->reverseTransform(['Foo/Bar']);
}
}
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php
index e84657451b..427ca9b208 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php
@@ -190,21 +190,17 @@ class IntegerToLocalizedStringTransformerTest extends TestCase
$this->assertEquals($output, $transformer->reverseTransform($input));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformExpectsString()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new IntegerToLocalizedStringTransformer();
$transformer->reverseTransform(1);
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformExpectsValidNumber()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new IntegerToLocalizedStringTransformer();
$transformer->reverseTransform('foo');
@@ -212,10 +208,10 @@ class IntegerToLocalizedStringTransformerTest extends TestCase
/**
* @dataProvider floatNumberProvider
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
*/
public function testReverseTransformExpectsInteger($number, $locale)
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault($locale);
@@ -233,41 +229,33 @@ class IntegerToLocalizedStringTransformerTest extends TestCase
];
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformDisallowsNaN()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new IntegerToLocalizedStringTransformer();
$transformer->reverseTransform('NaN');
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformDisallowsNaN2()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new IntegerToLocalizedStringTransformer();
$transformer->reverseTransform('nan');
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformDisallowsInfinity()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new IntegerToLocalizedStringTransformer();
$transformer->reverseTransform('∞');
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformDisallowsNegativeInfinity()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new IntegerToLocalizedStringTransformer();
$transformer->reverseTransform('-∞');
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntlTimeZoneToStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntlTimeZoneToStringTransformerTest.php
index 376c2ccaee..44f6ae02ae 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntlTimeZoneToStringTransformerTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntlTimeZoneToStringTransformerTest.php
@@ -41,19 +41,15 @@ class IntlTimeZoneToStringTransformerTest extends TestCase
$this->assertEquals([\IntlTimeZone::createTimeZone('Europe/Amsterdam')], $transformer->reverseTransform(['Europe/Amsterdam']));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testInvalidTimezone()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
(new IntlTimeZoneToStringTransformer())->transform(1);
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testUnknownTimezone()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
(new IntlTimeZoneToStringTransformer(true))->reverseTransform(['Foo/Bar']);
}
}
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php
index fd3f570d4c..c4e8c7a3d6 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php
@@ -400,11 +400,9 @@ class NumberToLocalizedStringTransformerTest extends TestCase
$this->assertEquals(1234.5, $transformer->reverseTransform('1234.5'));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDot()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
// Since we test against "de_DE", we need the full implementation
IntlTestHelper::requireFullIntl($this, '4.8.1.1');
@@ -415,11 +413,9 @@ class NumberToLocalizedStringTransformerTest extends TestCase
$transformer->reverseTransform('1.234.5');
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDotWithNoGroupSep()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
// Since we test against "de_DE", we need the full implementation
IntlTestHelper::requireFullIntl($this, '4.8.1.1');
@@ -459,11 +455,9 @@ class NumberToLocalizedStringTransformerTest extends TestCase
$this->assertEquals(1234.5, $transformer->reverseTransform('1234,5'));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsComma()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
IntlTestHelper::requireFullIntl($this, '4.8.1.1');
$transformer = new NumberToLocalizedStringTransformer(null, true);
@@ -471,11 +465,9 @@ class NumberToLocalizedStringTransformerTest extends TestCase
$transformer->reverseTransform('1,234,5');
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsCommaWithNoGroupSep()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
IntlTestHelper::requireFullIntl($this, '4.8.1.1');
$transformer = new NumberToLocalizedStringTransformer(null, true);
@@ -491,44 +483,37 @@ class NumberToLocalizedStringTransformerTest extends TestCase
$this->assertEquals(1234.5, $transformer->reverseTransform('1234.5'));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testTransformExpectsNumeric()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new NumberToLocalizedStringTransformer();
$transformer->transform('foo');
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformExpectsString()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new NumberToLocalizedStringTransformer();
$transformer->reverseTransform(1);
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformExpectsValidNumber()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new NumberToLocalizedStringTransformer();
$transformer->reverseTransform('foo');
}
/**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
* @dataProvider nanRepresentationProvider
- *
* @see https://github.com/symfony/symfony/issues/3161
*/
public function testReverseTransformDisallowsNaN($nan)
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new NumberToLocalizedStringTransformer();
$transformer->reverseTransform($nan);
@@ -543,63 +528,51 @@ class NumberToLocalizedStringTransformerTest extends TestCase
];
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformDisallowsInfinity()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new NumberToLocalizedStringTransformer();
$transformer->reverseTransform('∞');
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformDisallowsInfinity2()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new NumberToLocalizedStringTransformer();
$transformer->reverseTransform('∞,123');
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformDisallowsNegativeInfinity()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new NumberToLocalizedStringTransformer();
$transformer->reverseTransform('-∞');
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformDisallowsLeadingExtraCharacters()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new NumberToLocalizedStringTransformer();
$transformer->reverseTransform('foo123');
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- * @expectedExceptionMessage The number contains unrecognized characters: "foo3"
- */
public function testReverseTransformDisallowsCenteredExtraCharacters()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
+ $this->expectExceptionMessage('The number contains unrecognized characters: "foo3"');
$transformer = new NumberToLocalizedStringTransformer();
$transformer->reverseTransform('12foo3');
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- * @expectedExceptionMessage The number contains unrecognized characters: "foo8"
- */
public function testReverseTransformDisallowsCenteredExtraCharactersMultibyte()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
+ $this->expectExceptionMessage('The number contains unrecognized characters: "foo8"');
// Since we test against other locales, we need the full implementation
IntlTestHelper::requireFullIntl($this, false);
@@ -610,12 +583,10 @@ class NumberToLocalizedStringTransformerTest extends TestCase
$transformer->reverseTransform("12\xc2\xa0345,67foo8");
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- * @expectedExceptionMessage The number contains unrecognized characters: "foo8"
- */
public function testReverseTransformIgnoresTrailingSpacesInExceptionMessage()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
+ $this->expectExceptionMessage('The number contains unrecognized characters: "foo8"');
// Since we test against other locales, we need the full implementation
IntlTestHelper::requireFullIntl($this, false);
@@ -626,23 +597,19 @@ class NumberToLocalizedStringTransformerTest extends TestCase
$transformer->reverseTransform("12\xc2\xa0345,67foo8 \xc2\xa0\t");
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- * @expectedExceptionMessage The number contains unrecognized characters: "foo"
- */
public function testReverseTransformDisallowsTrailingExtraCharacters()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
+ $this->expectExceptionMessage('The number contains unrecognized characters: "foo"');
$transformer = new NumberToLocalizedStringTransformer();
$transformer->reverseTransform('123foo');
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- * @expectedExceptionMessage The number contains unrecognized characters: "foo"
- */
public function testReverseTransformDisallowsTrailingExtraCharactersMultibyte()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
+ $this->expectExceptionMessage('The number contains unrecognized characters: "foo"');
// Since we test against other locales, we need the full implementation
IntlTestHelper::requireFullIntl($this, false);
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php
index e2dfc481b3..06ef6cc736 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php
@@ -145,11 +145,9 @@ class PercentToLocalizedStringTransformerTest extends TestCase
$this->assertEquals(1234.5, $transformer->reverseTransform('1234.5'));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDot()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
// Since we test against "de_DE", we need the full implementation
IntlTestHelper::requireFullIntl($this, '4.8.1.1');
@@ -160,11 +158,9 @@ class PercentToLocalizedStringTransformerTest extends TestCase
$transformer->reverseTransform('1.234.5');
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDotWithNoGroupSep()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
// Since we test against "de_DE", we need the full implementation
IntlTestHelper::requireFullIntl($this, '4.8.1.1');
@@ -204,11 +200,9 @@ class PercentToLocalizedStringTransformerTest extends TestCase
$this->assertEquals(1234.5, $transformer->reverseTransform('1234,5'));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsComma()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
IntlTestHelper::requireFullIntl($this, '4.8.1.1');
$transformer = new PercentToLocalizedStringTransformer(1, 'integer');
@@ -216,11 +210,9 @@ class PercentToLocalizedStringTransformerTest extends TestCase
$transformer->reverseTransform('1,234,5');
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsCommaWithNoGroupSep()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
IntlTestHelper::requireFullIntl($this, '4.8.1.1');
$transformer = new PercentToLocalizedStringTransformer(1, 'integer');
@@ -246,34 +238,30 @@ class PercentToLocalizedStringTransformerTest extends TestCase
$this->assertEquals(1234.5, $transformer->reverseTransform('1234.5'));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformDisallowsLeadingExtraCharacters()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new PercentToLocalizedStringTransformer();
$transformer->reverseTransform('foo123');
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- * @expectedExceptionMessage The number contains unrecognized characters: "foo3"
- */
public function testReverseTransformDisallowsCenteredExtraCharacters()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
+ $this->expectExceptionMessage('The number contains unrecognized characters: "foo3"');
$transformer = new PercentToLocalizedStringTransformer();
$transformer->reverseTransform('12foo3');
}
/**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- * @expectedExceptionMessage The number contains unrecognized characters: "foo8"
* @requires extension mbstring
*/
public function testReverseTransformDisallowsCenteredExtraCharactersMultibyte()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
+ $this->expectExceptionMessage('The number contains unrecognized characters: "foo8"');
// Since we test against other locales, we need the full implementation
IntlTestHelper::requireFullIntl($this, false);
@@ -284,24 +272,22 @@ class PercentToLocalizedStringTransformerTest extends TestCase
$transformer->reverseTransform("12\xc2\xa0345,67foo8");
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- * @expectedExceptionMessage The number contains unrecognized characters: "foo"
- */
public function testReverseTransformDisallowsTrailingExtraCharacters()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
+ $this->expectExceptionMessage('The number contains unrecognized characters: "foo"');
$transformer = new PercentToLocalizedStringTransformer();
$transformer->reverseTransform('123foo');
}
/**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- * @expectedExceptionMessage The number contains unrecognized characters: "foo"
* @requires extension mbstring
*/
public function testReverseTransformDisallowsTrailingExtraCharactersMultibyte()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
+ $this->expectExceptionMessage('The number contains unrecognized characters: "foo"');
// Since we test against other locales, we need the full implementation
IntlTestHelper::requireFullIntl($this, false);
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/StringToFloatTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/StringToFloatTransformerTest.php
index 2eae3121b6..d2c800be67 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/StringToFloatTransformerTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/StringToFloatTransformerTest.php
@@ -49,20 +49,16 @@ class StringToFloatTransformerTest extends TestCase
$this->assertSame($to, $transformer->transform($from));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testFailIfTransformingANonString(): void
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new StringToFloatTransformer();
$transformer->transform(1.0);
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testFailIfTransformingANonNumericString(): void
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new StringToFloatTransformer();
$transformer->transform('foobar');
}
@@ -93,11 +89,9 @@ class StringToFloatTransformerTest extends TestCase
$this->assertSame($to, $transformer->reverseTransform($from));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testFailIfReverseTransformingANonNumeric(): void
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$transformer = new StringToFloatTransformer();
$transformer->reverseTransform('foobar');
}
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ValueToDuplicatesTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ValueToDuplicatesTransformerTest.php
index 179ace5a6c..c02eb3573e 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ValueToDuplicatesTransformerTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ValueToDuplicatesTransformerTest.php
@@ -108,11 +108,9 @@ class ValueToDuplicatesTransformerTest extends TestCase
$this->assertSame('0', $this->transformer->reverseTransform($input));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformPartiallyNull()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$input = [
'a' => 'Foo',
'b' => 'Foo',
@@ -122,11 +120,9 @@ class ValueToDuplicatesTransformerTest extends TestCase
$this->transformer->reverseTransform($input);
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformDifferences()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$input = [
'a' => 'Foo',
'b' => 'Bar',
@@ -136,11 +132,9 @@ class ValueToDuplicatesTransformerTest extends TestCase
$this->transformer->reverseTransform($input);
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- */
public function testReverseTransformRequiresArray()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
$this->transformer->reverseTransform('12345');
}
}
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerTest.php
index daf5d60d37..67545d6f29 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerTest.php
@@ -185,10 +185,10 @@ abstract class MergeCollectionListenerTest extends TestCase
/**
* @dataProvider getBooleanMatrix2
- * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
*/
public function testRequireArrayOrTraversable($allowAdd, $allowDelete)
{
+ $this->expectException('Symfony\Component\Form\Exception\UnexpectedTypeException');
$newData = 'no array or traversable';
$event = new FormEvent($this->form, $newData);
$listener = new MergeCollectionListener($allowAdd, $allowDelete);
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php
index a1775efe9f..4c3ff17b4c 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php
@@ -69,11 +69,9 @@ class ResizeFormListenerTest extends TestCase
$this->assertTrue($this->form->has('2'));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
- */
public function testPreSetDataRequiresArrayOrTraversable()
{
+ $this->expectException('Symfony\Component\Form\Exception\UnexpectedTypeException');
$data = 'no array or traversable';
$event = new FormEvent($this->form, $data);
$listener = new ResizeFormListener('text', [], false, false);
@@ -204,11 +202,9 @@ class ResizeFormListenerTest extends TestCase
$this->assertEquals($data, $event->getData());
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
- */
public function testOnSubmitNormDataRequiresArrayOrTraversable()
{
+ $this->expectException('Symfony\Component\Form\Exception\UnexpectedTypeException');
$data = 'no array or traversable';
$event = new FormEvent($this->form, $data);
$listener = new ResizeFormListener('text', [], false, false);
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/BirthdayTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/BirthdayTypeTest.php
index ffadf8c844..01e08d09ff 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/BirthdayTypeTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/BirthdayTypeTest.php
@@ -11,18 +11,20 @@
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
+
/**
* @author Stepan Anchugov
*/
class BirthdayTypeTest extends DateTypeTest
{
+ use ForwardCompatTestTrait;
+
const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\BirthdayType';
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- */
public function testSetInvalidYearsOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
$this->factory->create(static::TESTED_TYPE, null, [
'years' => 'bad value',
]);
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ButtonTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ButtonTypeTest.php
index 350602306f..98df91d7e8 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ButtonTypeTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ButtonTypeTest.php
@@ -11,11 +11,15 @@
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
+
/**
* @author Bernhard Schussek
*/
class ButtonTypeTest extends BaseTypeTest
{
+ use ForwardCompatTestTrait;
+
const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\ButtonType';
public function testCreateButtonInstances()
@@ -24,14 +28,14 @@ class ButtonTypeTest extends BaseTypeTest
}
/**
- * @expectedException \Symfony\Component\Form\Exception\BadMethodCallException
- * @expectedExceptionMessage Buttons do not support empty data.
*
* @param string $emptyData
* @param null $expectedData
*/
public function testSubmitNullUsesDefaultEmptyData($emptyData = 'empty', $expectedData = null)
{
+ $this->expectException('Symfony\Component\Form\Exception\BadMethodCallException');
+ $this->expectExceptionMessage('Buttons do not support empty data.');
parent::testSubmitNullUsesDefaultEmptyData($emptyData, $expectedData);
}
}
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CheckboxTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CheckboxTypeTest.php
index d8f0cba025..265e5e2b09 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CheckboxTypeTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CheckboxTypeTest.php
@@ -194,11 +194,9 @@ class CheckboxTypeTest extends BaseTypeTest
];
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- */
public function testDontAllowNonArrayFalseValues()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
$this->expectExceptionMessageRegExp('/"false_values" with value "invalid" is expected to be of type "array"/');
$this->factory->create(static::TESTED_TYPE, null, [
'false_values' => 'invalid',
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php
index 33812c552c..af3ba6237b 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php
@@ -83,21 +83,17 @@ class ChoiceTypeTest extends BaseTypeTest
$this->objectChoices = null;
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- */
public function testChoicesOptionExpectsArrayOrTraversable()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
$this->factory->create(static::TESTED_TYPE, null, [
'choices' => new \stdClass(),
]);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- */
public function testChoiceLoaderOptionExpectsChoiceLoaderInterface()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
$this->factory->create(static::TESTED_TYPE, null, [
'choice_loader' => new \stdClass(),
]);
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php
index a8513cceff..a2ab7ee9d8 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php
@@ -38,21 +38,17 @@ class DateTypeTest extends BaseTypeTest
\Locale::setDefault($this->defaultLocale);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- */
public function testInvalidWidgetOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
$this->factory->create(static::TESTED_TYPE, null, [
'widget' => 'fake_widget',
]);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- */
public function testInvalidInputOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
$this->factory->create(static::TESTED_TYPE, null, [
'input' => 'fake_input',
]);
@@ -376,11 +372,10 @@ class DateTypeTest extends BaseTypeTest
/**
* This test is to check that the strings '0', '1', '2', '3' are not accepted
* as valid IntlDateFormatter constants for FULL, LONG, MEDIUM or SHORT respectively.
- *
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
*/
public function testThrowExceptionIfFormatIsNoPattern()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
$this->factory->create(static::TESTED_TYPE, null, [
'format' => '0',
'html5' => false,
@@ -389,24 +384,20 @@ class DateTypeTest extends BaseTypeTest
]);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- * @expectedExceptionMessage The "format" option should contain the letters "y", "M" and "d". Its current value is "yy".
- */
public function testThrowExceptionIfFormatDoesNotContainYearMonthAndDay()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
+ $this->expectExceptionMessage('The "format" option should contain the letters "y", "M" and "d". Its current value is "yy".');
$this->factory->create(static::TESTED_TYPE, null, [
'months' => [6, 7],
'format' => 'yy',
]);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- * @expectedExceptionMessage The "format" option should contain the letters "y", "M" or "d". Its current value is "wrong".
- */
public function testThrowExceptionIfFormatMissesYearMonthAndDayWithSingleTextWidget()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
+ $this->expectExceptionMessage('The "format" option should contain the letters "y", "M" or "d". Its current value is "wrong".');
$this->factory->create(static::TESTED_TYPE, null, [
'widget' => 'single_text',
'format' => 'wrong',
@@ -414,51 +405,41 @@ class DateTypeTest extends BaseTypeTest
]);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- */
public function testThrowExceptionIfFormatIsNoConstant()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
$this->factory->create(static::TESTED_TYPE, null, [
'format' => 105,
]);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- */
public function testThrowExceptionIfFormatIsInvalid()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
$this->factory->create(static::TESTED_TYPE, null, [
'format' => [],
]);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- */
public function testThrowExceptionIfYearsIsInvalid()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
$this->factory->create(static::TESTED_TYPE, null, [
'years' => 'bad value',
]);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- */
public function testThrowExceptionIfMonthsIsInvalid()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
$this->factory->create(static::TESTED_TYPE, null, [
'months' => 'bad value',
]);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- */
public function testThrowExceptionIfDaysIsInvalid()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
$this->factory->create(static::TESTED_TYPE, null, [
'days' => 'bad value',
]);
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php
index 2607f1d376..4dcb3c34a0 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php
@@ -11,6 +11,7 @@
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Form\CallbackTransformer;
use Symfony\Component\Form\DataMapperInterface;
use Symfony\Component\Form\Exception\TransformationFailedException;
@@ -59,6 +60,8 @@ class FormTest_AuthorWithoutRefSetter
class FormTypeTest extends BaseTypeTest
{
+ use ForwardCompatTestTrait;
+
const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\FormType';
public function testCreateFormInstances()
@@ -168,11 +171,9 @@ class FormTypeTest extends BaseTypeTest
]));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException
- */
public function testDataClassMustBeValidClassOrInterface()
{
+ $this->expectException('Symfony\Component\Form\Exception\InvalidArgumentException');
$this->factory->createBuilder(static::TESTED_TYPE, null, [
'data_class' => 'foobar',
]);
@@ -337,11 +338,9 @@ class FormTypeTest extends BaseTypeTest
$this->assertEquals('Bernhard', $author->firstName);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- */
public function testAttributesException()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
$this->factory->create(static::TESTED_TYPE, null, ['attr' => '']);
}
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/NumberTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/NumberTypeTest.php
index 75e415fce2..08fd2d5406 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/NumberTypeTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/NumberTypeTest.php
@@ -80,24 +80,22 @@ class NumberTypeTest extends BaseTypeTest
$this->assertSame('12345,68', $form->createView()->vars['value']);
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- * @expectedExceptionMessage Expected a numeric string.
- */
public function testStringInputWithFloatData(): void
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
+ $this->expectExceptionMessage('Expected a numeric string.');
+
$this->factory->create(static::TESTED_TYPE, 12345.6789, [
'input' => 'string',
'scale' => 2,
]);
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- * @expectedExceptionMessage Expected a numeric string.
- */
public function testStringInputWithIntData(): void
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
+ $this->expectExceptionMessage('Expected a numeric string.');
+
$this->factory->create(static::TESTED_TYPE, 12345, [
'input' => 'string',
'scale' => 2,
@@ -182,11 +180,9 @@ class NumberTypeTest extends BaseTypeTest
$this->assertSame('12345.55', $form->getViewData());
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\LogicException
- */
public function testGroupingNotAllowedWithHtml5Widget()
{
+ $this->expectException('Symfony\Component\Form\Exception\LogicException');
$this->factory->create(static::TESTED_TYPE, null, [
'grouping' => true,
'html5' => true,
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/RepeatedTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/RepeatedTypeTest.php
index de99a9b9f1..3d49ae83f8 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/RepeatedTypeTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/RepeatedTypeTest.php
@@ -81,33 +81,27 @@ class RepeatedTypeTest extends BaseTypeTest
$this->assertFalse($form['second']->isRequired());
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- */
public function testSetInvalidOptions()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
$this->factory->create(static::TESTED_TYPE, null, [
'type' => TextTypeTest::TESTED_TYPE,
'options' => 'bad value',
]);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- */
public function testSetInvalidFirstOptions()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
$this->factory->create(static::TESTED_TYPE, null, [
'type' => TextTypeTest::TESTED_TYPE,
'first_options' => 'bad value',
]);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- */
public function testSetInvalidSecondOptions()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
$this->factory->create(static::TESTED_TYPE, null, [
'type' => TextTypeTest::TESTED_TYPE,
'second_options' => 'bad value',
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php
index d5b4a11ced..b161ba99f7 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php
@@ -11,11 +11,14 @@
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
use Symfony\Component\Form\FormError;
class TimeTypeTest extends BaseTypeTest
{
+ use ForwardCompatTestTrait;
+
const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\TimeType';
public function testSubmitDateTime()
@@ -425,12 +428,11 @@ class TimeTypeTest extends BaseTypeTest
$this->assertSame(['hour' => '16', 'minute' => '9', 'second' => '10'], $form->getViewData());
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\LogicException
- * @expectedExceptionMessage Using different values for the "model_timezone" and "view_timezone" options without configuring a reference date is not supported.
- */
public function testSetDataDifferentTimezonesWithoutReferenceDate()
{
+ $this->expectException('Symfony\Component\Form\Exception\LogicException');
+ $this->expectExceptionMessage('Using different values for the "model_timezone" and "view_timezone" options without configuring a reference date is not supported.');
+
$form = $this->factory->create(static::TESTED_TYPE, null, [
'model_timezone' => 'UTC',
'view_timezone' => 'Europe/Berlin',
@@ -807,52 +809,42 @@ class TimeTypeTest extends BaseTypeTest
$this->assertSame([$error], iterator_to_array($form->getErrors()));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\InvalidConfigurationException
- */
public function testInitializeWithSecondsAndWithoutMinutes()
{
+ $this->expectException('Symfony\Component\Form\Exception\InvalidConfigurationException');
$this->factory->create(static::TESTED_TYPE, null, [
'with_minutes' => false,
'with_seconds' => true,
]);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- */
public function testThrowExceptionIfHoursIsInvalid()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
$this->factory->create(static::TESTED_TYPE, null, [
'hours' => 'bad value',
]);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- */
public function testThrowExceptionIfMinutesIsInvalid()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
$this->factory->create(static::TESTED_TYPE, null, [
'minutes' => 'bad value',
]);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- */
public function testThrowExceptionIfSecondsIsInvalid()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
$this->factory->create(static::TESTED_TYPE, null, [
'seconds' => 'bad value',
]);
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\InvalidConfigurationException
- */
public function testReferenceDateTimezoneMustMatchModelTimezone()
{
+ $this->expectException('Symfony\Component\Form\Exception\InvalidConfigurationException');
$this->factory->create(static::TESTED_TYPE, null, [
'model_timezone' => 'UTC',
'view_timezone' => 'Europe/Berlin',
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimezoneTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimezoneTypeTest.php
index d514dc85a8..32582f99be 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimezoneTypeTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimezoneTypeTest.php
@@ -167,12 +167,10 @@ class TimezoneTypeTest extends BaseTypeTest
$this->assertContains(new ChoiceView('Etc/UTC', 'Etc/UTC', 'за всесвітнім координованим часом'), $choices, '', false, false);
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\LogicException
- * @expectedExceptionMessage The "choice_translation_locale" option can only be used if the "intl" option is set to true.
- */
public function testChoiceTranslationLocaleOptionWithoutIntl()
{
+ $this->expectException('Symfony\Component\Form\Exception\LogicException');
+ $this->expectExceptionMessage('The "choice_translation_locale" option can only be used if the "intl" option is set to true.');
$this->factory->create(static::TESTED_TYPE, null, [
'choice_translation_locale' => 'uk',
]);
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/UrlTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/UrlTypeTest.php
index a5608557dd..4ea231dc3a 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/UrlTypeTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/UrlTypeTest.php
@@ -11,8 +11,12 @@
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
+
class UrlTypeTest extends TextTypeTest
{
+ use ForwardCompatTestTrait;
+
const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\UrlType';
public function testSubmitAddsDefaultProtocolIfNoneIsIncluded()
@@ -73,11 +77,9 @@ class UrlTypeTest extends TextTypeTest
$this->assertSame('www.domain.com', $form->getViewData());
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- */
public function testThrowExceptionIfDefaultProtocolIsInvalid()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
$this->factory->create(static::TESTED_TYPE, null, [
'default_protocol' => [],
]);
diff --git a/src/Symfony/Component/Form/Tests/Extension/DependencyInjection/DependencyInjectionExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/DependencyInjection/DependencyInjectionExtensionTest.php
index 62a1ec286d..992d2f692f 100644
--- a/src/Symfony/Component/Form/Tests/Extension/DependencyInjection/DependencyInjectionExtensionTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/DependencyInjection/DependencyInjectionExtensionTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\Form\Tests\Extension\DependencyInjection;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\Extension\DependencyInjection\DependencyInjectionExtension;
@@ -20,6 +21,8 @@ use Symfony\Component\Form\FormTypeGuesserInterface;
class DependencyInjectionExtensionTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testGetTypeExtensions()
{
$typeExtension1 = new TestTypeExtension();
@@ -41,11 +44,9 @@ class DependencyInjectionExtensionTest extends TestCase
$this->assertSame([$typeExtension3, $typeExtension4], $extension->getTypeExtensions('other'));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException
- */
public function testThrowExceptionForInvalidExtendedType()
{
+ $this->expectException('Symfony\Component\Form\Exception\InvalidArgumentException');
$extensions = [
'unmatched' => new \ArrayIterator([new TestTypeExtension()]),
];
diff --git a/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php b/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php
index dc082505a1..2de65c7c18 100644
--- a/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php
@@ -11,6 +11,7 @@
namespace Symfony\Component\Form\Tests\Extension\HttpFoundation;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationRequestHandler;
use Symfony\Component\Form\Tests\AbstractRequestHandlerTest;
use Symfony\Component\HttpFoundation\File\UploadedFile;
@@ -21,19 +22,17 @@ use Symfony\Component\HttpFoundation\Request;
*/
class HttpFoundationRequestHandlerTest extends AbstractRequestHandlerTest
{
- /**
- * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
- */
+ use ForwardCompatTestTrait;
+
public function testRequestShouldNotBeNull()
{
+ $this->expectException('Symfony\Component\Form\Exception\UnexpectedTypeException');
$this->requestHandler->handleRequest($this->createForm('name', 'GET'));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
- */
public function testRequestShouldBeInstanceOfRequest()
{
+ $this->expectException('Symfony\Component\Form\Exception\UnexpectedTypeException');
$this->requestHandler->handleRequest($this->createForm('name', 'GET'), new \stdClass());
}
diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationPathTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationPathTest.php
index 7a6602d27e..889cc6bd8e 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationPathTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationPathTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\Form\Tests\Extension\Validator\ViolationMapper;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Form\Extension\Validator\ViolationMapper\ViolationPath;
/**
@@ -19,6 +20,8 @@ use Symfony\Component\Form\Extension\Validator\ViolationMapper\ViolationPath;
*/
class ViolationPathTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function providePaths()
{
return [
@@ -140,21 +143,17 @@ class ViolationPathTest extends TestCase
$this->assertEquals('street', $path->getElement(1));
}
- /**
- * @expectedException \OutOfBoundsException
- */
public function testGetElementDoesNotAcceptInvalidIndices()
{
+ $this->expectException('OutOfBoundsException');
$path = new ViolationPath('children[address].data[street].name');
$path->getElement(3);
}
- /**
- * @expectedException \OutOfBoundsException
- */
public function testGetElementDoesNotAcceptNegativeIndices()
{
+ $this->expectException('OutOfBoundsException');
$path = new ViolationPath('children[address].data[street].name');
$path->getElement(-1);
@@ -168,21 +167,17 @@ class ViolationPathTest extends TestCase
$this->assertTrue($path->isProperty(2));
}
- /**
- * @expectedException \OutOfBoundsException
- */
public function testIsPropertyDoesNotAcceptInvalidIndices()
{
+ $this->expectException('OutOfBoundsException');
$path = new ViolationPath('children[address].data[street].name');
$path->isProperty(3);
}
- /**
- * @expectedException \OutOfBoundsException
- */
public function testIsPropertyDoesNotAcceptNegativeIndices()
{
+ $this->expectException('OutOfBoundsException');
$path = new ViolationPath('children[address].data[street].name');
$path->isProperty(-1);
@@ -196,21 +191,17 @@ class ViolationPathTest extends TestCase
$this->assertFalse($path->isIndex(2));
}
- /**
- * @expectedException \OutOfBoundsException
- */
public function testIsIndexDoesNotAcceptInvalidIndices()
{
+ $this->expectException('OutOfBoundsException');
$path = new ViolationPath('children[address].data[street].name');
$path->isIndex(3);
}
- /**
- * @expectedException \OutOfBoundsException
- */
public function testIsIndexDoesNotAcceptNegativeIndices()
{
+ $this->expectException('OutOfBoundsException');
$path = new ViolationPath('children[address].data[street].name');
$path->isIndex(-1);
@@ -225,21 +216,17 @@ class ViolationPathTest extends TestCase
$this->assertFalse($path->mapsForm(2));
}
- /**
- * @expectedException \OutOfBoundsException
- */
public function testMapsFormDoesNotAcceptInvalidIndices()
{
+ $this->expectException('OutOfBoundsException');
$path = new ViolationPath('children[address].data[street].name');
$path->mapsForm(3);
}
- /**
- * @expectedException \OutOfBoundsException
- */
public function testMapsFormDoesNotAcceptNegativeIndices()
{
+ $this->expectException('OutOfBoundsException');
$path = new ViolationPath('children[address].data[street].name');
$path->mapsForm(-1);
diff --git a/src/Symfony/Component/Form/Tests/FormFactoryTest.php b/src/Symfony/Component/Form/Tests/FormFactoryTest.php
index 965485cf2c..9250ee4cf2 100644
--- a/src/Symfony/Component/Form/Tests/FormFactoryTest.php
+++ b/src/Symfony/Component/Form/Tests/FormFactoryTest.php
@@ -149,21 +149,17 @@ class FormFactoryTest extends TestCase
$this->assertSame($this->builder, $this->factory->createNamedBuilder('name', 'type', 'DATA', $options));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
- * @expectedExceptionMessage Expected argument of type "string", "stdClass" given
- */
public function testCreateNamedBuilderThrowsUnderstandableException()
{
+ $this->expectException('Symfony\Component\Form\Exception\UnexpectedTypeException');
+ $this->expectExceptionMessage('Expected argument of type "string", "stdClass" given');
$this->factory->createNamedBuilder('name', new \stdClass());
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
- * @expectedExceptionMessage Expected argument of type "string", "stdClass" given
- */
public function testCreateThrowsUnderstandableException()
{
+ $this->expectException('Symfony\Component\Form\Exception\UnexpectedTypeException');
+ $this->expectExceptionMessage('Expected argument of type "string", "stdClass" given');
$this->factory->create(new \stdClass());
}
diff --git a/src/Symfony/Component/Form/Tests/FormRegistryTest.php b/src/Symfony/Component/Form/Tests/FormRegistryTest.php
index 8d72db3391..21096b746d 100644
--- a/src/Symfony/Component/Form/Tests/FormRegistryTest.php
+++ b/src/Symfony/Component/Form/Tests/FormRegistryTest.php
@@ -105,19 +105,15 @@ class FormRegistryTest extends TestCase
$this->assertSame($resolvedType, $this->registry->getType('Symfony\Component\Form\Tests\Fixtures\FooType'));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException
- */
public function testFailIfUnregisteredTypeNoClass()
{
+ $this->expectException('Symfony\Component\Form\Exception\InvalidArgumentException');
$this->registry->getType('Symfony\Blubb');
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException
- */
public function testFailIfUnregisteredTypeNoFormType()
{
+ $this->expectException('Symfony\Component\Form\Exception\InvalidArgumentException');
$this->registry->getType('stdClass');
}
@@ -163,12 +159,10 @@ class FormRegistryTest extends TestCase
$this->assertSame($resolvedType, $this->registry->getType(\get_class($type)));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\LogicException
- * @expectedExceptionMessage Circular reference detected for form type "Symfony\Component\Form\Tests\Fixtures\FormWithSameParentType" (Symfony\Component\Form\Tests\Fixtures\FormWithSameParentType > Symfony\Component\Form\Tests\Fixtures\FormWithSameParentType).
- */
public function testFormCannotHaveItselfAsAParent()
{
+ $this->expectException('Symfony\Component\Form\Exception\LogicException');
+ $this->expectExceptionMessage('Circular reference detected for form type "Symfony\Component\Form\Tests\Fixtures\FormWithSameParentType" (Symfony\Component\Form\Tests\Fixtures\FormWithSameParentType > Symfony\Component\Form\Tests\Fixtures\FormWithSameParentType).');
$type = new FormWithSameParentType();
$this->extension2->addType($type);
@@ -176,12 +170,10 @@ class FormRegistryTest extends TestCase
$this->registry->getType(FormWithSameParentType::class);
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\LogicException
- * @expectedExceptionMessage Circular reference detected for form type "Symfony\Component\Form\Tests\Fixtures\RecursiveFormTypeFoo" (Symfony\Component\Form\Tests\Fixtures\RecursiveFormTypeFoo > Symfony\Component\Form\Tests\Fixtures\RecursiveFormTypeBar > Symfony\Component\Form\Tests\Fixtures\RecursiveFormTypeBaz > Symfony\Component\Form\Tests\Fixtures\RecursiveFormTypeFoo).
- */
public function testRecursiveFormDependencies()
{
+ $this->expectException('Symfony\Component\Form\Exception\LogicException');
+ $this->expectExceptionMessage('Circular reference detected for form type "Symfony\Component\Form\Tests\Fixtures\RecursiveFormTypeFoo" (Symfony\Component\Form\Tests\Fixtures\RecursiveFormTypeFoo > Symfony\Component\Form\Tests\Fixtures\RecursiveFormTypeBar > Symfony\Component\Form\Tests\Fixtures\RecursiveFormTypeBaz > Symfony\Component\Form\Tests\Fixtures\RecursiveFormTypeFoo).');
$foo = new RecursiveFormTypeFoo();
$bar = new RecursiveFormTypeBar();
$baz = new RecursiveFormTypeBaz();
@@ -193,11 +185,9 @@ class FormRegistryTest extends TestCase
$this->registry->getType(RecursiveFormTypeFoo::class);
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException
- */
public function testGetTypeThrowsExceptionIfTypeNotFound()
{
+ $this->expectException('Symfony\Component\Form\Exception\InvalidArgumentException');
$this->registry->getType('bar');
}
diff --git a/src/Symfony/Component/Form/Tests/FormRendererTest.php b/src/Symfony/Component/Form/Tests/FormRendererTest.php
index 43d0bec67a..8c85fd84ff 100644
--- a/src/Symfony/Component/Form/Tests/FormRendererTest.php
+++ b/src/Symfony/Component/Form/Tests/FormRendererTest.php
@@ -29,12 +29,11 @@ class FormRendererTest extends TestCase
$this->assertEquals('Is active', $renderer->humanize('isActive'));
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\BadMethodCallException
- * @expectedExceptionMessage Field "foo" has already been rendered, save the result of previous render call to a variable and output that instead.
- */
public function testRenderARenderedField()
{
+ $this->expectException('Symfony\Component\Form\Exception\BadMethodCallException');
+ $this->expectExceptionMessage('Field "foo" has already been rendered, save the result of previous render call to a variable and output that instead.');
+
$formView = new FormView();
$formView->vars['name'] = 'foo';
$formView->setRendered();
diff --git a/src/Symfony/Component/Form/Tests/Guess/GuessTest.php b/src/Symfony/Component/Form/Tests/Guess/GuessTest.php
index eea423bb9d..304eba3fa6 100644
--- a/src/Symfony/Component/Form/Tests/Guess/GuessTest.php
+++ b/src/Symfony/Component/Form/Tests/Guess/GuessTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\Form\Tests\Guess;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Form\Guess\Guess;
class TestGuess extends Guess
@@ -20,6 +21,8 @@ class TestGuess extends Guess
class GuessTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testGetBestGuessReturnsGuessWithHighestConfidence()
{
$guess1 = new TestGuess(Guess::MEDIUM_CONFIDENCE);
@@ -29,11 +32,9 @@ class GuessTest extends TestCase
$this->assertSame($guess3, Guess::getBestGuess([$guess1, $guess2, $guess3]));
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testGuessExpectsValidConfidence()
{
+ $this->expectException('\InvalidArgumentException');
new TestGuess(5);
}
}
diff --git a/src/Symfony/Component/Form/Tests/NativeRequestHandlerTest.php b/src/Symfony/Component/Form/Tests/NativeRequestHandlerTest.php
index ab66904617..12230a803d 100644
--- a/src/Symfony/Component/Form/Tests/NativeRequestHandlerTest.php
+++ b/src/Symfony/Component/Form/Tests/NativeRequestHandlerTest.php
@@ -51,11 +51,9 @@ class NativeRequestHandlerTest extends AbstractRequestHandlerTest
$_SERVER = self::$serverBackup;
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
- */
public function testRequestShouldBeNull()
{
+ $this->expectException('Symfony\Component\Form\Exception\UnexpectedTypeException');
$this->requestHandler->handleRequest($this->createForm('name', 'GET'), 'request');
}
diff --git a/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php b/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php
index ba55993cd6..e3dc671bfb 100644
--- a/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php
+++ b/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php
@@ -182,12 +182,10 @@ class ResolvedFormTypeTest extends TestCase
$this->assertSame('\stdClass', $builder->getDataClass());
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\MissingOptionsException
- * @expectedExceptionMessage An error has occurred resolving the options of the form "stdClass": The required option "foo" is missing.
- */
public function testFailsCreateBuilderOnInvalidFormOptionsResolution()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\MissingOptionsException');
+ $this->expectExceptionMessage('An error has occurred resolving the options of the form "stdClass": The required option "foo" is missing.');
$optionsResolver = (new OptionsResolver())
->setRequired('foo')
;
diff --git a/src/Symfony/Component/Form/Tests/SimpleFormTest.php b/src/Symfony/Component/Form/Tests/SimpleFormTest.php
index 284738313b..a814b34532 100644
--- a/src/Symfony/Component/Form/Tests/SimpleFormTest.php
+++ b/src/Symfony/Component/Form/Tests/SimpleFormTest.php
@@ -11,6 +11,7 @@
namespace Symfony\Component\Form\Tests;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\Form\Exception\TransformationFailedException;
use Symfony\Component\Form\Form;
@@ -54,6 +55,8 @@ class SimpleFormTest_Traversable implements \IteratorAggregate
class SimpleFormTest extends AbstractFormTest
{
+ use ForwardCompatTestTrait;
+
/**
* @dataProvider provideFormNames
*/
@@ -94,12 +97,10 @@ class SimpleFormTest extends AbstractFormTest
$this->assertSame('bar', $form->getViewData());
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
- * @expectedExceptionMessage Unable to transform data for property path "name": No mapping for value "arg"
- */
public function testDataTransformationFailure()
{
+ $this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
+ $this->expectExceptionMessage('Unable to transform data for property path "name": No mapping for value "arg"');
$model = new FixedDataTransformer([
'default' => 'foo',
]);
@@ -160,11 +161,9 @@ class SimpleFormTest extends AbstractFormTest
$this->assertNull($form->getData());
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\AlreadySubmittedException
- */
public function testSubmitThrowsExceptionIfAlreadySubmitted()
{
+ $this->expectException('Symfony\Component\Form\Exception\AlreadySubmittedException');
$this->form->submit([]);
$this->form->submit([]);
}
@@ -354,11 +353,9 @@ class SimpleFormTest extends AbstractFormTest
$this->assertCount(0, $this->form->getErrors());
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\AlreadySubmittedException
- */
public function testSetParentThrowsExceptionIfAlreadySubmitted()
{
+ $this->expectException('Symfony\Component\Form\Exception\AlreadySubmittedException');
$this->form->submit([]);
$this->form->setParent($this->getBuilder('parent')->getForm());
}
@@ -376,11 +373,9 @@ class SimpleFormTest extends AbstractFormTest
$this->assertFalse($this->form->isSubmitted());
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\AlreadySubmittedException
- */
public function testSetDataThrowsExceptionIfAlreadySubmitted()
{
+ $this->expectException('Symfony\Component\Form\Exception\AlreadySubmittedException');
$this->form->submit([]);
$this->form->setData(null);
}
@@ -779,12 +774,10 @@ class SimpleFormTest extends AbstractFormTest
$this->assertNull($form->getParent());
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\LogicException
- * @expectedExceptionMessage A form with an empty name cannot have a parent form.
- */
public function testFormCannotHaveEmptyNameNotInRootLevel()
{
+ $this->expectException('Symfony\Component\Form\Exception\LogicException');
+ $this->expectExceptionMessage('A form with an empty name cannot have a parent form.');
$this->getBuilder()
->setCompound(true)
->setDataMapper($this->getDataMapper())
@@ -891,11 +884,9 @@ class SimpleFormTest extends AbstractFormTest
$this->assertSame($arrayAccess, $form->getViewData());
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\LogicException
- */
public function testViewDataMustBeObjectIfDataClassIsSet()
{
+ $this->expectException('Symfony\Component\Form\Exception\LogicException');
$config = new FormConfigBuilder('name', 'stdClass', $this->dispatcher);
$config->addViewTransformer(new FixedDataTransformer([
'' => '',
@@ -906,12 +897,10 @@ class SimpleFormTest extends AbstractFormTest
$form->setData('foo');
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\RuntimeException
- * @expectedExceptionMessage A cycle was detected. Listeners to the PRE_SET_DATA event must not call setData(). You should call setData() on the FormEvent object instead.
- */
public function testSetDataCannotInvokeItself()
{
+ $this->expectException('Symfony\Component\Form\Exception\RuntimeException');
+ $this->expectExceptionMessage('A cycle was detected. Listeners to the PRE_SET_DATA event must not call setData(). You should call setData() on the FormEvent object instead.');
// Cycle detection to prevent endless loops
$config = new FormConfigBuilder('name', 'stdClass', $this->dispatcher);
$config->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
@@ -980,11 +969,9 @@ class SimpleFormTest extends AbstractFormTest
$this->assertSame('view[foo]', $parent->get('child')->getViewData());
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\RuntimeException
- */
public function testInheritDataDisallowsSetData()
{
+ $this->expectException('Symfony\Component\Form\Exception\RuntimeException');
$form = $this->getBuilder()
->setInheritData(true)
->getForm();
@@ -992,11 +979,9 @@ class SimpleFormTest extends AbstractFormTest
$form->setData('foo');
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\RuntimeException
- */
public function testGetDataRequiresParentToBeSetIfInheritData()
{
+ $this->expectException('Symfony\Component\Form\Exception\RuntimeException');
$form = $this->getBuilder()
->setInheritData(true)
->getForm();
@@ -1004,11 +989,9 @@ class SimpleFormTest extends AbstractFormTest
$form->getData();
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\RuntimeException
- */
public function testGetNormDataRequiresParentToBeSetIfInheritData()
{
+ $this->expectException('Symfony\Component\Form\Exception\RuntimeException');
$form = $this->getBuilder()
->setInheritData(true)
->getForm();
@@ -1016,11 +999,9 @@ class SimpleFormTest extends AbstractFormTest
$form->getNormData();
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\RuntimeException
- */
public function testGetViewDataRequiresParentToBeSetIfInheritData()
{
+ $this->expectException('Symfony\Component\Form\Exception\RuntimeException');
$form = $this->getBuilder()
->setInheritData(true)
->getForm();
@@ -1068,11 +1049,9 @@ class SimpleFormTest extends AbstractFormTest
$form->initialize();
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\RuntimeException
- */
public function testInitializeFailsIfParent()
{
+ $this->expectException('Symfony\Component\Form\Exception\RuntimeException');
$parent = $this->getBuilder()->setRequired(false)->getForm();
$child = $this->getBuilder()->setRequired(true)->getForm();
@@ -1081,12 +1060,10 @@ class SimpleFormTest extends AbstractFormTest
$child->initialize();
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\RuntimeException
- * @expectedExceptionMessage A cycle was detected. Listeners to the PRE_SET_DATA event must not call getData() if the form data has not already been set. You should call getData() on the FormEvent object instead.
- */
public function testCannotCallGetDataInPreSetDataListenerIfDataHasNotAlreadyBeenSet()
{
+ $this->expectException('Symfony\Component\Form\Exception\RuntimeException');
+ $this->expectExceptionMessage('A cycle was detected. Listeners to the PRE_SET_DATA event must not call getData() if the form data has not already been set. You should call getData() on the FormEvent object instead.');
$config = new FormConfigBuilder('name', 'stdClass', $this->dispatcher);
$config->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
$event->getForm()->getData();
@@ -1096,12 +1073,10 @@ class SimpleFormTest extends AbstractFormTest
$form->setData('foo');
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\RuntimeException
- * @expectedExceptionMessage A cycle was detected. Listeners to the PRE_SET_DATA event must not call getNormData() if the form data has not already been set.
- */
public function testCannotCallGetNormDataInPreSetDataListener()
{
+ $this->expectException('Symfony\Component\Form\Exception\RuntimeException');
+ $this->expectExceptionMessage('A cycle was detected. Listeners to the PRE_SET_DATA event must not call getNormData() if the form data has not already been set.');
$config = new FormConfigBuilder('name', 'stdClass', $this->dispatcher);
$config->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
$event->getForm()->getNormData();
@@ -1111,12 +1086,10 @@ class SimpleFormTest extends AbstractFormTest
$form->setData('foo');
}
- /**
- * @expectedException \Symfony\Component\Form\Exception\RuntimeException
- * @expectedExceptionMessage A cycle was detected. Listeners to the PRE_SET_DATA event must not call getViewData() if the form data has not already been set.
- */
public function testCannotCallGetViewDataInPreSetDataListener()
{
+ $this->expectException('Symfony\Component\Form\Exception\RuntimeException');
+ $this->expectExceptionMessage('A cycle was detected. Listeners to the PRE_SET_DATA event must not call getViewData() if the form data has not already been set.');
$config = new FormConfigBuilder('name', 'stdClass', $this->dispatcher);
$config->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
$event->getForm()->getViewData();
diff --git a/src/Symfony/Component/Form/Tests/Util/OrderedHashMapTest.php b/src/Symfony/Component/Form/Tests/Util/OrderedHashMapTest.php
index 01e76d87eb..649cb05ada 100644
--- a/src/Symfony/Component/Form/Tests/Util/OrderedHashMapTest.php
+++ b/src/Symfony/Component/Form/Tests/Util/OrderedHashMapTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\Form\Tests\Util;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Form\Util\OrderedHashMap;
/**
@@ -19,6 +20,8 @@ use Symfony\Component\Form\Util\OrderedHashMap;
*/
class OrderedHashMapTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testGet()
{
$map = new OrderedHashMap();
@@ -27,11 +30,9 @@ class OrderedHashMapTest extends TestCase
$this->assertSame(1, $map['first']);
}
- /**
- * @expectedException \OutOfBoundsException
- */
public function testGetNonExistingFails()
{
+ $this->expectException('OutOfBoundsException');
$map = new OrderedHashMap();
$map['first'];
diff --git a/src/Symfony/Component/HttpClient/Tests/HttpClientTraitTest.php b/src/Symfony/Component/HttpClient/Tests/HttpClientTraitTest.php
index f39771a46e..7971b79143 100644
--- a/src/Symfony/Component/HttpClient/Tests/HttpClientTraitTest.php
+++ b/src/Symfony/Component/HttpClient/Tests/HttpClientTraitTest.php
@@ -176,39 +176,31 @@ class HttpClientTraitTest extends TestCase
$this->assertSame(['Authorization: Bearer foobar'], $options['normalized_headers']['authorization']);
}
- /**
- * @expectedException \Symfony\Component\HttpClient\Exception\InvalidArgumentException
- * @expectedExceptionMessage Option "auth_bearer" must be a string containing only characters from the base 64 alphabet, object given.
- */
public function testInvalidAuthBearerOption()
{
+ $this->expectException('Symfony\Component\HttpClient\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Option "auth_bearer" must be a string containing only characters from the base 64 alphabet, object given.');
self::prepareRequest('POST', 'http://example.com', ['auth_bearer' => new \stdClass()], HttpClientInterface::OPTIONS_DEFAULTS);
}
- /**
- * @expectedException \Symfony\Component\HttpClient\Exception\InvalidArgumentException
- * @expectedExceptionMessage Option "auth_bearer" must be a string containing only characters from the base 64 alphabet, invalid string given.
- */
public function testInvalidAuthBearerValue()
{
+ $this->expectException('Symfony\Component\HttpClient\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Option "auth_bearer" must be a string containing only characters from the base 64 alphabet, invalid string given.');
self::prepareRequest('POST', 'http://example.com', ['auth_bearer' => "a\nb"], HttpClientInterface::OPTIONS_DEFAULTS);
}
- /**
- * @expectedException \Symfony\Component\HttpClient\Exception\InvalidArgumentException
- * @expectedExceptionMessage Define either the "auth_basic" or the "auth_bearer" option, setting both is not supported.
- */
public function testSetAuthBasicAndBearerOptions()
{
+ $this->expectException('Symfony\Component\HttpClient\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Define either the "auth_basic" or the "auth_bearer" option, setting both is not supported.');
self::prepareRequest('POST', 'http://example.com', ['auth_bearer' => 'foo', 'auth_basic' => 'foo:bar'], HttpClientInterface::OPTIONS_DEFAULTS);
}
- /**
- * @expectedException \Symfony\Component\HttpClient\Exception\InvalidArgumentException
- * @expectedExceptionMessage Define either the "json" or the "body" option, setting both is not supported
- */
public function testSetJSONAndBodyOptions()
{
+ $this->expectException('Symfony\Component\HttpClient\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Define either the "json" or the "body" option, setting both is not supported');
self::prepareRequest('POST', 'http://example.com', ['json' => ['foo' => 'bar'], 'body' => ''], HttpClientInterface::OPTIONS_DEFAULTS);
}
@@ -247,21 +239,17 @@ class HttpClientTraitTest extends TestCase
self::assertSame($expected, $this->normalizePeerFingerprint($fingerprint));
}
- /**
- * @expectedException \Symfony\Component\HttpClient\Exception\InvalidArgumentException
- * @expectedExceptionMessage Cannot auto-detect fingerprint algorithm for "foo".
- */
public function testNormalizePeerFingerprintException()
{
+ $this->expectException('Symfony\Component\HttpClient\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Cannot auto-detect fingerprint algorithm for "foo".');
$this->normalizePeerFingerprint('foo');
}
- /**
- * @expectedException \Symfony\Component\HttpClient\Exception\InvalidArgumentException
- * @expectedExceptionMessage Option "peer_fingerprint" must be string or array, object given.
- */
public function testNormalizePeerFingerprintTypeException()
{
+ $this->expectException('Symfony\Component\HttpClient\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Option "peer_fingerprint" must be string or array, object given.');
$fingerprint = new \stdClass();
$this->normalizePeerFingerprint($fingerprint);
diff --git a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php
index e0df45c539..06b0668f7c 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php
@@ -49,11 +49,9 @@ class BinaryFileResponseTest extends ResponseTestCase
$this->assertSame('fööö.html', $response->getFile()->getFilename());
}
- /**
- * @expectedException \LogicException
- */
public function testSetContent()
{
+ $this->expectException('LogicException');
$response = new BinaryFileResponse(__FILE__);
$response->setContent('foo');
}
diff --git a/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php b/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php
index 4aa32eea45..022fdab3f8 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\HttpFoundation\Tests;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\HttpFoundation\Cookie;
/**
@@ -24,6 +25,8 @@ use Symfony\Component\HttpFoundation\Cookie;
*/
class CookieTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function invalidNames()
{
return [
@@ -41,18 +44,16 @@ class CookieTest extends TestCase
/**
* @dataProvider invalidNames
- * @expectedException \InvalidArgumentException
*/
public function testInstantiationThrowsExceptionIfCookieNameContainsInvalidCharacters($name)
{
+ $this->expectException('InvalidArgumentException');
Cookie::create($name);
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testInvalidExpiration()
{
+ $this->expectException('InvalidArgumentException');
Cookie::create('MyCookie', 'foo', 'bar');
}
diff --git a/src/Symfony/Component/HttpFoundation/Tests/ExpressionRequestMatcherTest.php b/src/Symfony/Component/HttpFoundation/Tests/ExpressionRequestMatcherTest.php
index 2afdade67d..e750f39e68 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/ExpressionRequestMatcherTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/ExpressionRequestMatcherTest.php
@@ -12,17 +12,18 @@
namespace Symfony\Component\HttpFoundation\Tests;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
use Symfony\Component\HttpFoundation\ExpressionRequestMatcher;
use Symfony\Component\HttpFoundation\Request;
class ExpressionRequestMatcherTest extends TestCase
{
- /**
- * @expectedException \LogicException
- */
+ use ForwardCompatTestTrait;
+
public function testWhenNoExpressionIsSet()
{
+ $this->expectException('LogicException');
$expressionRequestMatcher = new ExpressionRequestMatcher();
$expressionRequestMatcher->matches(new Request());
}
diff --git a/src/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php b/src/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php
index ca7259aed8..3695fcdf5e 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php
@@ -145,11 +145,9 @@ class UploadedFileTest extends TestCase
$this->assertEquals('gif', $file->getClientOriginalExtension());
}
- /**
- * @expectedException \Symfony\Component\HttpFoundation\File\Exception\FileException
- */
public function testMoveLocalFileIsNotAllowed()
{
+ $this->expectException('Symfony\Component\HttpFoundation\File\Exception\FileException');
$file = new UploadedFile(
__DIR__.'/Fixtures/test.gif',
'original.gif',
diff --git a/src/Symfony/Component/HttpFoundation/Tests/FileBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/FileBagTest.php
index 6f2a33d3cc..e830ba47d2 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/FileBagTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/FileBagTest.php
@@ -26,11 +26,9 @@ class FileBagTest extends TestCase
{
use ForwardCompatTestTrait;
- /**
- * @expectedException \InvalidArgumentException
- */
public function testFileMustBeAnArrayOrUploadedFile()
{
+ $this->expectException('InvalidArgumentException');
new FileBag(['file' => 'foo']);
}
diff --git a/src/Symfony/Component/HttpFoundation/Tests/HeaderBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/HeaderBagTest.php
index 6c4915f2e4..3eff568409 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/HeaderBagTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/HeaderBagTest.php
@@ -12,10 +12,13 @@
namespace Symfony\Component\HttpFoundation\Tests;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\HttpFoundation\HeaderBag;
class HeaderBagTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testConstructor()
{
$bag = new HeaderBag(['foo' => 'bar']);
@@ -48,11 +51,9 @@ class HeaderBagTest extends TestCase
$this->assertInstanceOf('DateTime', $headerDate);
}
- /**
- * @expectedException \RuntimeException
- */
public function testGetDateException()
{
+ $this->expectException('RuntimeException');
$bag = new HeaderBag(['foo' => 'Tue']);
$headerDate = $bag->getDate('foo');
}
diff --git a/src/Symfony/Component/HttpFoundation/Tests/HeaderUtilsTest.php b/src/Symfony/Component/HttpFoundation/Tests/HeaderUtilsTest.php
index 2f82dc4e67..d2b19ca84d 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/HeaderUtilsTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/HeaderUtilsTest.php
@@ -83,11 +83,9 @@ class HeaderUtilsTest extends TestCase
$this->assertEquals('foo \\ bar', HeaderUtils::unquote('"foo \\\\ bar"'));
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testMakeDispositionInvalidDisposition()
{
+ $this->expectException('InvalidArgumentException');
HeaderUtils::makeDisposition('invalid', 'foo.html');
}
@@ -113,10 +111,10 @@ class HeaderUtilsTest extends TestCase
/**
* @dataProvider provideMakeDispositionFail
- * @expectedException \InvalidArgumentException
*/
public function testMakeDispositionFail($disposition, $filename)
{
+ $this->expectException('InvalidArgumentException');
HeaderUtils::makeDisposition($disposition, $filename);
}
diff --git a/src/Symfony/Component/HttpFoundation/Tests/IpUtilsTest.php b/src/Symfony/Component/HttpFoundation/Tests/IpUtilsTest.php
index c7f76b5de2..338da1d25c 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/IpUtilsTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/IpUtilsTest.php
@@ -12,10 +12,13 @@
namespace Symfony\Component\HttpFoundation\Tests;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\HttpFoundation\IpUtils;
class IpUtilsTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
/**
* @dataProvider getIpv4Data
*/
@@ -73,11 +76,11 @@ class IpUtilsTest extends TestCase
}
/**
- * @expectedException \RuntimeException
* @requires extension sockets
*/
public function testAnIpv6WithOptionDisabledIpv6()
{
+ $this->expectException('RuntimeException');
if (\defined('AF_INET6')) {
$this->markTestSkipped('Only works when PHP is compiled with the option "disable-ipv6".');
}
diff --git a/src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php
index b7482d0339..893e4cb896 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php
@@ -210,29 +210,23 @@ class JsonResponseTest extends TestCase
$this->assertSame('{"foo":"bar"}', $response->getContent());
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testSetCallbackInvalidIdentifier()
{
+ $this->expectException('InvalidArgumentException');
$response = new JsonResponse('foo');
$response->setCallback('+invalid');
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testSetContent()
{
+ $this->expectException('InvalidArgumentException');
JsonResponse::create("\xB1\x31");
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage This error is expected
- */
public function testSetContentJsonSerializeError()
{
+ $this->expectException('Exception');
+ $this->expectExceptionMessage('This error is expected');
if (!interface_exists('JsonSerializable', false)) {
$this->markTestSkipped('JsonSerializable is required.');
}
diff --git a/src/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php
index 24d703d52b..e67fbe7273 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php
@@ -12,10 +12,13 @@
namespace Symfony\Component\HttpFoundation\Tests;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\HttpFoundation\RedirectResponse;
class RedirectResponseTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testGenerateMetaRedirect()
{
$response = new RedirectResponse('foo.bar');
@@ -26,20 +29,16 @@ class RedirectResponseTest extends TestCase
));
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage Cannot redirect to an empty URL.
- */
public function testRedirectResponseConstructorEmptyUrl()
{
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('Cannot redirect to an empty URL.');
$response = new RedirectResponse('');
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testRedirectResponseConstructorWrongStatusCode()
{
+ $this->expectException('InvalidArgumentException');
$response = new RedirectResponse('foo.bar', 404);
}
@@ -66,11 +65,9 @@ class RedirectResponseTest extends TestCase
$this->assertEquals('baz.beep', $response->getTargetUrl());
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testSetTargetUrlNull()
{
+ $this->expectException('InvalidArgumentException');
$response = new RedirectResponse('foo.bar');
$response->setTargetUrl(null);
}
diff --git a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php
index 6a7bd445b7..05877cd6d5 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php
@@ -921,11 +921,9 @@ class RequestTest extends TestCase
$this->assertEquals(80, $port, 'With only PROTO set and value is not recognized, getPort() defaults to 80.');
}
- /**
- * @expectedException \RuntimeException
- */
public function testGetHostWithFakeHttpHostValue()
{
+ $this->expectException('RuntimeException');
$request = new Request();
$request->initialize([], [], [], [], [], ['HTTP_HOST' => 'www.host.com?query=string']);
$request->getHost();
@@ -1090,11 +1088,11 @@ class RequestTest extends TestCase
}
/**
- * @expectedException \Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException
* @dataProvider getClientIpsWithConflictingHeadersProvider
*/
public function testGetClientIpsWithConflictingHeaders($httpForwarded, $httpXForwardedFor)
{
+ $this->expectException('Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException');
$request = new Request();
$server = [
diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php
index 35df36c1c6..d6638e10cb 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\HttpFoundation\Tests;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
@@ -20,6 +21,8 @@ use Symfony\Component\HttpFoundation\ResponseHeaderBag;
*/
class ResponseHeaderBagTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testAllPreserveCase()
{
$headers = [
@@ -240,11 +243,9 @@ class ResponseHeaderBagTest extends TestCase
$this->assertEquals([], $bag->getCookies());
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testGetCookiesWithInvalidArgument()
{
+ $this->expectException('InvalidArgumentException');
$bag = new ResponseHeaderBag();
$bag->getCookies('invalid_argument');
diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php
index 550d7ce0b0..4edada1160 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php
@@ -11,6 +11,7 @@
namespace Symfony\Component\HttpFoundation\Tests;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@@ -20,6 +21,8 @@ use Symfony\Component\HttpFoundation\Response;
*/
class ResponseTest extends ResponseTestCase
{
+ use ForwardCompatTestTrait;
+
public function testCreate()
{
$response = Response::create('foo', 301, ['Foo' => 'bar']);
@@ -902,11 +905,11 @@ class ResponseTest extends ResponseTestCase
}
/**
- * @expectedException \UnexpectedValueException
* @dataProvider invalidContentProvider
*/
public function testSetContentInvalid($content)
{
+ $this->expectException('UnexpectedValueException');
$response = new Response();
$response->setContent($content);
}
@@ -991,11 +994,11 @@ class ResponseTest extends ResponseTestCase
}
/**
- * @see http://github.com/zendframework/zend-diactoros for the canonical source repository
+ * @see http://github.com/zendframework/zend-diactoros for the canonical source repository
*
- * @author Fábio Pacheco
+ * @author Fábio Pacheco
* @copyright Copyright (c) 2015-2016 Zend Technologies USA Inc. (http://www.zend.com)
- * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License
+ * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License
*/
public function ianaCodesReasonPhrasesProvider()
{
diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php
index f4e775b719..c0057dd3eb 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php
@@ -55,11 +55,9 @@ class MongoDbSessionHandlerTest extends TestCase
$this->storage = new MongoDbSessionHandler($this->mongo, $this->options);
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testConstructorShouldThrowExceptionForMissingOptions()
{
+ $this->expectException('InvalidArgumentException');
new MongoDbSessionHandler($this->mongo, []);
}
diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php
index e227bebf62..ad1a6adff4 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler;
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
@@ -25,6 +26,8 @@ use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
*/
class NativeFileSessionHandlerTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testConstruct()
{
$storage = new NativeSessionStorage(['name' => 'TESTING'], new NativeFileSessionHandler(sys_get_temp_dir()));
@@ -58,11 +61,9 @@ class NativeFileSessionHandlerTest extends TestCase
];
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testConstructException()
{
+ $this->expectException('InvalidArgumentException');
$handler = new NativeFileSessionHandler('something;invalid;with;too-many-args');
}
diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php
index 23eb5b11aa..b2af73e2f4 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php
@@ -51,22 +51,18 @@ class PdoSessionHandlerTest extends TestCase
return $pdo;
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testWrongPdoErrMode()
{
+ $this->expectException('InvalidArgumentException');
$pdo = $this->getMemorySqlitePdo();
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_SILENT);
$storage = new PdoSessionHandler($pdo);
}
- /**
- * @expectedException \RuntimeException
- */
public function testInexistentTable()
{
+ $this->expectException('RuntimeException');
$storage = new PdoSessionHandler($this->getMemorySqlitePdo(), ['db_table' => 'inexistent_table']);
$storage->open('', 'sid');
$storage->read('id');
@@ -74,11 +70,9 @@ class PdoSessionHandlerTest extends TestCase
$storage->close();
}
- /**
- * @expectedException \RuntimeException
- */
public function testCreateTableTwice()
{
+ $this->expectException('RuntimeException');
$storage = new PdoSessionHandler($this->getMemorySqlitePdo());
$storage->createTable();
}
diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockArraySessionStorageTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockArraySessionStorageTest.php
index c60a78910b..1285dbf1ad 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockArraySessionStorageTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockArraySessionStorageTest.php
@@ -124,11 +124,9 @@ class MockArraySessionStorageTest extends TestCase
$this->assertTrue($storage->isStarted());
}
- /**
- * @expectedException \RuntimeException
- */
public function testUnstartedSave()
{
+ $this->expectException('RuntimeException');
$this->storage->save();
}
}
diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockFileSessionStorageTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockFileSessionStorageTest.php
index 67c47e417a..bd120723ea 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockFileSessionStorageTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockFileSessionStorageTest.php
@@ -110,11 +110,9 @@ class MockFileSessionStorageTest extends TestCase
$this->assertEquals('bar', $storage2->getBag('attributes')->get('foo'), 'values persist between instances');
}
- /**
- * @expectedException \RuntimeException
- */
public function testSaveWithoutStart()
{
+ $this->expectException('RuntimeException');
$storage1 = $this->getStorage();
$storage1->save();
}
diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php
index ba06902c58..04a86614bd 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php
@@ -75,20 +75,16 @@ class NativeSessionStorageTest extends TestCase
$this->assertSame($bag, $storage->getBag($bag->getName()));
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testRegisterBagException()
{
+ $this->expectException('InvalidArgumentException');
$storage = $this->getStorage();
$storage->getBag('non_existing');
}
- /**
- * @expectedException \LogicException
- */
public function testRegisterBagForAStartedSessionThrowsException()
{
+ $this->expectException('LogicException');
$storage = $this->getStorage();
$storage->start();
$storage->registerBag(new AttributeBag());
@@ -206,11 +202,9 @@ class NativeSessionStorageTest extends TestCase
$this->assertSame('200', ini_get('session.cache_expire'));
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testSetSaveHandlerException()
{
+ $this->expectException('InvalidArgumentException');
$storage = $this->getStorage();
$storage->setSaveHandler(new \stdClass());
}
@@ -233,11 +227,9 @@ class NativeSessionStorageTest extends TestCase
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler());
}
- /**
- * @expectedException \RuntimeException
- */
public function testStarted()
{
+ $this->expectException('RuntimeException');
$storage = $this->getStorage();
$this->assertFalse($storage->getSaveHandler()->isActive());
diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php
index 499a54a8ed..dcd3003645 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php
@@ -83,10 +83,10 @@ class AbstractProxyTest extends TestCase
/**
* @runInSeparateProcess
* @preserveGlobalState disabled
- * @expectedException \LogicException
*/
public function testNameException()
{
+ $this->expectException('LogicException');
session_start();
$this->proxy->setName('foo');
}
@@ -106,10 +106,10 @@ class AbstractProxyTest extends TestCase
/**
* @runInSeparateProcess
* @preserveGlobalState disabled
- * @expectedException \LogicException
*/
public function testIdException()
{
+ $this->expectException('LogicException');
session_start();
$this->proxy->setId('foo');
}
diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php
index 63b3c8afb3..d6459e10d6 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php
@@ -28,7 +28,7 @@ class SessionHandlerProxyTest extends TestCase
use ForwardCompatTestTrait;
/**
- * @var \PHPUnit_Framework_MockObject_Matcher
+ * @var \PHPUnit\Framework\MockObject\Matcher
*/
private $mock;
diff --git a/src/Symfony/Component/HttpFoundation/Tests/StreamedResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/StreamedResponseTest.php
index 62dfc9bc94..96ab63d496 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/StreamedResponseTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/StreamedResponseTest.php
@@ -12,11 +12,14 @@
namespace Symfony\Component\HttpFoundation\Tests;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\StreamedResponse;
class StreamedResponseTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testConstructor()
{
$response = new StreamedResponse(function () { echo 'foo'; }, 404, ['Content-Type' => 'text/plain']);
@@ -81,20 +84,16 @@ class StreamedResponseTest extends TestCase
$this->assertEquals(1, $called);
}
- /**
- * @expectedException \LogicException
- */
public function testSendContentWithNonCallable()
{
+ $this->expectException('LogicException');
$response = new StreamedResponse(null);
$response->sendContent();
}
- /**
- * @expectedException \LogicException
- */
public function testSetContent()
{
+ $this->expectException('LogicException');
$response = new StreamedResponse(function () { echo 'foo'; });
$response->setContent('foo');
}
diff --git a/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php b/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php
index 394e7ed7c6..b0e5d0ea8a 100644
--- a/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php
@@ -12,12 +12,15 @@
namespace Symfony\Component\HttpKernel\Tests\Bundle;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionNotValidBundle\ExtensionNotValidBundle;
use Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\ExtensionPresentBundle;
class BundleTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testGetContainerExtension()
{
$bundle = new ExtensionPresentBundle();
@@ -28,12 +31,10 @@ class BundleTest extends TestCase
);
}
- /**
- * @expectedException \LogicException
- * @expectedExceptionMessage must implement Symfony\Component\DependencyInjection\Extension\ExtensionInterface
- */
public function testGetContainerExtensionWithInvalidClass()
{
+ $this->expectException('LogicException');
+ $this->expectExceptionMessage('must implement Symfony\Component\DependencyInjection\Extension\ExtensionInterface');
$bundle = new ExtensionNotValidBundle();
$bundle->getContainerExtension();
}
diff --git a/src/Symfony/Component/HttpKernel/Tests/CacheClearer/Psr6CacheClearerTest.php b/src/Symfony/Component/HttpKernel/Tests/CacheClearer/Psr6CacheClearerTest.php
index d24131dae5..d326c0f89a 100644
--- a/src/Symfony/Component/HttpKernel/Tests/CacheClearer/Psr6CacheClearerTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/CacheClearer/Psr6CacheClearerTest.php
@@ -13,10 +13,13 @@ namespace Symfony\Component\HttpKernel\Tests\CacheClearer;
use PHPUnit\Framework\TestCase;
use Psr\Cache\CacheItemPoolInterface;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\HttpKernel\CacheClearer\Psr6CacheClearer;
class Psr6CacheClearerTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testClearPoolsInjectedInConstructor()
{
$pool = $this->getMockBuilder(CacheItemPoolInterface::class)->getMock();
@@ -37,12 +40,10 @@ class Psr6CacheClearerTest extends TestCase
(new Psr6CacheClearer(['pool' => $pool]))->clearPool('pool');
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage Cache pool not found: unknown
- */
public function testClearPoolThrowsExceptionOnUnreferencedPool()
{
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('Cache pool not found: unknown');
(new Psr6CacheClearer())->clearPool('unknown');
}
}
diff --git a/src/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerTest.php b/src/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerTest.php
index e620d6c8b4..cb4fa1aae2 100644
--- a/src/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerTest.php
@@ -39,11 +39,9 @@ class CacheWarmerTest extends TestCase
$this->assertFileExists(self::$cacheFile);
}
- /**
- * @expectedException \RuntimeException
- */
public function testWriteNonWritableCacheFileThrowsARuntimeException()
{
+ $this->expectException('RuntimeException');
$nonWritableFile = '/this/file/is/very/probably/not/writable';
$warmer = new TestCacheWarmer($nonWritableFile);
$warmer->warmUp(\dirname($nonWritableFile));
diff --git a/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolver/NotTaggedControllerValueResolverTest.php b/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolver/NotTaggedControllerValueResolverTest.php
index bd22adde91..4f85b0f351 100644
--- a/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolver/NotTaggedControllerValueResolverTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolver/NotTaggedControllerValueResolverTest.php
@@ -53,12 +53,10 @@ class NotTaggedControllerValueResolverTest extends TestCase
$this->assertFalse($resolver->supports($request, $argument));
}
- /**
- * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
- * @expectedExceptionMessage Could not resolve argument $dummy of "App\Controller\Mine::method()", maybe you forgot to register the controller as a service or missed tagging it with the "controller.service_arguments"?
- */
public function testController()
{
+ $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
+ $this->expectExceptionMessage('Could not resolve argument $dummy of "App\Controller\Mine::method()", maybe you forgot to register the controller as a service or missed tagging it with the "controller.service_arguments"?');
$resolver = new NotTaggedControllerValueResolver(new ServiceLocator([]));
$argument = new ArgumentMetadata('dummy', \stdClass::class, false, false, null);
$request = $this->requestWithAttributes(['_controller' => 'App\\Controller\\Mine::method']);
@@ -66,12 +64,10 @@ class NotTaggedControllerValueResolverTest extends TestCase
$resolver->resolve($request, $argument);
}
- /**
- * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
- * @expectedExceptionMessage Could not resolve argument $dummy of "App\Controller\Mine::method()", maybe you forgot to register the controller as a service or missed tagging it with the "controller.service_arguments"?
- */
public function testControllerWithATrailingBackSlash()
{
+ $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
+ $this->expectExceptionMessage('Could not resolve argument $dummy of "App\Controller\Mine::method()", maybe you forgot to register the controller as a service or missed tagging it with the "controller.service_arguments"?');
$resolver = new NotTaggedControllerValueResolver(new ServiceLocator([]));
$argument = new ArgumentMetadata('dummy', \stdClass::class, false, false, null);
$request = $this->requestWithAttributes(['_controller' => '\\App\\Controller\\Mine::method']);
@@ -79,12 +75,10 @@ class NotTaggedControllerValueResolverTest extends TestCase
$resolver->resolve($request, $argument);
}
- /**
- * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
- * @expectedExceptionMessage Could not resolve argument $dummy of "App\Controller\Mine::method()", maybe you forgot to register the controller as a service or missed tagging it with the "controller.service_arguments"?
- */
public function testControllerWithMethodNameStartUppercase()
{
+ $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
+ $this->expectExceptionMessage('Could not resolve argument $dummy of "App\Controller\Mine::method()", maybe you forgot to register the controller as a service or missed tagging it with the "controller.service_arguments"?');
$resolver = new NotTaggedControllerValueResolver(new ServiceLocator([]));
$argument = new ArgumentMetadata('dummy', \stdClass::class, false, false, null);
$request = $this->requestWithAttributes(['_controller' => 'App\\Controller\\Mine::Method']);
@@ -92,12 +86,10 @@ class NotTaggedControllerValueResolverTest extends TestCase
$resolver->resolve($request, $argument);
}
- /**
- * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
- * @expectedExceptionMessage Could not resolve argument $dummy of "App\Controller\Mine::method()", maybe you forgot to register the controller as a service or missed tagging it with the "controller.service_arguments"?
- */
public function testControllerNameIsAnArray()
{
+ $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
+ $this->expectExceptionMessage('Could not resolve argument $dummy of "App\Controller\Mine::method()", maybe you forgot to register the controller as a service or missed tagging it with the "controller.service_arguments"?');
$resolver = new NotTaggedControllerValueResolver(new ServiceLocator([]));
$argument = new ArgumentMetadata('dummy', \stdClass::class, false, false, null);
$request = $this->requestWithAttributes(['_controller' => ['App\\Controller\\Mine', 'method']]);
diff --git a/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php b/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php
index f1915961ff..4036727bce 100644
--- a/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php
@@ -105,12 +105,10 @@ class ServiceValueResolverTest extends TestCase
$this->assertYieldEquals([new DummyService()], $resolver->resolve($request, $argument));
}
- /**
- * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
- * @expectedExceptionMessage Cannot autowire argument $dummy of "Symfony\Component\HttpKernel\Tests\Controller\ArgumentResolver\DummyController::index()": it references class "Symfony\Component\HttpKernel\Tests\Controller\ArgumentResolver\DummyService" but no such service exists.
- */
public function testErrorIsTruncated()
{
+ $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
+ $this->expectExceptionMessage('Cannot autowire argument $dummy of "Symfony\Component\HttpKernel\Tests\Controller\ArgumentResolver\DummyController::index()": it references class "Symfony\Component\HttpKernel\Tests\Controller\ArgumentResolver\DummyService" but no such service exists.');
$container = new ContainerBuilder();
$container->addCompilerPass(new RegisterControllerArgumentLocatorsPass());
diff --git a/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolverTest.php b/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolverTest.php
index 0aa9c6722a..312584624c 100644
--- a/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolverTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolverTest.php
@@ -165,11 +165,9 @@ class ArgumentResolverTest extends TestCase
$this->assertEquals(['foo', 'foo', 'bar'], self::$resolver->getArguments($request, $controller));
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testGetVariadicArgumentsWithoutArrayInRequest()
{
+ $this->expectException('InvalidArgumentException');
$request = Request::create('/');
$request->attributes->set('foo', 'foo');
$request->attributes->set('bar', 'foo');
@@ -178,11 +176,9 @@ class ArgumentResolverTest extends TestCase
self::$resolver->getArguments($request, $controller);
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testGetArgumentWithoutArray()
{
+ $this->expectException('InvalidArgumentException');
$factory = new ArgumentMetadataFactory();
$valueResolver = $this->getMockBuilder(ArgumentValueResolverInterface::class)->getMock();
$resolver = new ArgumentResolver($factory, [$valueResolver]);
@@ -197,11 +193,9 @@ class ArgumentResolverTest extends TestCase
$resolver->getArguments($request, $controller);
}
- /**
- * @expectedException \RuntimeException
- */
public function testIfExceptionIsThrownWhenMissingAnArgument()
{
+ $this->expectException('RuntimeException');
$request = Request::create('/');
$controller = [$this, 'controllerWithFoo'];
@@ -258,11 +252,9 @@ class ArgumentResolverTest extends TestCase
$this->assertEquals([$session], self::$resolver->getArguments($request, $controller));
}
- /**
- * @expectedException \RuntimeException
- */
public function testGetSessionMissMatchWithInterface()
{
+ $this->expectException('RuntimeException');
$session = $this->getMockBuilder(SessionInterface::class)->getMock();
$request = Request::create('/');
$request->setSession($session);
@@ -271,11 +263,9 @@ class ArgumentResolverTest extends TestCase
self::$resolver->getArguments($request, $controller);
}
- /**
- * @expectedException \RuntimeException
- */
public function testGetSessionMissMatchWithImplementation()
{
+ $this->expectException('RuntimeException');
$session = new Session(new MockArraySessionStorage());
$request = Request::create('/');
$request->setSession($session);
@@ -284,11 +274,9 @@ class ArgumentResolverTest extends TestCase
self::$resolver->getArguments($request, $controller);
}
- /**
- * @expectedException \RuntimeException
- */
public function testGetSessionMissMatchOnNull()
{
+ $this->expectException('RuntimeException');
$request = Request::create('/');
$controller = [$this, 'controllerWithExtendingSession'];
diff --git a/src/Symfony/Component/HttpKernel/Tests/Controller/ContainerControllerResolverTest.php b/src/Symfony/Component/HttpKernel/Tests/Controller/ContainerControllerResolverTest.php
index 5a6c9d70d0..922289e466 100644
--- a/src/Symfony/Component/HttpKernel/Tests/Controller/ContainerControllerResolverTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/Controller/ContainerControllerResolverTest.php
@@ -122,14 +122,10 @@ class ContainerControllerResolverTest extends ControllerResolverTest
$this->assertSame($service, $controller);
}
- /**
- * Tests where the fallback instantiation fails due to required constructor arguments.
- *
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage Controller "Symfony\Component\HttpKernel\Tests\Controller\ControllerTestService" cannot be fetched from the container because it is private. Did you forget to tag the service with "controller.service_arguments"?
- */
public function testExceptionWhenUsingRemovedControllerServiceWithClassNameAsName()
{
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('Controller "Symfony\Component\HttpKernel\Tests\Controller\ControllerTestService" cannot be fetched from the container because it is private. Did you forget to tag the service with "controller.service_arguments"?');
$container = $this->getMockBuilder(Container::class)->getMock();
$container->expects($this->once())
->method('has')
@@ -150,14 +146,10 @@ class ContainerControllerResolverTest extends ControllerResolverTest
$resolver->getController($request);
}
- /**
- * Tests where the fallback instantiation fails due to non-existing class.
- *
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage Controller "app.my_controller" cannot be fetched from the container because it is private. Did you forget to tag the service with "controller.service_arguments"?
- */
public function testExceptionWhenUsingRemovedControllerService()
{
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('Controller "app.my_controller" cannot be fetched from the container because it is private. Did you forget to tag the service with "controller.service_arguments"?');
$container = $this->getMockBuilder(Container::class)->getMock();
$container->expects($this->once())
->method('has')
diff --git a/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php b/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php
index 5b937594b3..4512a40b7c 100644
--- a/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php
@@ -95,11 +95,9 @@ class ControllerResolverTest extends TestCase
$this->assertInstanceOf(InvokableController::class, $controller);
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testGetControllerOnObjectWithoutInvokeMethod()
{
+ $this->expectException('InvalidArgumentException');
$resolver = $this->createControllerResolver();
$request = Request::create('/');
diff --git a/src/Symfony/Component/HttpKernel/Tests/ControllerMetadata/ArgumentMetadataTest.php b/src/Symfony/Component/HttpKernel/Tests/ControllerMetadata/ArgumentMetadataTest.php
index 05351445e0..fb6894bbf4 100644
--- a/src/Symfony/Component/HttpKernel/Tests/ControllerMetadata/ArgumentMetadataTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/ControllerMetadata/ArgumentMetadataTest.php
@@ -12,10 +12,13 @@
namespace Symfony\Component\HttpKernel\Tests\ControllerMetadata;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;
class ArgumentMetadataTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testWithBcLayerWithDefault()
{
$argument = new ArgumentMetadata('foo', 'string', false, true, 'default value');
@@ -32,11 +35,9 @@ class ArgumentMetadataTest extends TestCase
$this->assertSame('default value', $argument->getDefaultValue());
}
- /**
- * @expectedException \LogicException
- */
public function testDefaultValueUnavailable()
{
+ $this->expectException('LogicException');
$argument = new ArgumentMetadata('foo', 'string', false, false, null, false);
$this->assertFalse($argument->isNullable());
diff --git a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/FragmentRendererPassTest.php b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/FragmentRendererPassTest.php
index 087c666596..9b49bd2d99 100644
--- a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/FragmentRendererPassTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/FragmentRendererPassTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\HttpKernel\Tests\DependencyInjection;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
@@ -22,14 +23,15 @@ use Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface;
class FragmentRendererPassTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
/**
* Tests that content rendering not implementing FragmentRendererInterface
* triggers an exception.
- *
- * @expectedException \InvalidArgumentException
*/
public function testContentRendererWithoutInterface()
{
+ $this->expectException('InvalidArgumentException');
$builder = new ContainerBuilder();
$fragmentHandlerDefinition = $builder->register('fragment.handler');
$builder->register('my_content_renderer', 'Symfony\Component\DependencyInjection\Definition')
diff --git a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php
index 948311556c..f37a0dbbb0 100644
--- a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\HttpKernel\Tests\DependencyInjection;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
@@ -25,12 +26,12 @@ use Symfony\Component\HttpKernel\DependencyInjection\RegisterControllerArgumentL
class RegisterControllerArgumentLocatorsPassTest extends TestCase
{
- /**
- * @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
- * @expectedExceptionMessage Class "Symfony\Component\HttpKernel\Tests\DependencyInjection\NotFound" used for service "foo" cannot be found.
- */
+ use ForwardCompatTestTrait;
+
public function testInvalidClass()
{
+ $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Class "Symfony\Component\HttpKernel\Tests\DependencyInjection\NotFound" used for service "foo" cannot be found.');
$container = new ContainerBuilder();
$container->register('argument_resolver.service')->addArgument([]);
@@ -42,12 +43,10 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
$pass->process($container);
}
- /**
- * @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
- * @expectedExceptionMessage Missing "action" attribute on tag "controller.service_arguments" {"argument":"bar"} for service "foo".
- */
public function testNoAction()
{
+ $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Missing "action" attribute on tag "controller.service_arguments" {"argument":"bar"} for service "foo".');
$container = new ContainerBuilder();
$container->register('argument_resolver.service')->addArgument([]);
@@ -59,12 +58,10 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
$pass->process($container);
}
- /**
- * @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
- * @expectedExceptionMessage Missing "argument" attribute on tag "controller.service_arguments" {"action":"fooAction"} for service "foo".
- */
public function testNoArgument()
{
+ $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Missing "argument" attribute on tag "controller.service_arguments" {"action":"fooAction"} for service "foo".');
$container = new ContainerBuilder();
$container->register('argument_resolver.service')->addArgument([]);
@@ -76,12 +73,10 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
$pass->process($container);
}
- /**
- * @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
- * @expectedExceptionMessage Missing "id" attribute on tag "controller.service_arguments" {"action":"fooAction","argument":"bar"} for service "foo".
- */
public function testNoService()
{
+ $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Missing "id" attribute on tag "controller.service_arguments" {"action":"fooAction","argument":"bar"} for service "foo".');
$container = new ContainerBuilder();
$container->register('argument_resolver.service')->addArgument([]);
@@ -93,12 +88,10 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
$pass->process($container);
}
- /**
- * @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
- * @expectedExceptionMessage Invalid "action" attribute on tag "controller.service_arguments" for service "foo": no public "barAction()" method found on class "Symfony\Component\HttpKernel\Tests\DependencyInjection\RegisterTestController".
- */
public function testInvalidMethod()
{
+ $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Invalid "action" attribute on tag "controller.service_arguments" for service "foo": no public "barAction()" method found on class "Symfony\Component\HttpKernel\Tests\DependencyInjection\RegisterTestController".');
$container = new ContainerBuilder();
$container->register('argument_resolver.service')->addArgument([]);
@@ -110,12 +103,10 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
$pass->process($container);
}
- /**
- * @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
- * @expectedExceptionMessage Invalid "controller.service_arguments" tag for service "foo": method "fooAction()" has no "baz" argument on class "Symfony\Component\HttpKernel\Tests\DependencyInjection\RegisterTestController".
- */
public function testInvalidArgument()
{
+ $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Invalid "controller.service_arguments" tag for service "foo": method "fooAction()" has no "baz" argument on class "Symfony\Component\HttpKernel\Tests\DependencyInjection\RegisterTestController".');
$container = new ContainerBuilder();
$container->register('argument_resolver.service')->addArgument([]);
@@ -207,12 +198,10 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
$this->assertSame(['foo::fooAction'], array_keys($locator));
}
- /**
- * @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
- * @expectedExceptionMessage Cannot determine controller argument for "Symfony\Component\HttpKernel\Tests\DependencyInjection\NonExistentClassController::fooAction()": the $nonExistent argument is type-hinted with the non-existent class or interface: "Symfony\Component\HttpKernel\Tests\DependencyInjection\NonExistentClass". Did you forget to add a use statement?
- */
public function testExceptionOnNonExistentTypeHint()
{
+ $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Cannot determine controller argument for "Symfony\Component\HttpKernel\Tests\DependencyInjection\NonExistentClassController::fooAction()": the $nonExistent argument is type-hinted with the non-existent class or interface: "Symfony\Component\HttpKernel\Tests\DependencyInjection\NonExistentClass". Did you forget to add a use statement?');
$container = new ContainerBuilder();
$container->register('argument_resolver.service')->addArgument([]);
@@ -223,12 +212,10 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
$pass->process($container);
}
- /**
- * @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
- * @expectedExceptionMessage Cannot determine controller argument for "Symfony\Component\HttpKernel\Tests\DependencyInjection\NonExistentClassDifferentNamespaceController::fooAction()": the $nonExistent argument is type-hinted with the non-existent class or interface: "Acme\NonExistentClass".
- */
public function testExceptionOnNonExistentTypeHintDifferentNamespace()
{
+ $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Cannot determine controller argument for "Symfony\Component\HttpKernel\Tests\DependencyInjection\NonExistentClassDifferentNamespaceController::fooAction()": the $nonExistent argument is type-hinted with the non-existent class or interface: "Acme\NonExistentClass".');
$container = new ContainerBuilder();
$container->register('argument_resolver.service')->addArgument([]);
diff --git a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/ResettableServicePassTest.php b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/ResettableServicePassTest.php
index 9b23ad003d..5d4ce0b8c2 100644
--- a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/ResettableServicePassTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/ResettableServicePassTest.php
@@ -3,6 +3,7 @@
namespace Symfony\Component\HttpKernel\Tests\DependencyInjection;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -14,6 +15,8 @@ use Symfony\Component\HttpKernel\Tests\Fixtures\ResettableService;
class ResettableServicePassTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testCompilerPass()
{
$container = new ContainerBuilder();
@@ -48,12 +51,10 @@ class ResettableServicePassTest extends TestCase
);
}
- /**
- * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
- * @expectedExceptionMessage Tag kernel.reset requires the "method" attribute to be set.
- */
public function testMissingMethod()
{
+ $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
+ $this->expectExceptionMessage('Tag kernel.reset requires the "method" attribute to be set.');
$container = new ContainerBuilder();
$container->register(ResettableService::class)
->addTag('kernel.reset');
diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php
index 40da65d240..c54cda1280 100644
--- a/src/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\HttpKernel\Tests\EventListener;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\EventListener\FragmentListener;
@@ -20,6 +21,8 @@ use Symfony\Component\HttpKernel\UriSigner;
class FragmentListenerTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testOnlyTriggeredOnFragmentRoute()
{
$request = Request::create('http://example.com/foo?_path=foo%3Dbar%26_controller%3Dfoo');
@@ -50,11 +53,9 @@ class FragmentListenerTest extends TestCase
$this->assertEquals($expected, $request->attributes->all());
}
- /**
- * @expectedException \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
- */
public function testAccessDeniedWithNonSafeMethods()
{
+ $this->expectException('Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException');
$request = Request::create('http://example.com/_fragment', 'POST');
$listener = new FragmentListener(new UriSigner('foo'));
@@ -63,11 +64,9 @@ class FragmentListenerTest extends TestCase
$listener->onKernelRequest($event);
}
- /**
- * @expectedException \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
- */
public function testAccessDeniedWithWrongSignature()
{
+ $this->expectException('Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException');
$request = Request::create('http://example.com/_fragment', 'GET', [], [], [], ['REMOTE_ADDR' => '10.0.0.1']);
$listener = new FragmentListener(new UriSigner('foo'));
diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php
index a23a681e0b..75ca60e5fe 100644
--- a/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php
@@ -82,11 +82,9 @@ class RouterListenerTest extends TestCase
return new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST);
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testInvalidMatcher()
{
+ $this->expectException('InvalidArgumentException');
new RouterListener(new \stdClass(), $this->requestStack);
}
@@ -207,11 +205,9 @@ class RouterListenerTest extends TestCase
$this->assertContains('Welcome', $response->getContent());
}
- /**
- * @expectedException \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
- */
public function testRequestWithBadHost()
{
+ $this->expectException('Symfony\Component\HttpKernel\Exception\BadRequestHttpException');
$kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock();
$request = Request::create('http://bad host %22/');
$event = new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST);
diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/ValidateRequestListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/ValidateRequestListenerTest.php
index 6f12720bd3..7803250501 100644
--- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ValidateRequestListenerTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ValidateRequestListenerTest.php
@@ -29,11 +29,9 @@ class ValidateRequestListenerTest extends TestCase
Request::setTrustedProxies([], -1);
}
- /**
- * @expectedException \Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException
- */
public function testListenerThrowsWhenMasterRequestHasInconsistentClientIps()
{
+ $this->expectException('Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException');
$dispatcher = new EventDispatcher();
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
diff --git a/src/Symfony/Component/HttpKernel/Tests/Fragment/EsiFragmentRendererTest.php b/src/Symfony/Component/HttpKernel/Tests/Fragment/EsiFragmentRendererTest.php
index d8006e1707..13bbdf8e1a 100644
--- a/src/Symfony/Component/HttpKernel/Tests/Fragment/EsiFragmentRendererTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/Fragment/EsiFragmentRendererTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\HttpKernel\Tests\Fragment;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Controller\ControllerReference;
use Symfony\Component\HttpKernel\Fragment\EsiFragmentRenderer;
@@ -20,6 +21,8 @@ use Symfony\Component\HttpKernel\UriSigner;
class EsiFragmentRendererTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testRenderFallbackToInlineStrategyIfEsiNotSupported()
{
$strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy(true));
@@ -65,11 +68,9 @@ class EsiFragmentRendererTest extends TestCase
);
}
- /**
- * @expectedException \LogicException
- */
public function testRenderControllerReferenceWithoutSignerThrowsException()
{
+ $this->expectException('LogicException');
$strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy());
$request = Request::create('/');
@@ -79,11 +80,9 @@ class EsiFragmentRendererTest extends TestCase
$strategy->render(new ControllerReference('main_controller'), $request);
}
- /**
- * @expectedException \LogicException
- */
public function testRenderAltControllerReferenceWithoutSignerThrowsException()
{
+ $this->expectException('LogicException');
$strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy());
$request = Request::create('/');
diff --git a/src/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php b/src/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php
index f8b79c725d..20ad664d0d 100644
--- a/src/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/Fragment/FragmentHandlerTest.php
@@ -39,31 +39,25 @@ class FragmentHandlerTest extends TestCase
;
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testRenderWhenRendererDoesNotExist()
{
+ $this->expectException('InvalidArgumentException');
$handler = new FragmentHandler($this->requestStack);
$handler->render('/', 'foo');
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testRenderWithUnknownRenderer()
{
+ $this->expectException('InvalidArgumentException');
$handler = $this->getHandler($this->returnValue(new Response('foo')));
$handler->render('/', 'bar');
}
- /**
- * @expectedException \RuntimeException
- * @expectedExceptionMessage Error when rendering "http://localhost/" (Status code is 404).
- */
public function testDeliverWithUnsuccessfulResponse()
{
+ $this->expectException('RuntimeException');
+ $this->expectExceptionMessage('Error when rendering "http://localhost/" (Status code is 404).');
$handler = $this->getHandler($this->returnValue(new Response('foo', 404)));
$handler->render('/', 'foo');
diff --git a/src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php b/src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php
index 1d0272d151..c6e46cf715 100644
--- a/src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\HttpKernel\Tests\Fragment;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Controller\ControllerReference;
use Symfony\Component\HttpKernel\Fragment\HIncludeFragmentRenderer;
@@ -21,11 +22,11 @@ use Twig\Loader\ArrayLoader;
class HIncludeFragmentRendererTest extends TestCase
{
- /**
- * @expectedException \LogicException
- */
+ use ForwardCompatTestTrait;
+
public function testRenderExceptionWhenControllerAndNoSigner()
{
+ $this->expectException('LogicException');
$strategy = new HIncludeFragmentRenderer();
$strategy->render(new ControllerReference('main_controller', [], []), Request::create('/'));
}
diff --git a/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php b/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php
index ce71804187..f3734ea9f7 100644
--- a/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\HttpKernel\Tests\Fragment;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
@@ -25,6 +26,8 @@ use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
class InlineFragmentRendererTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testRender()
{
$strategy = new InlineFragmentRenderer($this->getKernel($this->returnValue(new Response('foo'))));
@@ -69,11 +72,9 @@ class InlineFragmentRendererTest extends TestCase
Request::setTrustedProxies([], -1);
}
- /**
- * @expectedException \RuntimeException
- */
public function testRenderExceptionNoIgnoreErrors()
{
+ $this->expectException('RuntimeException');
$dispatcher = $this->getMockBuilder(EventDispatcherInterface::class)->getMock();
$dispatcher->expects($this->never())->method('dispatch');
diff --git a/src/Symfony/Component/HttpKernel/Tests/Fragment/RoutableFragmentRendererTest.php b/src/Symfony/Component/HttpKernel/Tests/Fragment/RoutableFragmentRendererTest.php
index c03e8c4a92..dc4e59da83 100644
--- a/src/Symfony/Component/HttpKernel/Tests/Fragment/RoutableFragmentRendererTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/Fragment/RoutableFragmentRendererTest.php
@@ -12,11 +12,14 @@
namespace Symfony\Component\HttpKernel\Tests\Fragment;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Controller\ControllerReference;
class RoutableFragmentRendererTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
/**
* @dataProvider getGenerateFragmentUriData
*/
@@ -56,11 +59,11 @@ class RoutableFragmentRendererTest extends TestCase
}
/**
- * @expectedException \LogicException
- * @dataProvider getGenerateFragmentUriDataWithNonScalar
+ * @dataProvider getGenerateFragmentUriDataWithNonScalar
*/
public function testGenerateFragmentUriWithNonScalar($controller)
{
+ $this->expectException('LogicException');
$this->callGenerateFragmentUriMethod($controller, Request::create('/'));
}
diff --git a/src/Symfony/Component/HttpKernel/Tests/Fragment/SsiFragmentRendererTest.php b/src/Symfony/Component/HttpKernel/Tests/Fragment/SsiFragmentRendererTest.php
index b2181725ed..fbf69610fb 100644
--- a/src/Symfony/Component/HttpKernel/Tests/Fragment/SsiFragmentRendererTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/Fragment/SsiFragmentRendererTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\HttpKernel\Tests\Fragment;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Controller\ControllerReference;
use Symfony\Component\HttpKernel\Fragment\SsiFragmentRenderer;
@@ -20,6 +21,8 @@ use Symfony\Component\HttpKernel\UriSigner;
class SsiFragmentRendererTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testRenderFallbackToInlineStrategyIfSsiNotSupported()
{
$strategy = new SsiFragmentRenderer(new Ssi(), $this->getInlineStrategy(true));
@@ -56,11 +59,9 @@ class SsiFragmentRendererTest extends TestCase
);
}
- /**
- * @expectedException \LogicException
- */
public function testRenderControllerReferenceWithoutSignerThrowsException()
{
+ $this->expectException('LogicException');
$strategy = new SsiFragmentRenderer(new Ssi(), $this->getInlineStrategy());
$request = Request::create('/');
@@ -70,11 +71,9 @@ class SsiFragmentRendererTest extends TestCase
$strategy->render(new ControllerReference('main_controller'), $request);
}
- /**
- * @expectedException \LogicException
- */
public function testRenderAltControllerReferenceWithoutSignerThrowsException()
{
+ $this->expectException('LogicException');
$strategy = new SsiFragmentRenderer(new Ssi(), $this->getInlineStrategy());
$request = Request::create('/');
diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php
index ef717c63f5..ad0152ea7c 100644
--- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php
@@ -12,12 +12,15 @@
namespace Symfony\Component\HttpKernel\Tests\HttpCache;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpCache\Esi;
class EsiTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testHasSurrogateEsiCapability()
{
$esi = new Esi();
@@ -153,11 +156,9 @@ class EsiTest extends TestCase
$this->assertEquals('php cript language=php>', $response->getContent());
}
- /**
- * @expectedException \RuntimeException
- */
public function testProcessWhenNoSrcInAnEsi()
{
+ $this->expectException('RuntimeException');
$esi = new Esi();
$request = Request::create('/');
@@ -193,11 +194,9 @@ class EsiTest extends TestCase
$this->assertEquals('foo', $esi->handle($cache, '/', '/alt', true));
}
- /**
- * @expectedException \RuntimeException
- */
public function testHandleWhenResponseIsNot200()
{
+ $this->expectException('RuntimeException');
$esi = new Esi();
$response = new Response('foo');
$response->setStatusCode(404);
diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/SsiTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/SsiTest.php
index 4411427028..bb1a9acb71 100644
--- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/SsiTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/SsiTest.php
@@ -12,12 +12,15 @@
namespace Symfony\Component\HttpKernel\Tests\HttpCache;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpCache\Ssi;
class SsiTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testHasSurrogateSsiCapability()
{
$ssi = new Ssi();
@@ -120,11 +123,9 @@ class SsiTest extends TestCase
$this->assertEquals('php cript language=php>', $response->getContent());
}
- /**
- * @expectedException \RuntimeException
- */
public function testProcessWhenNoSrcInAnSsi()
{
+ $this->expectException('RuntimeException');
$ssi = new Ssi();
$request = Request::create('/');
@@ -160,11 +161,9 @@ class SsiTest extends TestCase
$this->assertEquals('foo', $ssi->handle($cache, '/', '/alt', true));
}
- /**
- * @expectedException \RuntimeException
- */
public function testHandleWhenResponseIsNot200()
{
+ $this->expectException('RuntimeException');
$ssi = new Ssi();
$response = new Response('foo');
$response->setStatusCode(404);
diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php
index 457b525dd2..da259be2af 100644
--- a/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\HttpKernel\Tests;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
@@ -29,21 +30,19 @@ use Symfony\Component\HttpKernel\KernelEvents;
class HttpKernelTest extends TestCase
{
- /**
- * @expectedException \RuntimeException
- */
+ use ForwardCompatTestTrait;
+
public function testHandleWhenControllerThrowsAnExceptionAndCatchIsTrue()
{
+ $this->expectException('RuntimeException');
$kernel = $this->getHttpKernel(new EventDispatcher(), function () { throw new \RuntimeException(); });
$kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUEST, true);
}
- /**
- * @expectedException \RuntimeException
- */
public function testHandleWhenControllerThrowsAnExceptionAndCatchIsFalseAndNoListenerIsRegistered()
{
+ $this->expectException('RuntimeException');
$kernel = $this->getHttpKernel(new EventDispatcher(), function () { throw new \RuntimeException(); });
$kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUEST, false);
@@ -158,11 +157,9 @@ class HttpKernelTest extends TestCase
$this->assertEquals('hello', $kernel->handle(new Request())->getContent());
}
- /**
- * @expectedException \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
- */
public function testHandleWhenNoControllerIsFound()
{
+ $this->expectException('Symfony\Component\HttpKernel\Exception\NotFoundHttpException');
$dispatcher = new EventDispatcher();
$kernel = $this->getHttpKernel($dispatcher, false);
@@ -319,11 +316,9 @@ class HttpKernelTest extends TestCase
$kernel->handle($request, HttpKernelInterface::MASTER_REQUEST);
}
- /**
- * @expectedException \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
- */
public function testInconsistentClientIpsOnMasterRequests()
{
+ $this->expectException('Symfony\Component\HttpKernel\Exception\BadRequestHttpException');
$request = new Request();
$request->setTrustedProxies(['1.1.1.1'], Request::HEADER_X_FORWARDED_FOR | Request::HEADER_FORWARDED);
$request->server->set('REMOTE_ADDR', '1.1.1.1');
diff --git a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php
index 3a0beb6a4c..91c056106a 100644
--- a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php
@@ -66,12 +66,10 @@ class KernelTest extends TestCase
$this->assertNull($clone->getContainer());
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage The environment "test.env" contains invalid characters, it can only contain characters allowed in PHP class names.
- */
public function testClassNameValidityGetter()
{
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('The environment "test.env" contains invalid characters, it can only contain characters allowed in PHP class names.');
// We check the classname that will be generated by using a $env that
// contains invalid characters.
$env = 'test.env';
@@ -320,35 +318,27 @@ EOF;
$this->assertEquals($expected, serialize($kernel));
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testLocateResourceThrowsExceptionWhenNameIsNotValid()
{
+ $this->expectException('InvalidArgumentException');
$this->getKernel()->locateResource('Foo');
}
- /**
- * @expectedException \RuntimeException
- */
public function testLocateResourceThrowsExceptionWhenNameIsUnsafe()
{
+ $this->expectException('RuntimeException');
$this->getKernel()->locateResource('@FooBundle/../bar');
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testLocateResourceThrowsExceptionWhenBundleDoesNotExist()
{
+ $this->expectException('InvalidArgumentException');
$this->getKernel()->locateResource('@FooBundle/config/routing.xml');
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testLocateResourceThrowsExceptionWhenResourceDoesNotExist()
{
+ $this->expectException('InvalidArgumentException');
$kernel = $this->getKernel(['getBundle']);
$kernel
->expects($this->once())
@@ -436,12 +426,10 @@ EOF;
);
}
- /**
- * @expectedException \LogicException
- * @expectedExceptionMessage Trying to register two bundles with the same name "DuplicateName"
- */
public function testInitializeBundleThrowsExceptionWhenRegisteringTwoBundlesWithTheSameName()
{
+ $this->expectException('LogicException');
+ $this->expectExceptionMessage('Trying to register two bundles with the same name "DuplicateName"');
$fooBundle = $this->getBundle(null, null, 'FooBundle', 'DuplicateName');
$barBundle = $this->getBundle(null, null, 'BarBundle', 'DuplicateName');
diff --git a/src/Symfony/Component/HttpKernel/Tests/Log/LoggerTest.php b/src/Symfony/Component/HttpKernel/Tests/Log/LoggerTest.php
index 26e9a99abd..1c8c064c3d 100644
--- a/src/Symfony/Component/HttpKernel/Tests/Log/LoggerTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/Log/LoggerTest.php
@@ -110,27 +110,21 @@ class LoggerTest extends TestCase
$this->assertSame([], $this->getLogs());
}
- /**
- * @expectedException \Psr\Log\InvalidArgumentException
- */
public function testThrowsOnInvalidLevel()
{
+ $this->expectException('Psr\Log\InvalidArgumentException');
$this->logger->log('invalid level', 'Foo');
}
- /**
- * @expectedException \Psr\Log\InvalidArgumentException
- */
public function testThrowsOnInvalidMinLevel()
{
+ $this->expectException('Psr\Log\InvalidArgumentException');
new Logger('invalid');
}
- /**
- * @expectedException \Psr\Log\InvalidArgumentException
- */
public function testInvalidOutput()
{
+ $this->expectException('Psr\Log\InvalidArgumentException');
new Logger(LogLevel::DEBUG, '/');
}
diff --git a/src/Symfony/Component/Intl/Tests/Collator/CollatorTest.php b/src/Symfony/Component/Intl/Tests/Collator/CollatorTest.php
index 840d97532f..b0efe8ed32 100644
--- a/src/Symfony/Component/Intl/Tests/Collator/CollatorTest.php
+++ b/src/Symfony/Component/Intl/Tests/Collator/CollatorTest.php
@@ -11,33 +11,30 @@
namespace Symfony\Component\Intl\Tests\Collator;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Intl\Collator\Collator;
use Symfony\Component\Intl\Globals\IntlGlobals;
class CollatorTest extends AbstractCollatorTest
{
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException
- */
+ use ForwardCompatTestTrait;
+
public function testConstructorWithUnsupportedLocale()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException');
new Collator('pt_BR');
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
- */
public function testCompare()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
$collator = $this->getCollator('en');
$collator->compare('a', 'b');
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
- */
public function testGetAttribute()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
$collator = $this->getCollator('en');
$collator->getAttribute(Collator::NUMERIC_COLLATION);
}
@@ -66,38 +63,30 @@ class CollatorTest extends AbstractCollatorTest
$this->assertInstanceOf('\Symfony\Component\Intl\Collator\Collator', $collator);
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
- */
public function testGetSortKey()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
$collator = $this->getCollator('en');
$collator->getSortKey('Hello');
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
- */
public function testGetStrength()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
$collator = $this->getCollator('en');
$collator->getStrength();
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
- */
public function testSetAttribute()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
$collator = $this->getCollator('en');
$collator->setAttribute(Collator::NUMERIC_COLLATION, Collator::ON);
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
- */
public function testSetStrength()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
$collator = $this->getCollator('en');
$collator->setStrength(Collator::PRIMARY);
}
diff --git a/src/Symfony/Component/Intl/Tests/CountriesTest.php b/src/Symfony/Component/Intl/Tests/CountriesTest.php
index df1450f287..fec90d3fde 100644
--- a/src/Symfony/Component/Intl/Tests/CountriesTest.php
+++ b/src/Symfony/Component/Intl/Tests/CountriesTest.php
@@ -337,11 +337,9 @@ class CountriesTest extends ResourceBundleTestCase
$this->assertNotSame($countryNameZh, $countryNameZhTw, 'zh_TW does not fall back to zh');
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MissingResourceException
- */
public function testGetNameWithInvalidCountryCode()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException');
Countries::getName('foo');
}
diff --git a/src/Symfony/Component/Intl/Tests/CurrenciesTest.php b/src/Symfony/Component/Intl/Tests/CurrenciesTest.php
index 612e017b0a..f681f1c2d8 100644
--- a/src/Symfony/Component/Intl/Tests/CurrenciesTest.php
+++ b/src/Symfony/Component/Intl/Tests/CurrenciesTest.php
@@ -725,10 +725,10 @@ class CurrenciesTest extends ResourceBundleTestCase
/**
* @dataProvider provideCurrenciesWithoutNumericEquivalent
- * @expectedException \Symfony\Component\Intl\Exception\MissingResourceException
*/
public function testGetNumericCodeFailsIfNoNumericEquivalent($currency)
{
+ $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException');
Currencies::getNumericCode($currency);
}
@@ -770,18 +770,16 @@ class CurrenciesTest extends ResourceBundleTestCase
/**
* @dataProvider provideInvalidNumericCodes
- * @expectedException \Symfony\Component\Intl\Exception\MissingResourceException
*/
public function testForNumericCodeFailsIfInvalidNumericCode($currency)
{
+ $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException');
Currencies::forNumericCode($currency);
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MissingResourceException
- */
public function testGetNameWithInvalidCurrencyCode()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException');
Currencies::getName('foo');
}
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 02f9830de4..f20da714b5 100644
--- a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/BundleEntryReaderTest.php
+++ b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/BundleEntryReaderTest.php
@@ -105,11 +105,9 @@ class BundleEntryReaderTest extends TestCase
$this->assertSame('Bar', $this->reader->readEntry(self::RES_DIR, 'root', ['Entries', 'Foo']));
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MissingResourceException
- */
public function testReadNonExistingEntry()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException');
$this->readerImpl->expects($this->once())
->method('read')
->with(self::RES_DIR, 'root')
@@ -133,11 +131,9 @@ class BundleEntryReaderTest extends TestCase
$this->assertSame('Lah', $this->reader->readEntry(self::RES_DIR, 'en_GB', ['Entries', 'Bam']));
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MissingResourceException
- */
public function testDontFallbackIfEntryDoesNotExistAndFallbackDisabled()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException');
$this->readerImpl->expects($this->once())
->method('read')
->with(self::RES_DIR, 'en_GB')
@@ -161,11 +157,9 @@ class BundleEntryReaderTest extends TestCase
$this->assertSame('Lah', $this->reader->readEntry(self::RES_DIR, 'en_GB', ['Entries', 'Bam']));
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MissingResourceException
- */
public function testDontFallbackIfLocaleDoesNotExistAndFallbackDisabled()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException');
$this->readerImpl->expects($this->once())
->method('read')
->with(self::RES_DIR, 'en_GB')
@@ -293,11 +287,9 @@ class BundleEntryReaderTest extends TestCase
$this->assertSame($childData, $this->reader->readEntry(self::RES_DIR, 'en_GB', ['Foo', 'Bar'], true));
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MissingResourceException
- */
public function testFailIfEntryFoundNeitherInParentNorChild()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException');
$this->readerImpl->expects($this->at(0))
->method('read')
->with(self::RES_DIR, 'en_GB')
diff --git a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/IntlBundleReaderTest.php b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/IntlBundleReaderTest.php
index a3cc63669b..3b86afbb0f 100644
--- a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/IntlBundleReaderTest.php
+++ b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/IntlBundleReaderTest.php
@@ -76,27 +76,21 @@ class IntlBundleReaderTest extends TestCase
$this->assertArrayNotHasKey('ExistsNot', $data);
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\ResourceBundleNotFoundException
- */
public function testReadFailsIfNonExistingLocale()
{
+ $this->expectException('Symfony\Component\Intl\Exception\ResourceBundleNotFoundException');
$this->reader->read(__DIR__.'/Fixtures/res', 'foo');
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\ResourceBundleNotFoundException
- */
public function testReadFailsIfNonExistingFallbackLocale()
{
+ $this->expectException('Symfony\Component\Intl\Exception\ResourceBundleNotFoundException');
$this->reader->read(__DIR__.'/Fixtures/res', 'ro_AT');
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\RuntimeException
- */
public function testReadFailsIfNonExistingDirectory()
{
+ $this->expectException('Symfony\Component\Intl\Exception\RuntimeException');
$this->reader->read(__DIR__.'/foo', 'ro');
}
}
diff --git a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/JsonBundleReaderTest.php b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/JsonBundleReaderTest.php
index cf9dac64b5..73697f0565 100644
--- a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/JsonBundleReaderTest.php
+++ b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/JsonBundleReaderTest.php
@@ -41,43 +41,33 @@ class JsonBundleReaderTest extends TestCase
$this->assertArrayNotHasKey('ExistsNot', $data);
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\ResourceBundleNotFoundException
- */
public function testReadFailsIfNonExistingLocale()
{
+ $this->expectException('Symfony\Component\Intl\Exception\ResourceBundleNotFoundException');
$this->reader->read(__DIR__.'/Fixtures/json', 'foo');
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\RuntimeException
- */
public function testReadFailsIfNonExistingDirectory()
{
+ $this->expectException('Symfony\Component\Intl\Exception\RuntimeException');
$this->reader->read(__DIR__.'/foo', 'en');
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\RuntimeException
- */
public function testReadFailsIfNotAFile()
{
+ $this->expectException('Symfony\Component\Intl\Exception\RuntimeException');
$this->reader->read(__DIR__.'/Fixtures/NotAFile', 'en');
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\RuntimeException
- */
public function testReadFailsIfInvalidJson()
{
+ $this->expectException('Symfony\Component\Intl\Exception\RuntimeException');
$this->reader->read(__DIR__.'/Fixtures/json', 'en_Invalid');
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\ResourceBundleNotFoundException
- */
public function testReaderDoesNotBreakOutOfGivenPath()
{
+ $this->expectException('Symfony\Component\Intl\Exception\ResourceBundleNotFoundException');
$this->reader->read(__DIR__.'/Fixtures/json', '../invalid_directory/en');
}
}
diff --git a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/PhpBundleReaderTest.php b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/PhpBundleReaderTest.php
index d4879b9479..300f860aa1 100644
--- a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/PhpBundleReaderTest.php
+++ b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/PhpBundleReaderTest.php
@@ -41,35 +41,27 @@ class PhpBundleReaderTest extends TestCase
$this->assertArrayNotHasKey('ExistsNot', $data);
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\ResourceBundleNotFoundException
- */
public function testReadFailsIfNonExistingLocale()
{
+ $this->expectException('Symfony\Component\Intl\Exception\ResourceBundleNotFoundException');
$this->reader->read(__DIR__.'/Fixtures/php', 'foo');
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\RuntimeException
- */
public function testReadFailsIfNonExistingDirectory()
{
+ $this->expectException('Symfony\Component\Intl\Exception\RuntimeException');
$this->reader->read(__DIR__.'/foo', 'en');
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\RuntimeException
- */
public function testReadFailsIfNotAFile()
{
+ $this->expectException('Symfony\Component\Intl\Exception\RuntimeException');
$this->reader->read(__DIR__.'/Fixtures/NotAFile', 'en');
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\ResourceBundleNotFoundException
- */
public function testReaderDoesNotBreakOutOfGivenPath()
{
+ $this->expectException('Symfony\Component\Intl\Exception\ResourceBundleNotFoundException');
$this->reader->read(__DIR__.'/Fixtures/php', '../invalid_directory/en');
}
}
diff --git a/src/Symfony/Component/Intl/Tests/Data/Util/RingBufferTest.php b/src/Symfony/Component/Intl/Tests/Data/Util/RingBufferTest.php
index 425c0bba04..b990a94362 100644
--- a/src/Symfony/Component/Intl/Tests/Data/Util/RingBufferTest.php
+++ b/src/Symfony/Component/Intl/Tests/Data/Util/RingBufferTest.php
@@ -55,11 +55,9 @@ class RingBufferTest extends TestCase
$this->assertSame('bam', $this->buffer[2]);
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\OutOfBoundsException
- */
public function testReadNonExistingFails()
{
+ $this->expectException('Symfony\Component\Intl\Exception\OutOfBoundsException');
$this->buffer['foo'];
}
@@ -75,11 +73,9 @@ class RingBufferTest extends TestCase
$this->assertArrayNotHasKey('foo', $this->buffer);
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\OutOfBoundsException
- */
public function testReadOverwrittenFails()
{
+ $this->expectException('Symfony\Component\Intl\Exception\OutOfBoundsException');
$this->buffer[0] = 'foo';
$this->buffer['bar'] = 'baz';
$this->buffer[2] = 'bam';
diff --git a/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php b/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php
index cda1935eb5..f40ee04ed5 100644
--- a/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php
+++ b/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php
@@ -11,11 +11,14 @@
namespace Symfony\Component\Intl\Tests\DateFormatter;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Intl\DateFormatter\IntlDateFormatter;
use Symfony\Component\Intl\Globals\IntlGlobals;
class IntlDateFormatterTest extends AbstractIntlDateFormatterTest
{
+ use ForwardCompatTestTrait;
+
public function testConstructor()
{
$formatter = new IntlDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, 'UTC', IntlDateFormatter::GREGORIAN, 'y-M-d');
@@ -34,11 +37,9 @@ class IntlDateFormatterTest extends AbstractIntlDateFormatterTest
$this->assertEquals('y-M-d', $formatter->getPattern());
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException
- */
public function testConstructorWithUnsupportedLocale()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException');
new IntlDateFormatter('pt_BR', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT);
}
@@ -73,21 +74,17 @@ class IntlDateFormatterTest extends AbstractIntlDateFormatterTest
}
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\NotImplementedException
- */
public function testFormatWithUnimplementedChars()
{
+ $this->expectException('Symfony\Component\Intl\Exception\NotImplementedException');
$pattern = 'Y';
$formatter = new IntlDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, 'UTC', IntlDateFormatter::GREGORIAN, $pattern);
$formatter->format(0);
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\NotImplementedException
- */
public function testFormatWithNonIntegerTimestamp()
{
+ $this->expectException('Symfony\Component\Intl\Exception\NotImplementedException');
$formatter = $this->getDefaultDateFormatter();
$formatter->format([]);
}
@@ -110,56 +107,44 @@ class IntlDateFormatterTest extends AbstractIntlDateFormatterTest
$this->assertFalse($formatter->isLenient());
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
- */
public function testLocaltime()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
$formatter = $this->getDefaultDateFormatter();
$formatter->localtime('Wednesday, December 31, 1969 4:00:00 PM PT');
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentNotImplementedException
- */
public function testParseWithNotNullPositionValue()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodArgumentNotImplementedException');
$position = 0;
$formatter = $this->getDefaultDateFormatter('y');
$this->assertSame(0, $formatter->parse('1970', $position));
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
- */
public function testSetCalendar()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
$formatter = $this->getDefaultDateFormatter();
$formatter->setCalendar(IntlDateFormatter::GREGORIAN);
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException
- */
public function testSetLenient()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException');
$formatter = $this->getDefaultDateFormatter();
$formatter->setLenient(true);
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\NotImplementedException
- */
public function testFormatWithGmtTimeZoneAndMinutesOffset()
{
+ $this->expectException('Symfony\Component\Intl\Exception\NotImplementedException');
parent::testFormatWithGmtTimeZoneAndMinutesOffset();
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\NotImplementedException
- */
public function testFormatWithNonStandardTimezone()
{
+ $this->expectException('Symfony\Component\Intl\Exception\NotImplementedException');
parent::testFormatWithNonStandardTimezone();
}
diff --git a/src/Symfony/Component/Intl/Tests/LanguagesTest.php b/src/Symfony/Component/Intl/Tests/LanguagesTest.php
index b87ea9a38d..5da1060cc3 100644
--- a/src/Symfony/Component/Intl/Tests/LanguagesTest.php
+++ b/src/Symfony/Component/Intl/Tests/LanguagesTest.php
@@ -907,18 +907,16 @@ class LanguagesTest extends ResourceBundleTestCase
/**
* @dataProvider provideLanguagesWithoutAlpha3Equivalent
- * @expectedException \Symfony\Component\Intl\Exception\MissingResourceException
*/
public function testGetAlpha3CodeFailsIfNoAlpha3Equivalent($language)
{
+ $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException');
Languages::getAlpha3Code($language);
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MissingResourceException
- */
public function testGetNameWithInvalidLanguageCode()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException');
Languages::getName('foo');
}
diff --git a/src/Symfony/Component/Intl/Tests/Locale/LocaleTest.php b/src/Symfony/Component/Intl/Tests/Locale/LocaleTest.php
index e7bdb7102a..e5d547294b 100644
--- a/src/Symfony/Component/Intl/Tests/Locale/LocaleTest.php
+++ b/src/Symfony/Component/Intl/Tests/Locale/LocaleTest.php
@@ -11,15 +11,16 @@
namespace Symfony\Component\Intl\Tests\Locale;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Intl\Locale\Locale;
class LocaleTest extends AbstractLocaleTest
{
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
- */
+ use ForwardCompatTestTrait;
+
public function testAcceptFromHttp()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
$this->call('acceptFromHttp', 'pt-br,en-us;q=0.7,en;q=0.5');
}
@@ -34,11 +35,9 @@ class LocaleTest extends AbstractLocaleTest
$this->assertSame('123', $this->call('canonicalize', 123));
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
- */
public function testComposeLocale()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
$subtags = [
'language' => 'pt',
'script' => 'Latn',
@@ -47,99 +46,75 @@ class LocaleTest extends AbstractLocaleTest
$this->call('composeLocale', $subtags);
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
- */
public function testFilterMatches()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
$this->call('filterMatches', 'pt-BR', 'pt-BR');
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
- */
public function testGetAllVariants()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
$this->call('getAllVariants', 'pt_BR_Latn');
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
- */
public function testGetDisplayLanguage()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
$this->call('getDisplayLanguage', 'pt-Latn-BR', 'en');
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
- */
public function testGetDisplayName()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
$this->call('getDisplayName', 'pt-Latn-BR', 'en');
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
- */
public function testGetDisplayRegion()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
$this->call('getDisplayRegion', 'pt-Latn-BR', 'en');
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
- */
public function testGetDisplayScript()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
$this->call('getDisplayScript', 'pt-Latn-BR', 'en');
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
- */
public function testGetDisplayVariant()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
$this->call('getDisplayVariant', 'pt-Latn-BR', 'en');
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
- */
public function testGetKeywords()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
$this->call('getKeywords', 'pt-BR@currency=BRL');
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
- */
public function testGetPrimaryLanguage()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
$this->call('getPrimaryLanguage', 'pt-Latn-BR');
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
- */
public function testGetRegion()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
$this->call('getRegion', 'pt-Latn-BR');
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
- */
public function testGetScript()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
$this->call('getScript', 'pt-Latn-BR');
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
- */
public function testLookup()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
$langtag = [
'pt-Latn-BR',
'pt-BR',
@@ -147,19 +122,15 @@ class LocaleTest extends AbstractLocaleTest
$this->call('lookup', $langtag, 'pt-BR-x-priv1');
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
- */
public function testParseLocale()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
$this->call('parseLocale', 'pt-Latn-BR');
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
- */
public function testSetDefault()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
$this->call('setDefault', 'pt_BR');
}
diff --git a/src/Symfony/Component/Intl/Tests/LocalesTest.php b/src/Symfony/Component/Intl/Tests/LocalesTest.php
index 5ccff4923f..3265c723d1 100644
--- a/src/Symfony/Component/Intl/Tests/LocalesTest.php
+++ b/src/Symfony/Component/Intl/Tests/LocalesTest.php
@@ -84,11 +84,9 @@ class LocalesTest extends ResourceBundleTestCase
}
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MissingResourceException
- */
public function testGetNameWithInvalidLocale()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException');
Locales::getName('foo');
}
diff --git a/src/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php b/src/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php
index c5c047642d..28bf9f5473 100644
--- a/src/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php
+++ b/src/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php
@@ -23,44 +23,34 @@ class NumberFormatterTest extends AbstractNumberFormatterTest
{
use ForwardCompatTestTrait;
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException
- */
public function testConstructorWithUnsupportedLocale()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException');
new NumberFormatter('pt_BR');
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException
- */
public function testConstructorWithUnsupportedStyle()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException');
new NumberFormatter('en', NumberFormatter::PATTERN_DECIMAL);
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentNotImplementedException
- */
public function testConstructorWithPatternDifferentThanNull()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodArgumentNotImplementedException');
new NumberFormatter('en', NumberFormatter::DECIMAL, '');
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException
- */
public function testSetAttributeWithUnsupportedAttribute()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException');
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$formatter->setAttribute(NumberFormatter::LENIENT_PARSE, null);
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException
- */
public function testSetAttributeInvalidRoundingMode()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException');
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$formatter->setAttribute(NumberFormatter::ROUNDING_MODE, -1);
}
@@ -81,73 +71,69 @@ class NumberFormatterTest extends AbstractNumberFormatterTest
);
}
- /**
- * @expectedException \RuntimeException
- */
public function testFormatWithCurrencyStyle()
{
+ $this->expectException('RuntimeException');
parent::testFormatWithCurrencyStyle();
}
/**
* @dataProvider formatTypeInt32Provider
- * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException
*/
public function testFormatTypeInt32($formatter, $value, $expected, $message = '')
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException');
parent::testFormatTypeInt32($formatter, $value, $expected, $message);
}
/**
* @dataProvider formatTypeInt32WithCurrencyStyleProvider
- * @expectedException \Symfony\Component\Intl\Exception\NotImplementedException
*/
public function testFormatTypeInt32WithCurrencyStyle($formatter, $value, $expected, $message = '')
{
+ $this->expectException('Symfony\Component\Intl\Exception\NotImplementedException');
parent::testFormatTypeInt32WithCurrencyStyle($formatter, $value, $expected, $message);
}
/**
* @dataProvider formatTypeInt64Provider
- * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException
*/
public function testFormatTypeInt64($formatter, $value, $expected)
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException');
parent::testFormatTypeInt64($formatter, $value, $expected);
}
/**
* @dataProvider formatTypeInt64WithCurrencyStyleProvider
- * @expectedException \Symfony\Component\Intl\Exception\NotImplementedException
*/
public function testFormatTypeInt64WithCurrencyStyle($formatter, $value, $expected)
{
+ $this->expectException('Symfony\Component\Intl\Exception\NotImplementedException');
parent::testFormatTypeInt64WithCurrencyStyle($formatter, $value, $expected);
}
/**
* @dataProvider formatTypeDoubleProvider
- * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException
*/
public function testFormatTypeDouble($formatter, $value, $expected)
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException');
parent::testFormatTypeDouble($formatter, $value, $expected);
}
/**
* @dataProvider formatTypeDoubleWithCurrencyStyleProvider
- * @expectedException \Symfony\Component\Intl\Exception\NotImplementedException
*/
public function testFormatTypeDoubleWithCurrencyStyle($formatter, $value, $expected)
{
+ $this->expectException('Symfony\Component\Intl\Exception\NotImplementedException');
parent::testFormatTypeDoubleWithCurrencyStyle($formatter, $value, $expected);
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
- */
public function testGetPattern()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$formatter->getPattern();
}
@@ -158,38 +144,30 @@ class NumberFormatterTest extends AbstractNumberFormatterTest
$this->assertEquals(IntlGlobals::U_ZERO_ERROR, $formatter->getErrorCode());
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
- */
public function testParseCurrency()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$formatter->parseCurrency(null, $currency);
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
- */
public function testSetPattern()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$formatter->setPattern(null);
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
- */
public function testSetSymbol()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$formatter->setSymbol(null, null);
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
- */
public function testSetTextAttribute()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$formatter->setTextAttribute(null, null);
}
diff --git a/src/Symfony/Component/Intl/Tests/ScriptsTest.php b/src/Symfony/Component/Intl/Tests/ScriptsTest.php
index bc696cf63f..4b7967f548 100644
--- a/src/Symfony/Component/Intl/Tests/ScriptsTest.php
+++ b/src/Symfony/Component/Intl/Tests/ScriptsTest.php
@@ -273,11 +273,9 @@ class ScriptsTest extends ResourceBundleTestCase
}
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MissingResourceException
- */
public function testGetNameWithInvalidScriptCode()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException');
Scripts::getName('foo');
}
diff --git a/src/Symfony/Component/Intl/Tests/TimezonesTest.php b/src/Symfony/Component/Intl/Tests/TimezonesTest.php
index ef922e1de8..c438d32eaa 100644
--- a/src/Symfony/Component/Intl/Tests/TimezonesTest.php
+++ b/src/Symfony/Component/Intl/Tests/TimezonesTest.php
@@ -527,19 +527,15 @@ class TimezonesTest extends ResourceBundleTestCase
}
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MissingResourceException
- */
public function testGetNameWithInvalidTimezone()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException');
Timezones::getName('foo');
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MissingResourceException
- */
public function testGetNameWithAliasTimezone()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException');
Timezones::getName('US/Pacific'); // alias in icu (not compiled), name unavailable in php
}
@@ -561,12 +557,10 @@ class TimezonesTest extends ResourceBundleTestCase
Timezones::getRawOffset('US/Pacific');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Unknown or bad timezone (foobar)
- */
public function testGetRawOffsetWithUnknownTimezone()
{
+ $this->expectException('Exception');
+ $this->expectExceptionMessage('Unknown or bad timezone (foobar)');
Timezones::getRawOffset('foobar');
}
@@ -595,28 +589,22 @@ class TimezonesTest extends ResourceBundleTestCase
$this->assertSame(['Europe/Berlin', 'Europe/Busingen'], Timezones::forCountryCode('DE'));
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MissingResourceException
- */
public function testForCountryCodeWithUnknownCountry()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException');
Timezones::forCountryCode('foobar');
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MissingResourceException
- * @expectedExceptionMessage Country codes must be in uppercase, but "nl" was passed. Try with "NL" country code instead.
- */
public function testForCountryCodeWithWrongCountryCode()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException');
+ $this->expectExceptionMessage('Country codes must be in uppercase, but "nl" was passed. Try with "NL" country code instead.');
Timezones::forCountryCode('nl');
}
- /**
- * @expectedException \Symfony\Component\Intl\Exception\MissingResourceException
- */
public function testGetCountryCodeWithUnknownTimezone()
{
+ $this->expectException('Symfony\Component\Intl\Exception\MissingResourceException');
Timezones::getCountryCode('foobar');
}
diff --git a/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/EntryManagerTest.php b/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/EntryManagerTest.php
index 758ae78e49..918ff9af1b 100644
--- a/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/EntryManagerTest.php
+++ b/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/EntryManagerTest.php
@@ -11,18 +11,19 @@
namespace Symfony\Component\Ldap\Tests\Adapter\ExtLdap;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Ldap\Adapter\ExtLdap\Connection;
use Symfony\Component\Ldap\Adapter\ExtLdap\EntryManager;
use Symfony\Component\Ldap\Entry;
class EntryManagerTest extends TestCase
{
- /**
- * @expectedException \Symfony\Component\Ldap\Exception\LdapException
- * @expectedExceptionMessage Entry "$$$$$$" malformed, could not parse RDN.
- */
+ use ForwardCompatTestTrait;
+
public function testMove()
{
+ $this->expectException('Symfony\Component\Ldap\Exception\LdapException');
+ $this->expectExceptionMessage('Entry "$$$$$$" malformed, could not parse RDN.');
$connection = $this->createMock(Connection::class);
$connection
->expects($this->once())
@@ -33,12 +34,10 @@ class EntryManagerTest extends TestCase
$entryManager->move($entry, 'a');
}
- /**
- * @expectedException \Symfony\Component\Ldap\Exception\NotBoundException
- * @expectedExceptionMessage Query execution is not possible without binding the connection first.
- */
public function testGetResources()
{
+ $this->expectException('Symfony\Component\Ldap\Exception\NotBoundException');
+ $this->expectExceptionMessage('Query execution is not possible without binding the connection first.');
$connection = $this->getMockBuilder(Connection::class)->getMock();
$connection
->expects($this->once())
diff --git a/src/Symfony/Component/Lock/Tests/LockTest.php b/src/Symfony/Component/Lock/Tests/LockTest.php
index 1239ddba0f..1fffe74808 100644
--- a/src/Symfony/Component/Lock/Tests/LockTest.php
+++ b/src/Symfony/Component/Lock/Tests/LockTest.php
@@ -13,6 +13,7 @@ namespace Symfony\Component\Lock\Tests;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Lock\BlockingStoreInterface;
use Symfony\Component\Lock\Exception\LockConflictedException;
use Symfony\Component\Lock\Key;
@@ -24,6 +25,8 @@ use Symfony\Component\Lock\PersistingStoreInterface;
*/
class LockTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testAcquireNoBlocking()
{
$key = new Key(uniqid(__METHOD__, true));
@@ -248,11 +251,9 @@ class LockTest extends TestCase
unset($lock);
}
- /**
- * @expectedException \Symfony\Component\Lock\Exception\LockReleasingException
- */
public function testReleaseThrowsExceptionWhenDeletionFail()
{
+ $this->expectException('Symfony\Component\Lock\Exception\LockReleasingException');
$key = new Key(uniqid(__METHOD__, true));
$store = $this->getMockBuilder(PersistingStoreInterface::class)->getMock();
$lock = new Lock($key, $store, 10);
@@ -271,11 +272,9 @@ class LockTest extends TestCase
$lock->release();
}
- /**
- * @expectedException \Symfony\Component\Lock\Exception\LockReleasingException
- */
public function testReleaseThrowsExceptionIfNotWellDeleted()
{
+ $this->expectException('Symfony\Component\Lock\Exception\LockReleasingException');
$key = new Key(uniqid(__METHOD__, true));
$store = $this->getMockBuilder(PersistingStoreInterface::class)->getMock();
$lock = new Lock($key, $store, 10);
@@ -294,11 +293,9 @@ class LockTest extends TestCase
$lock->release();
}
- /**
- * @expectedException \Symfony\Component\Lock\Exception\LockReleasingException
- */
public function testReleaseThrowsAndLog()
{
+ $this->expectException('Symfony\Component\Lock\Exception\LockReleasingException');
$key = new Key(uniqid(__METHOD__, true));
$store = $this->getMockBuilder(PersistingStoreInterface::class)->getMock();
$logger = $this->getMockBuilder(LoggerInterface::class)->getMock();
diff --git a/src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php
index 3cc258c3b7..7afe3e800d 100644
--- a/src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php
+++ b/src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php
@@ -70,11 +70,9 @@ class CombinedStoreTest extends AbstractStoreTest
$this->store = new CombinedStore([$this->store1, $this->store2], $this->strategy);
}
- /**
- * @expectedException \Symfony\Component\Lock\Exception\LockConflictedException
- */
public function testSaveThrowsExceptionOnFailure()
{
+ $this->expectException('Symfony\Component\Lock\Exception\LockConflictedException');
$key = new Key(uniqid(__METHOD__, true));
$this->store1
@@ -167,11 +165,9 @@ class CombinedStoreTest extends AbstractStoreTest
}
}
- /**
- * @expectedException \Symfony\Component\Lock\Exception\LockConflictedException
- */
public function testputOffExpirationThrowsExceptionOnFailure()
{
+ $this->expectException('Symfony\Component\Lock\Exception\LockConflictedException');
$key = new Key(uniqid(__METHOD__, true));
$ttl = random_int(1, 10);
diff --git a/src/Symfony/Component/Lock/Tests/Store/ExpiringStoreTestTrait.php b/src/Symfony/Component/Lock/Tests/Store/ExpiringStoreTestTrait.php
index 019b6f40de..15b7522671 100644
--- a/src/Symfony/Component/Lock/Tests/Store/ExpiringStoreTestTrait.php
+++ b/src/Symfony/Component/Lock/Tests/Store/ExpiringStoreTestTrait.php
@@ -11,6 +11,7 @@
namespace Symfony\Component\Lock\Tests\Store;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Lock\Exception\LockExpiredException;
use Symfony\Component\Lock\Key;
use Symfony\Component\Lock\PersistingStoreInterface;
@@ -57,11 +58,10 @@ trait ExpiringStoreTestTrait
/**
* Tests the store thrown exception when TTL expires.
- *
- * @expectedException \Symfony\Component\Lock\Exception\LockExpiredException
*/
public function testAbortAfterExpiration()
{
+ $this->expectException('\Symfony\Component\Lock\Exception\LockExpiredException');
$key = new Key(uniqid(__METHOD__, true));
/** @var PersistingStoreInterface $store */
diff --git a/src/Symfony/Component/Lock/Tests/Store/FlockStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/FlockStoreTest.php
index ef3650c312..42f88390db 100644
--- a/src/Symfony/Component/Lock/Tests/Store/FlockStoreTest.php
+++ b/src/Symfony/Component/Lock/Tests/Store/FlockStoreTest.php
@@ -11,6 +11,7 @@
namespace Symfony\Component\Lock\Tests\Store;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Lock\Key;
use Symfony\Component\Lock\Store\FlockStore;
@@ -19,6 +20,7 @@ use Symfony\Component\Lock\Store\FlockStore;
*/
class FlockStoreTest extends AbstractStoreTest
{
+ use ForwardCompatTestTrait;
use BlockingStoreTestTrait;
/**
@@ -29,12 +31,10 @@ class FlockStoreTest extends AbstractStoreTest
return new FlockStore();
}
- /**
- * @expectedException \Symfony\Component\Lock\Exception\InvalidArgumentException
- * @expectedExceptionMessage The directory "/a/b/c/d/e" is not writable.
- */
public function testConstructWhenRepositoryDoesNotExist()
{
+ $this->expectException('Symfony\Component\Lock\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('The directory "/a/b/c/d/e" is not writable.');
if (!getenv('USER') || 'root' === getenv('USER')) {
$this->markTestSkipped('This test will fail if run under superuser');
}
@@ -42,12 +42,10 @@ class FlockStoreTest extends AbstractStoreTest
new FlockStore('/a/b/c/d/e');
}
- /**
- * @expectedException \Symfony\Component\Lock\Exception\InvalidArgumentException
- * @expectedExceptionMessage The directory "/" is not writable.
- */
public function testConstructWhenRepositoryIsNotWriteable()
{
+ $this->expectException('Symfony\Component\Lock\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('The directory "/" is not writable.');
if (!getenv('USER') || 'root' === getenv('USER')) {
$this->markTestSkipped('This test will fail if run under superuser');
}
diff --git a/src/Symfony/Component/Lock/Tests/Store/MemcachedStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/MemcachedStoreTest.php
index dfc8dfba0d..8d22d1508b 100644
--- a/src/Symfony/Component/Lock/Tests/Store/MemcachedStoreTest.php
+++ b/src/Symfony/Component/Lock/Tests/Store/MemcachedStoreTest.php
@@ -61,11 +61,9 @@ class MemcachedStoreTest extends AbstractStoreTest
$this->markTestSkipped('Memcached expects a TTL greater than 1 sec. Simulating a slow network is too hard');
}
- /**
- * @expectedException \Symfony\Component\Lock\Exception\InvalidTtlException
- */
public function testInvalidTtl()
{
+ $this->expectException('Symfony\Component\Lock\Exception\InvalidTtlException');
$store = $this->getStore();
$store->putOffExpiration(new Key('toto'), 0.1);
}
diff --git a/src/Symfony/Component/Lock/Tests/Store/PdoStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/PdoStoreTest.php
index 0fb25459e0..77a97860fe 100644
--- a/src/Symfony/Component/Lock/Tests/Store/PdoStoreTest.php
+++ b/src/Symfony/Component/Lock/Tests/Store/PdoStoreTest.php
@@ -59,20 +59,16 @@ class PdoStoreTest extends AbstractStoreTest
$this->markTestSkipped('Pdo expects a TTL greater than 1 sec. Simulating a slow network is too hard');
}
- /**
- * @expectedException \Symfony\Component\Lock\Exception\InvalidTtlException
- */
public function testInvalidTtl()
{
+ $this->expectException('Symfony\Component\Lock\Exception\InvalidTtlException');
$store = $this->getStore();
$store->putOffExpiration(new Key('toto'), 0.1);
}
- /**
- * @expectedException \Symfony\Component\Lock\Exception\InvalidTtlException
- */
public function testInvalidTtlConstruct()
{
+ $this->expectException('Symfony\Component\Lock\Exception\InvalidTtlException');
return new PdoStore('sqlite:'.self::$dbFile, [], 0.1, 0.1);
}
}
diff --git a/src/Symfony/Component/Lock/Tests/Store/RedisStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/RedisStoreTest.php
index 17edd80fe2..e385ce523d 100644
--- a/src/Symfony/Component/Lock/Tests/Store/RedisStoreTest.php
+++ b/src/Symfony/Component/Lock/Tests/Store/RedisStoreTest.php
@@ -39,11 +39,9 @@ class RedisStoreTest extends AbstractRedisStoreTest
return $redis;
}
- /**
- * @expectedException \Symfony\Component\Lock\Exception\InvalidTtlException
- */
public function testInvalidTtl()
{
+ $this->expectException('Symfony\Component\Lock\Exception\InvalidTtlException');
new RedisStore($this->getRedisConnection(), -1);
}
}
diff --git a/src/Symfony/Component/Mailer/Tests/Transport/Smtp/Stream/SocketStreamTest.php b/src/Symfony/Component/Mailer/Tests/Transport/Smtp/Stream/SocketStreamTest.php
index b825d1d19a..ead0d7b73a 100644
--- a/src/Symfony/Component/Mailer/Tests/Transport/Smtp/Stream/SocketStreamTest.php
+++ b/src/Symfony/Component/Mailer/Tests/Transport/Smtp/Stream/SocketStreamTest.php
@@ -16,24 +16,20 @@ use Symfony\Component\Mailer\Transport\Smtp\Stream\SocketStream;
class SocketStreamTest extends TestCase
{
- /**
- * @expectedException \Symfony\Component\Mailer\Exception\TransportException
- * @expectedExceptionMessageRegExp /Connection refused|unable to connect/
- */
public function testSocketErrorNoConnection()
{
+ $this->expectException('Symfony\Component\Mailer\Exception\TransportException');
+ $this->expectExceptionMessageRegExp('/Connection refused|unable to connect/');
$s = new SocketStream();
$s->setTimeout(0.1);
$s->setPort(9999);
$s->initialize();
}
- /**
- * @expectedException \Symfony\Component\Mailer\Exception\TransportException
- * @expectedExceptionMessageRegExp /no valid certs found cafile stream|Unable to find the socket transport "ssl"/
- */
public function testSocketErrorBeforeConnectError()
{
+ $this->expectException('Symfony\Component\Mailer\Exception\TransportException');
+ $this->expectExceptionMessageRegExp('/no valid certs found cafile stream|Unable to find the socket transport "ssl"/');
$s = new SocketStream();
$s->setStreamOptions([
'ssl' => [
diff --git a/src/Symfony/Component/Messenger/Tests/Command/DebugCommandTest.php b/src/Symfony/Component/Messenger/Tests/Command/DebugCommandTest.php
index e78b88d0fc..02812adb47 100644
--- a/src/Symfony/Component/Messenger/Tests/Command/DebugCommandTest.php
+++ b/src/Symfony/Component/Messenger/Tests/Command/DebugCommandTest.php
@@ -139,12 +139,10 @@ TXT
);
}
- /**
- * @expectedException \Symfony\Component\Console\Exception\RuntimeException
- * @expectedExceptionMessage Bus "unknown_bus" does not exist. Known buses are command_bus, query_bus.
- */
public function testExceptionOnUnknownBusArgument()
{
+ $this->expectException('Symfony\Component\Console\Exception\RuntimeException');
+ $this->expectExceptionMessage('Bus "unknown_bus" does not exist. Known buses are command_bus, query_bus.');
$command = new DebugCommand(['command_bus' => [], 'query_bus' => []]);
$tester = new CommandTester($command);
diff --git a/src/Symfony/Component/Messenger/Tests/Command/SetupTransportsCommandTest.php b/src/Symfony/Component/Messenger/Tests/Command/SetupTransportsCommandTest.php
index 48df2782bd..6916d5552c 100644
--- a/src/Symfony/Component/Messenger/Tests/Command/SetupTransportsCommandTest.php
+++ b/src/Symfony/Component/Messenger/Tests/Command/SetupTransportsCommandTest.php
@@ -69,12 +69,10 @@ class SetupTransportsCommandTest extends TestCase
$this->assertContains('The "amqp" transport was setup successfully.', $display);
}
- /**
- * @expectedException \RuntimeException
- * @expectedExceptionMessage The "not_found" transport does not exist.
- */
public function testReceiverNameArgumentNotFound()
{
+ $this->expectException('RuntimeException');
+ $this->expectExceptionMessage('The "not_found" transport does not exist.');
// mock a service locator
/** @var MockObject|ServiceLocator $serviceLocator */
$serviceLocator = $this->createMock(ServiceLocator::class);
diff --git a/src/Symfony/Component/Messenger/Tests/DependencyInjection/MessengerPassTest.php b/src/Symfony/Component/Messenger/Tests/DependencyInjection/MessengerPassTest.php
index 87ec875cb3..c50a70ea77 100644
--- a/src/Symfony/Component/Messenger/Tests/DependencyInjection/MessengerPassTest.php
+++ b/src/Symfony/Component/Messenger/Tests/DependencyInjection/MessengerPassTest.php
@@ -134,12 +134,10 @@ class MessengerPassTest extends TestCase
);
}
- /**
- * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
- * @expectedExceptionMessage Invalid handler service "Symfony\Component\Messenger\Tests\Fixtures\DummyCommandHandler": bus "unknown_bus" specified on the tag "messenger.message_handler" does not exist (known ones are: command_bus).
- */
public function testProcessTagWithUnknownBus()
{
+ $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
+ $this->expectExceptionMessage('Invalid handler service "Symfony\Component\Messenger\Tests\Fixtures\DummyCommandHandler": bus "unknown_bus" specified on the tag "messenger.message_handler" does not exist (known ones are: command_bus).');
$container = $this->getContainerBuilder($commandBusId = 'command_bus');
$container->register(DummyCommandHandler::class)->addTag('messenger.message_handler', ['bus' => 'unknown_bus']);
@@ -208,12 +206,10 @@ class MessengerPassTest extends TestCase
$this->assertSame(PrioritizedHandler::class, $secondHandlerDefinition->getClass());
}
- /**
- * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
- * @expectedExceptionMessage Invalid service "NonExistentHandlerClass": class "NonExistentHandlerClass" does not exist.
- */
public function testThrowsExceptionIfTheHandlerClassDoesNotExist()
{
+ $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
+ $this->expectExceptionMessage('Invalid service "NonExistentHandlerClass": class "NonExistentHandlerClass" does not exist.');
$container = $this->getContainerBuilder();
$container->register('message_bus', MessageBusInterface::class)->addTag('messenger.bus');
$container
@@ -224,12 +220,10 @@ class MessengerPassTest extends TestCase
(new MessengerPass())->process($container);
}
- /**
- * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
- * @expectedExceptionMessage Invalid handler service "Symfony\Component\Messenger\Tests\DependencyInjection\HandlerMappingWithNonExistentMethod": method "Symfony\Component\Messenger\Tests\DependencyInjection\HandlerMappingWithNonExistentMethod::dummyMethod()" does not exist.
- */
public function testThrowsExceptionIfTheHandlerMethodDoesNotExist()
{
+ $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
+ $this->expectExceptionMessage('Invalid handler service "Symfony\Component\Messenger\Tests\DependencyInjection\HandlerMappingWithNonExistentMethod": method "Symfony\Component\Messenger\Tests\DependencyInjection\HandlerMappingWithNonExistentMethod::dummyMethod()" does not exist.');
$container = $this->getContainerBuilder();
$container->register('message_bus', MessageBusInterface::class)->addTag('messenger.bus');
$container
@@ -357,12 +351,10 @@ class MessengerPassTest extends TestCase
);
}
- /**
- * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
- * @expectedExceptionMessage Invalid configuration returned by method "Symfony\Component\Messenger\Tests\DependencyInjection\HandlerOnUndefinedBus::getHandledMessages()" for message "Symfony\Component\Messenger\Tests\Fixtures\DummyMessage": bus "some_undefined_bus" does not exist.
- */
public function testItThrowsAnExceptionOnUnknownBus()
{
+ $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
+ $this->expectExceptionMessage('Invalid configuration returned by method "Symfony\Component\Messenger\Tests\DependencyInjection\HandlerOnUndefinedBus::getHandledMessages()" for message "Symfony\Component\Messenger\Tests\Fixtures\DummyMessage": bus "some_undefined_bus" does not exist.');
$container = $this->getContainerBuilder();
$container
->register(HandlerOnUndefinedBus::class, HandlerOnUndefinedBus::class)
@@ -372,12 +364,10 @@ class MessengerPassTest extends TestCase
(new MessengerPass())->process($container);
}
- /**
- * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
- * @expectedExceptionMessage Invalid handler service "Symfony\Component\Messenger\Tests\DependencyInjection\UndefinedMessageHandler": class or interface "Symfony\Component\Messenger\Tests\DependencyInjection\UndefinedMessage" used as argument type in method "Symfony\Component\Messenger\Tests\DependencyInjection\UndefinedMessageHandler::__invoke()" not found.
- */
public function testUndefinedMessageClassForHandler()
{
+ $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
+ $this->expectExceptionMessage('Invalid handler service "Symfony\Component\Messenger\Tests\DependencyInjection\UndefinedMessageHandler": class or interface "Symfony\Component\Messenger\Tests\DependencyInjection\UndefinedMessage" used as argument type in method "Symfony\Component\Messenger\Tests\DependencyInjection\UndefinedMessageHandler::__invoke()" not found.');
$container = $this->getContainerBuilder();
$container
->register(UndefinedMessageHandler::class, UndefinedMessageHandler::class)
@@ -387,12 +377,10 @@ class MessengerPassTest extends TestCase
(new MessengerPass())->process($container);
}
- /**
- * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
- * @expectedExceptionMessage Invalid handler service "Symfony\Component\Messenger\Tests\DependencyInjection\UndefinedMessageHandlerViaHandlerInterface": class or interface "Symfony\Component\Messenger\Tests\DependencyInjection\UndefinedMessage" used as argument type in method "Symfony\Component\Messenger\Tests\DependencyInjection\UndefinedMessageHandlerViaHandlerInterface::__invoke()" not found.
- */
public function testUndefinedMessageClassForHandlerImplementingMessageHandlerInterface()
{
+ $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
+ $this->expectExceptionMessage('Invalid handler service "Symfony\Component\Messenger\Tests\DependencyInjection\UndefinedMessageHandlerViaHandlerInterface": class or interface "Symfony\Component\Messenger\Tests\DependencyInjection\UndefinedMessage" used as argument type in method "Symfony\Component\Messenger\Tests\DependencyInjection\UndefinedMessageHandlerViaHandlerInterface::__invoke()" not found.');
$container = $this->getContainerBuilder();
$container
->register(UndefinedMessageHandlerViaHandlerInterface::class, UndefinedMessageHandlerViaHandlerInterface::class)
@@ -402,12 +390,10 @@ class MessengerPassTest extends TestCase
(new MessengerPass())->process($container);
}
- /**
- * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
- * @expectedExceptionMessage Invalid handler service "Symfony\Component\Messenger\Tests\DependencyInjection\UndefinedMessageHandlerViaSubscriberInterface": class or interface "Symfony\Component\Messenger\Tests\DependencyInjection\UndefinedMessage" returned by method "Symfony\Component\Messenger\Tests\DependencyInjection\UndefinedMessageHandlerViaSubscriberInterface::getHandledMessages()" not found.
- */
public function testUndefinedMessageClassForHandlerImplementingMessageSubscriberInterface()
{
+ $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
+ $this->expectExceptionMessage('Invalid handler service "Symfony\Component\Messenger\Tests\DependencyInjection\UndefinedMessageHandlerViaSubscriberInterface": class or interface "Symfony\Component\Messenger\Tests\DependencyInjection\UndefinedMessage" returned by method "Symfony\Component\Messenger\Tests\DependencyInjection\UndefinedMessageHandlerViaSubscriberInterface::getHandledMessages()" not found.');
$container = $this->getContainerBuilder();
$container
->register(UndefinedMessageHandlerViaSubscriberInterface::class, UndefinedMessageHandlerViaSubscriberInterface::class)
@@ -417,12 +403,10 @@ class MessengerPassTest extends TestCase
(new MessengerPass())->process($container);
}
- /**
- * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
- * @expectedExceptionMessage Invalid handler service "Symfony\Component\Messenger\Tests\DependencyInjection\NotInvokableHandler": class "Symfony\Component\Messenger\Tests\DependencyInjection\NotInvokableHandler" must have an "__invoke()" method.
- */
public function testNotInvokableHandler()
{
+ $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
+ $this->expectExceptionMessage('Invalid handler service "Symfony\Component\Messenger\Tests\DependencyInjection\NotInvokableHandler": class "Symfony\Component\Messenger\Tests\DependencyInjection\NotInvokableHandler" must have an "__invoke()" method.');
$container = $this->getContainerBuilder();
$container
->register(NotInvokableHandler::class, NotInvokableHandler::class)
@@ -432,12 +416,10 @@ class MessengerPassTest extends TestCase
(new MessengerPass())->process($container);
}
- /**
- * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
- * @expectedExceptionMessage Invalid handler service "Symfony\Component\Messenger\Tests\DependencyInjection\MissingArgumentHandler": method "Symfony\Component\Messenger\Tests\DependencyInjection\MissingArgumentHandler::__invoke()" requires at least one argument, first one being the message it handles.
- */
public function testMissingArgumentHandler()
{
+ $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
+ $this->expectExceptionMessage('Invalid handler service "Symfony\Component\Messenger\Tests\DependencyInjection\MissingArgumentHandler": method "Symfony\Component\Messenger\Tests\DependencyInjection\MissingArgumentHandler::__invoke()" requires at least one argument, first one being the message it handles.');
$container = $this->getContainerBuilder();
$container
->register(MissingArgumentHandler::class, MissingArgumentHandler::class)
@@ -447,12 +429,10 @@ class MessengerPassTest extends TestCase
(new MessengerPass())->process($container);
}
- /**
- * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
- * @expectedExceptionMessage Invalid handler service "Symfony\Component\Messenger\Tests\DependencyInjection\MissingArgumentTypeHandler": argument "$message" of method "Symfony\Component\Messenger\Tests\DependencyInjection\MissingArgumentTypeHandler::__invoke()" must have a type-hint corresponding to the message class it handles.
- */
public function testMissingArgumentTypeHandler()
{
+ $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
+ $this->expectExceptionMessage('Invalid handler service "Symfony\Component\Messenger\Tests\DependencyInjection\MissingArgumentTypeHandler": argument "$message" of method "Symfony\Component\Messenger\Tests\DependencyInjection\MissingArgumentTypeHandler::__invoke()" must have a type-hint corresponding to the message class it handles.');
$container = $this->getContainerBuilder();
$container
->register(MissingArgumentTypeHandler::class, MissingArgumentTypeHandler::class)
@@ -462,12 +442,10 @@ class MessengerPassTest extends TestCase
(new MessengerPass())->process($container);
}
- /**
- * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
- * @expectedExceptionMessage Invalid handler service "Symfony\Component\Messenger\Tests\DependencyInjection\BuiltinArgumentTypeHandler": type-hint of argument "$message" in method "Symfony\Component\Messenger\Tests\DependencyInjection\BuiltinArgumentTypeHandler::__invoke()" must be a class , "string" given.
- */
public function testBuiltinArgumentTypeHandler()
{
+ $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
+ $this->expectExceptionMessage('Invalid handler service "Symfony\Component\Messenger\Tests\DependencyInjection\BuiltinArgumentTypeHandler": type-hint of argument "$message" in method "Symfony\Component\Messenger\Tests\DependencyInjection\BuiltinArgumentTypeHandler::__invoke()" must be a class , "string" given.');
$container = $this->getContainerBuilder();
$container
->register(BuiltinArgumentTypeHandler::class, BuiltinArgumentTypeHandler::class)
@@ -477,12 +455,10 @@ class MessengerPassTest extends TestCase
(new MessengerPass())->process($container);
}
- /**
- * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
- * @expectedExceptionMessage Invalid handler service "Symfony\Component\Messenger\Tests\DependencyInjection\HandleNoMessageHandler": method "Symfony\Component\Messenger\Tests\DependencyInjection\HandleNoMessageHandler::getHandledMessages()" must return one or more messages.
- */
public function testNeedsToHandleAtLeastOneMessage()
{
+ $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
+ $this->expectExceptionMessage('Invalid handler service "Symfony\Component\Messenger\Tests\DependencyInjection\HandleNoMessageHandler": method "Symfony\Component\Messenger\Tests\DependencyInjection\HandleNoMessageHandler::getHandledMessages()" must return one or more messages.');
$container = $this->getContainerBuilder();
$container
->register(HandleNoMessageHandler::class, HandleNoMessageHandler::class)
@@ -543,12 +519,10 @@ class MessengerPassTest extends TestCase
$this->assertFalse($container->hasParameter($middlewareParameter));
}
- /**
- * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
- * @expectedExceptionMessage Invalid middleware: service "not_defined_middleware" not found.
- */
public function testCannotRegistersAnUndefinedMiddleware()
{
+ $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
+ $this->expectExceptionMessage('Invalid middleware: service "not_defined_middleware" not found.');
$container = $this->getContainerBuilder($fooBusId = 'messenger.bus.foo');
$container->setParameter($middlewareParameter = $fooBusId.'.middleware', [
['id' => 'not_defined_middleware', 'arguments' => []],
@@ -557,12 +531,10 @@ class MessengerPassTest extends TestCase
(new MessengerPass())->process($container);
}
- /**
- * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
- * @expectedExceptionMessage Invalid middleware factory "not_an_abstract_definition": a middleware factory must be an abstract definition.
- */
public function testMiddlewareFactoryDefinitionMustBeAbstract()
{
+ $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
+ $this->expectExceptionMessage('Invalid middleware factory "not_an_abstract_definition": a middleware factory must be an abstract definition.');
$container = $this->getContainerBuilder($fooBusId = 'messenger.bus.foo');
$container->register('not_an_abstract_definition', UselessMiddleware::class);
$container->setParameter($middlewareParameter = $fooBusId.'.middleware', [
diff --git a/src/Symfony/Component/Messenger/Tests/HandleTraitTest.php b/src/Symfony/Component/Messenger/Tests/HandleTraitTest.php
index 09442f2a2c..10247cf761 100644
--- a/src/Symfony/Component/Messenger/Tests/HandleTraitTest.php
+++ b/src/Symfony/Component/Messenger/Tests/HandleTraitTest.php
@@ -12,12 +12,10 @@ use Symfony\Component\Messenger\Tests\Fixtures\DummyMessage;
class HandleTraitTest extends TestCase
{
- /**
- * @expectedException \Symfony\Component\Messenger\Exception\LogicException
- * @expectedExceptionMessage You must provide a "Symfony\Component\Messenger\MessageBusInterface" instance in the "Symfony\Component\Messenger\Tests\TestQueryBus::$messageBus" property, "NULL" given.
- */
public function testItThrowsOnNoMessageBusInstance()
{
+ $this->expectException('Symfony\Component\Messenger\Exception\LogicException');
+ $this->expectExceptionMessage('You must provide a "Symfony\Component\Messenger\MessageBusInterface" instance in the "Symfony\Component\Messenger\Tests\TestQueryBus::$messageBus" property, "NULL" given.');
$queryBus = new TestQueryBus(null);
$query = new DummyMessage('Hello');
@@ -48,12 +46,10 @@ class HandleTraitTest extends TestCase
$this->assertSame('result', $queryBus->query($envelope));
}
- /**
- * @expectedException \Symfony\Component\Messenger\Exception\LogicException
- * @expectedExceptionMessage Message of type "Symfony\Component\Messenger\Tests\Fixtures\DummyMessage" was handled zero times. Exactly one handler is expected when using "Symfony\Component\Messenger\Tests\TestQueryBus::handle()".
- */
public function testHandleThrowsOnNoHandledStamp()
{
+ $this->expectException('Symfony\Component\Messenger\Exception\LogicException');
+ $this->expectExceptionMessage('Message of type "Symfony\Component\Messenger\Tests\Fixtures\DummyMessage" was handled zero times. Exactly one handler is expected when using "Symfony\Component\Messenger\Tests\TestQueryBus::handle()".');
$bus = $this->createMock(MessageBus::class);
$queryBus = new TestQueryBus($bus);
@@ -63,12 +59,10 @@ class HandleTraitTest extends TestCase
$queryBus->query($query);
}
- /**
- * @expectedException \Symfony\Component\Messenger\Exception\LogicException
- * @expectedExceptionMessage Message of type "Symfony\Component\Messenger\Tests\Fixtures\DummyMessage" was handled multiple times. Only one handler is expected when using "Symfony\Component\Messenger\Tests\TestQueryBus::handle()", got 2: "FirstDummyHandler::__invoke", "SecondDummyHandler::__invoke".
- */
public function testHandleThrowsOnMultipleHandledStamps()
{
+ $this->expectException('Symfony\Component\Messenger\Exception\LogicException');
+ $this->expectExceptionMessage('Message of type "Symfony\Component\Messenger\Tests\Fixtures\DummyMessage" was handled multiple times. Only one handler is expected when using "Symfony\Component\Messenger\Tests\TestQueryBus::handle()", got 2: "FirstDummyHandler::__invoke", "SecondDummyHandler::__invoke".');
$bus = $this->createMock(MessageBus::class);
$queryBus = new TestQueryBus($bus);
diff --git a/src/Symfony/Component/Messenger/Tests/MessageBusTest.php b/src/Symfony/Component/Messenger/Tests/MessageBusTest.php
index c8644623b7..e47b57c104 100644
--- a/src/Symfony/Component/Messenger/Tests/MessageBusTest.php
+++ b/src/Symfony/Component/Messenger/Tests/MessageBusTest.php
@@ -32,12 +32,10 @@ class MessageBusTest extends TestCase
$this->assertInstanceOf(MessageBusInterface::class, $bus);
}
- /**
- * @expectedException \TypeError
- * @expectedExceptionMessage Invalid argument provided to "Symfony\Component\Messenger\MessageBus::dispatch()": expected object, but got string.
- */
public function testItDispatchInvalidMessageType()
{
+ $this->expectException('TypeError');
+ $this->expectExceptionMessage('Invalid argument provided to "Symfony\Component\Messenger\MessageBus::dispatch()": expected object, but got string.');
(new MessageBus())->dispatch('wrong');
}
diff --git a/src/Symfony/Component/Messenger/Tests/Middleware/HandleMessageMiddlewareTest.php b/src/Symfony/Component/Messenger/Tests/Middleware/HandleMessageMiddlewareTest.php
index 3bc263c74b..667f4f6961 100644
--- a/src/Symfony/Component/Messenger/Tests/Middleware/HandleMessageMiddlewareTest.php
+++ b/src/Symfony/Component/Messenger/Tests/Middleware/HandleMessageMiddlewareTest.php
@@ -113,12 +113,10 @@ class HandleMessageMiddlewareTest extends MiddlewareTestCase
];
}
- /**
- * @expectedException \Symfony\Component\Messenger\Exception\NoHandlerForMessageException
- * @expectedExceptionMessage No handler for message "Symfony\Component\Messenger\Tests\Fixtures\DummyMessage"
- */
public function testThrowsNoHandlerException()
{
+ $this->expectException('Symfony\Component\Messenger\Exception\NoHandlerForMessageException');
+ $this->expectExceptionMessage('No handler for message "Symfony\Component\Messenger\Tests\Fixtures\DummyMessage"');
$middleware = new HandleMessageMiddleware(new HandlersLocator([]));
$middleware->handle(new Envelope(new DummyMessage('Hey')), new StackMiddleware());
diff --git a/src/Symfony/Component/Messenger/Tests/Middleware/TraceableMiddlewareTest.php b/src/Symfony/Component/Messenger/Tests/Middleware/TraceableMiddlewareTest.php
index 9e1c1dcafb..54be577554 100644
--- a/src/Symfony/Component/Messenger/Tests/Middleware/TraceableMiddlewareTest.php
+++ b/src/Symfony/Component/Messenger/Tests/Middleware/TraceableMiddlewareTest.php
@@ -61,12 +61,10 @@ class TraceableMiddlewareTest extends MiddlewareTestCase
$traced->handle($envelope, new StackMiddleware(new \ArrayIterator([null, $middleware])));
}
- /**
- * @expectedException \RuntimeException
- * @expectedExceptionMessage Thrown from next middleware.
- */
public function testHandleWithException()
{
+ $this->expectException('RuntimeException');
+ $this->expectExceptionMessage('Thrown from next middleware.');
$busId = 'command_bus';
$middleware = $this->getMockBuilder(MiddlewareInterface::class)->getMock();
diff --git a/src/Symfony/Component/Messenger/Tests/Middleware/ValidationMiddlewareTest.php b/src/Symfony/Component/Messenger/Tests/Middleware/ValidationMiddlewareTest.php
index 510396f0a3..dc279118ec 100644
--- a/src/Symfony/Component/Messenger/Tests/Middleware/ValidationMiddlewareTest.php
+++ b/src/Symfony/Component/Messenger/Tests/Middleware/ValidationMiddlewareTest.php
@@ -52,12 +52,10 @@ class ValidationMiddlewareTest extends MiddlewareTestCase
(new ValidationMiddleware($validator))->handle($envelope, $this->getStackMock());
}
- /**
- * @expectedException \Symfony\Component\Messenger\Exception\ValidationFailedException
- * @expectedExceptionMessage Message of type "Symfony\Component\Messenger\Tests\Fixtures\DummyMessage" failed validation.
- */
public function testValidationFailedException()
{
+ $this->expectException('Symfony\Component\Messenger\Exception\ValidationFailedException');
+ $this->expectExceptionMessage('Message of type "Symfony\Component\Messenger\Tests\Fixtures\DummyMessage" failed validation.');
$message = new DummyMessage('Hey');
$envelope = new Envelope($message);
diff --git a/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/AmqpReceiverTest.php b/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/AmqpReceiverTest.php
index 617250f2aa..8e0b9da29a 100644
--- a/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/AmqpReceiverTest.php
+++ b/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/AmqpReceiverTest.php
@@ -45,11 +45,9 @@ class AmqpReceiverTest extends TestCase
$this->assertEquals(new DummyMessage('Hi'), $actualEnvelopes[0]->getMessage());
}
- /**
- * @expectedException \Symfony\Component\Messenger\Exception\TransportException
- */
public function testItThrowsATransportExceptionIfItCannotAcknowledgeMessage()
{
+ $this->expectException('Symfony\Component\Messenger\Exception\TransportException');
$serializer = $this->createMock(SerializerInterface::class);
$amqpEnvelope = $this->createAMQPEnvelope();
$connection = $this->getMockBuilder(Connection::class)->disableOriginalConstructor()->getMock();
@@ -61,11 +59,9 @@ class AmqpReceiverTest extends TestCase
$receiver->ack(new Envelope(new \stdClass(), [new AmqpReceivedStamp($amqpEnvelope, 'queueName')]));
}
- /**
- * @expectedException \Symfony\Component\Messenger\Exception\TransportException
- */
public function testItThrowsATransportExceptionIfItCannotRejectMessage()
{
+ $this->expectException('Symfony\Component\Messenger\Exception\TransportException');
$serializer = $this->createMock(SerializerInterface::class);
$amqpEnvelope = $this->createAMQPEnvelope();
$connection = $this->getMockBuilder(Connection::class)->disableOriginalConstructor()->getMock();
diff --git a/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/AmqpSenderTest.php b/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/AmqpSenderTest.php
index c13345f033..002e92b249 100644
--- a/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/AmqpSenderTest.php
+++ b/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/AmqpSenderTest.php
@@ -102,11 +102,9 @@ class AmqpSenderTest extends TestCase
$sender->send($envelope);
}
- /**
- * @expectedException \Symfony\Component\Messenger\Exception\TransportException
- */
public function testItThrowsATransportExceptionIfItCannotSendTheMessage()
{
+ $this->expectException('Symfony\Component\Messenger\Exception\TransportException');
$envelope = new Envelope(new DummyMessage('Oy'));
$encoded = ['body' => '...', 'headers' => ['type' => DummyMessage::class]];
diff --git a/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/ConnectionTest.php b/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/ConnectionTest.php
index f51070c1d9..5d8cd58c98 100644
--- a/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/ConnectionTest.php
+++ b/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/ConnectionTest.php
@@ -25,12 +25,10 @@ class ConnectionTest extends TestCase
{
private const DEFAULT_EXCHANGE_NAME = 'messages';
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage The given AMQP DSN "amqp://:" is invalid.
- */
public function testItCannotBeConstructedWithAWrongDsn()
{
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('The given AMQP DSN "amqp://:" is invalid.');
Connection::fromDsn('amqp://:');
}
@@ -421,12 +419,10 @@ class ConnectionTest extends TestCase
$connection->publish('{}', [], 120000);
}
- /**
- * @expectedException \AMQPException
- * @expectedExceptionMessage Could not connect to the AMQP server. Please verify the provided DSN. ({"host":"localhost","port":5672,"vhost":"\/","login":"user","password":"********"})
- */
public function testObfuscatePasswordInDsn()
{
+ $this->expectException('AMQPException');
+ $this->expectExceptionMessage('Could not connect to the AMQP server. Please verify the provided DSN. ({"host":"localhost","port":5672,"vhost":"\/","login":"user","password":"********"})');
$factory = new TestAmqpFactory(
$amqpConnection = $this->createMock(\AMQPConnection::class),
$amqpChannel = $this->createMock(\AMQPChannel::class),
diff --git a/src/Symfony/Component/Messenger/Tests/Transport/Doctrine/ConnectionTest.php b/src/Symfony/Component/Messenger/Tests/Transport/Doctrine/ConnectionTest.php
index 28e54a9b36..6e7724d506 100644
--- a/src/Symfony/Component/Messenger/Tests/Transport/Doctrine/ConnectionTest.php
+++ b/src/Symfony/Component/Messenger/Tests/Transport/Doctrine/ConnectionTest.php
@@ -78,11 +78,9 @@ class ConnectionTest extends TestCase
$this->assertNull($doctrineEnvelope);
}
- /**
- * @expectedException \Symfony\Component\Messenger\Exception\TransportException
- */
public function testItThrowsATransportExceptionIfItCannotAcknowledgeMessage()
{
+ $this->expectException('Symfony\Component\Messenger\Exception\TransportException');
$driverConnection = $this->getDBALConnectionMock();
$driverConnection->method('delete')->willThrowException(new DBALException());
@@ -90,11 +88,9 @@ class ConnectionTest extends TestCase
$connection->ack('dummy_id');
}
- /**
- * @expectedException \Symfony\Component\Messenger\Exception\TransportException
- */
public function testItThrowsATransportExceptionIfItCannotRejectMessage()
{
+ $this->expectException('Symfony\Component\Messenger\Exception\TransportException');
$driverConnection = $this->getDBALConnectionMock();
$driverConnection->method('delete')->willThrowException(new DBALException());
@@ -240,19 +236,15 @@ class ConnectionTest extends TestCase
];
}
- /**
- * @expectedException \Symfony\Component\Messenger\Exception\InvalidArgumentException
- */
public function testItThrowsAnExceptionIfAnExtraOptionsInDefined()
{
+ $this->expectException('Symfony\Component\Messenger\Exception\InvalidArgumentException');
Connection::buildConfiguration('doctrine://default', ['new_option' => 'woops']);
}
- /**
- * @expectedException \Symfony\Component\Messenger\Exception\InvalidArgumentException
- */
public function testItThrowsAnExceptionIfAnExtraOptionsInDefinedInDSN()
{
+ $this->expectException('Symfony\Component\Messenger\Exception\InvalidArgumentException');
Connection::buildConfiguration('doctrine://default?new_option=woops');
}
diff --git a/src/Symfony/Component/Messenger/Tests/Transport/Doctrine/DoctrineReceiverTest.php b/src/Symfony/Component/Messenger/Tests/Transport/Doctrine/DoctrineReceiverTest.php
index c4f73c94ca..c284c2536b 100644
--- a/src/Symfony/Component/Messenger/Tests/Transport/Doctrine/DoctrineReceiverTest.php
+++ b/src/Symfony/Component/Messenger/Tests/Transport/Doctrine/DoctrineReceiverTest.php
@@ -53,11 +53,9 @@ class DoctrineReceiverTest extends TestCase
$this->assertSame(1, $transportMessageIdStamp->getId());
}
- /**
- * @expectedException \Symfony\Component\Messenger\Exception\MessageDecodingFailedException
- */
public function testItRejectTheMessageIfThereIsAMessageDecodingFailedException()
{
+ $this->expectException('Symfony\Component\Messenger\Exception\MessageDecodingFailedException');
$serializer = $this->createMock(PhpSerializer::class);
$serializer->method('decode')->willThrowException(new MessageDecodingFailedException());
diff --git a/src/Symfony/Component/Messenger/Tests/Transport/Doctrine/DoctrineTransportFactoryTest.php b/src/Symfony/Component/Messenger/Tests/Transport/Doctrine/DoctrineTransportFactoryTest.php
index 9c59a2a88a..20559c5352 100644
--- a/src/Symfony/Component/Messenger/Tests/Transport/Doctrine/DoctrineTransportFactoryTest.php
+++ b/src/Symfony/Component/Messenger/Tests/Transport/Doctrine/DoctrineTransportFactoryTest.php
@@ -54,12 +54,10 @@ class DoctrineTransportFactoryTest extends TestCase
);
}
- /**
- * @expectedException \Symfony\Component\Messenger\Exception\TransportException
- * @expectedExceptionMessage Could not find Doctrine connection from Messenger DSN "doctrine://default".
- */
public function testCreateTransportMustThrowAnExceptionIfManagerIsNotFound()
{
+ $this->expectException('Symfony\Component\Messenger\Exception\TransportException');
+ $this->expectExceptionMessage('Could not find Doctrine connection from Messenger DSN "doctrine://default".');
$registry = $this->createMock(ConnectionRegistry::class);
$registry->expects($this->once())
->method('getConnection')
diff --git a/src/Symfony/Component/Mime/Tests/Header/IdentificationHeaderTest.php b/src/Symfony/Component/Mime/Tests/Header/IdentificationHeaderTest.php
index 7d94d4d19d..b7f0095d3a 100644
--- a/src/Symfony/Component/Mime/Tests/Header/IdentificationHeaderTest.php
+++ b/src/Symfony/Component/Mime/Tests/Header/IdentificationHeaderTest.php
@@ -99,12 +99,10 @@ class IdentificationHeaderTest extends TestCase
$this->assertEquals('', $header->getBodyAsString());
}
- /**
- * @expectedException \Exception
- * @expectedMessageException "a b c" is not valid id-left
- */
public function testInvalidIdLeftThrowsException()
{
+ $this->expectException('Exception');
+ $this->expectExceptionMessage('Email "a b c@d" does not comply with addr-spec of RFC 2822.');
$header = new IdentificationHeader('References', 'a b c@d');
}
@@ -137,21 +135,17 @@ class IdentificationHeaderTest extends TestCase
$this->assertEquals('', $header->getBodyAsString());
}
- /**
- * @expectedException \Exception
- * @expectedMessageException "b c d" is not valid id-right
- */
public function testInvalidIdRightThrowsException()
{
+ $this->expectException('Exception');
+ $this->expectExceptionMessage('Email "a@b c d" does not comply with addr-spec of RFC 2822.');
$header = new IdentificationHeader('References', 'a@b c d');
}
- /**
- * @expectedException \Exception
- * @expectedMessageException "abc" is does not contain @
- */
public function testMissingAtSignThrowsException()
{
+ $this->expectException('Exception');
+ $this->expectExceptionMessage('Email "abc" does not comply with addr-spec of RFC 2822.');
/* -- RFC 2822, 3.6.4.
msg-id = [CFWS] "<" id-left "@" id-right ">" [CFWS]
*/
diff --git a/src/Symfony/Component/Mime/Tests/Header/MailboxHeaderTest.php b/src/Symfony/Component/Mime/Tests/Header/MailboxHeaderTest.php
index 11a7ac9c54..72f22ff980 100644
--- a/src/Symfony/Component/Mime/Tests/Header/MailboxHeaderTest.php
+++ b/src/Symfony/Component/Mime/Tests/Header/MailboxHeaderTest.php
@@ -59,11 +59,9 @@ class MailboxHeaderTest extends TestCase
$this->assertEquals('Fabien =?'.$header->getCharset().'?Q?P=8Ftencier?= ', $header->getBodyAsString());
}
- /**
- * @expectedException \Symfony\Component\Mime\Exception\AddressEncoderException
- */
public function testUtf8CharsInLocalPartThrows()
{
+ $this->expectException('Symfony\Component\Mime\Exception\AddressEncoderException');
$header = new MailboxHeader('Sender', new Address('fabïen@symfony.com'));
$header->getBodyAsString();
}
diff --git a/src/Symfony/Component/Mime/Tests/Header/MailboxListHeaderTest.php b/src/Symfony/Component/Mime/Tests/Header/MailboxListHeaderTest.php
index a2a28050f1..2eee1cfa86 100644
--- a/src/Symfony/Component/Mime/Tests/Header/MailboxListHeaderTest.php
+++ b/src/Symfony/Component/Mime/Tests/Header/MailboxListHeaderTest.php
@@ -56,11 +56,9 @@ class MailboxListHeaderTest extends TestCase
$this->assertEquals(['Chris Corbyn '], $header->getAddressStrings());
}
- /**
- * @expectedException \Symfony\Component\Mime\Exception\AddressEncoderException
- */
public function testUtf8CharsInLocalPartThrows()
{
+ $this->expectException('Symfony\Component\Mime\Exception\AddressEncoderException');
$header = new MailboxListHeader('From', [new NamedAddress('chrïs@swiftmailer.org', 'Chris Corbyn')]);
$header->getAddressStrings();
}
diff --git a/src/Symfony/Component/Mime/Tests/Header/PathHeaderTest.php b/src/Symfony/Component/Mime/Tests/Header/PathHeaderTest.php
index 8f41959944..6bc029aee4 100644
--- a/src/Symfony/Component/Mime/Tests/Header/PathHeaderTest.php
+++ b/src/Symfony/Component/Mime/Tests/Header/PathHeaderTest.php
@@ -23,11 +23,9 @@ class PathHeaderTest extends TestCase
$this->assertEquals($address, $header->getAddress());
}
- /**
- * @expectedException \Exception
- */
public function testAddressMustComplyWithRfc2822()
{
+ $this->expectException('Exception');
$header = new PathHeader('Return-Path', new Address('chr is@swiftmailer.org'));
}
@@ -51,11 +49,9 @@ class PathHeaderTest extends TestCase
$this->assertEquals('', $header->getBodyAsString());
}
- /**
- * @expectedException \Symfony\Component\Mime\Exception\AddressEncoderException
- */
public function testAddressMustBeEncodable()
{
+ $this->expectException('Symfony\Component\Mime\Exception\AddressEncoderException');
$header = new PathHeader('Return-Path', new Address('chrïs@swiftmailer.org'));
$header->getBodyAsString();
}
diff --git a/src/Symfony/Component/OptionsResolver/Tests/Debug/OptionsResolverIntrospectorTest.php b/src/Symfony/Component/OptionsResolver/Tests/Debug/OptionsResolverIntrospectorTest.php
index 64a1ead1fe..fa80614d75 100644
--- a/src/Symfony/Component/OptionsResolver/Tests/Debug/OptionsResolverIntrospectorTest.php
+++ b/src/Symfony/Component/OptionsResolver/Tests/Debug/OptionsResolverIntrospectorTest.php
@@ -12,12 +12,15 @@
namespace Symfony\Component\OptionsResolver\Tests\Debug;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\OptionsResolver\Debug\OptionsResolverIntrospector;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;
class OptionsResolverIntrospectorTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testGetDefault()
{
$resolver = new OptionsResolver();
@@ -36,12 +39,10 @@ class OptionsResolverIntrospectorTest extends TestCase
$this->assertNull($debug->getDefault($option));
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\NoConfigurationException
- * @expectedExceptionMessage No default value was set for the "foo" option.
- */
public function testGetDefaultThrowsOnNoConfiguredValue()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\NoConfigurationException');
+ $this->expectExceptionMessage('No default value was set for the "foo" option.');
$resolver = new OptionsResolver();
$resolver->setDefined($option = 'foo');
@@ -49,12 +50,10 @@ class OptionsResolverIntrospectorTest extends TestCase
$this->assertSame('bar', $debug->getDefault($option));
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException
- * @expectedExceptionMessage The option "foo" does not exist.
- */
public function testGetDefaultThrowsOnNotDefinedOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException');
+ $this->expectExceptionMessage('The option "foo" does not exist.');
$resolver = new OptionsResolver();
$debug = new OptionsResolverIntrospector($resolver);
@@ -71,12 +70,10 @@ class OptionsResolverIntrospectorTest extends TestCase
$this->assertSame($closures, $debug->getLazyClosures($option));
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\NoConfigurationException
- * @expectedExceptionMessage No lazy closures were set for the "foo" option.
- */
public function testGetLazyClosuresThrowsOnNoConfiguredValue()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\NoConfigurationException');
+ $this->expectExceptionMessage('No lazy closures were set for the "foo" option.');
$resolver = new OptionsResolver();
$resolver->setDefined($option = 'foo');
@@ -84,12 +81,10 @@ class OptionsResolverIntrospectorTest extends TestCase
$this->assertSame('bar', $debug->getLazyClosures($option));
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException
- * @expectedExceptionMessage The option "foo" does not exist.
- */
public function testGetLazyClosuresThrowsOnNotDefinedOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException');
+ $this->expectExceptionMessage('The option "foo" does not exist.');
$resolver = new OptionsResolver();
$debug = new OptionsResolverIntrospector($resolver);
@@ -106,12 +101,10 @@ class OptionsResolverIntrospectorTest extends TestCase
$this->assertSame($allowedTypes, $debug->getAllowedTypes($option));
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\NoConfigurationException
- * @expectedExceptionMessage No allowed types were set for the "foo" option.
- */
public function testGetAllowedTypesThrowsOnNoConfiguredValue()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\NoConfigurationException');
+ $this->expectExceptionMessage('No allowed types were set for the "foo" option.');
$resolver = new OptionsResolver();
$resolver->setDefined($option = 'foo');
@@ -119,12 +112,10 @@ class OptionsResolverIntrospectorTest extends TestCase
$this->assertSame('bar', $debug->getAllowedTypes($option));
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException
- * @expectedExceptionMessage The option "foo" does not exist.
- */
public function testGetAllowedTypesThrowsOnNotDefinedOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException');
+ $this->expectExceptionMessage('The option "foo" does not exist.');
$resolver = new OptionsResolver();
$debug = new OptionsResolverIntrospector($resolver);
@@ -141,12 +132,10 @@ class OptionsResolverIntrospectorTest extends TestCase
$this->assertSame($allowedValues, $debug->getAllowedValues($option));
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\NoConfigurationException
- * @expectedExceptionMessage No allowed values were set for the "foo" option.
- */
public function testGetAllowedValuesThrowsOnNoConfiguredValue()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\NoConfigurationException');
+ $this->expectExceptionMessage('No allowed values were set for the "foo" option.');
$resolver = new OptionsResolver();
$resolver->setDefined($option = 'foo');
@@ -154,12 +143,10 @@ class OptionsResolverIntrospectorTest extends TestCase
$this->assertSame('bar', $debug->getAllowedValues($option));
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException
- * @expectedExceptionMessage The option "foo" does not exist.
- */
public function testGetAllowedValuesThrowsOnNotDefinedOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException');
+ $this->expectExceptionMessage('The option "foo" does not exist.');
$resolver = new OptionsResolver();
$debug = new OptionsResolverIntrospector($resolver);
@@ -176,12 +163,10 @@ class OptionsResolverIntrospectorTest extends TestCase
$this->assertSame($normalizer, $debug->getNormalizer($option));
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\NoConfigurationException
- * @expectedExceptionMessage No normalizer was set for the "foo" option.
- */
public function testGetNormalizerThrowsOnNoConfiguredValue()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\NoConfigurationException');
+ $this->expectExceptionMessage('No normalizer was set for the "foo" option.');
$resolver = new OptionsResolver();
$resolver->setDefined($option = 'foo');
@@ -189,12 +174,10 @@ class OptionsResolverIntrospectorTest extends TestCase
$this->assertSame('bar', $debug->getNormalizer($option));
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException
- * @expectedExceptionMessage The option "foo" does not exist.
- */
public function testGetNormalizerThrowsOnNotDefinedOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException');
+ $this->expectExceptionMessage('The option "foo" does not exist.');
$resolver = new OptionsResolver();
$debug = new OptionsResolverIntrospector($resolver);
@@ -212,12 +195,10 @@ class OptionsResolverIntrospectorTest extends TestCase
$this->assertSame([$normalizer1, $normalizer2], $debug->getNormalizers('foo'));
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\NoConfigurationException
- * @expectedExceptionMessage No normalizer was set for the "foo" option.
- */
public function testGetNormalizersThrowsOnNoConfiguredValue()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\NoConfigurationException');
+ $this->expectExceptionMessage('No normalizer was set for the "foo" option.');
$resolver = new OptionsResolver();
$resolver->setDefined('foo');
@@ -225,12 +206,10 @@ class OptionsResolverIntrospectorTest extends TestCase
$debug->getNormalizers('foo');
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException
- * @expectedExceptionMessage The option "foo" does not exist.
- */
public function testGetNormalizersThrowsOnNotDefinedOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException');
+ $this->expectExceptionMessage('The option "foo" does not exist.');
$resolver = new OptionsResolver();
$debug = new OptionsResolverIntrospector($resolver);
@@ -257,12 +236,10 @@ class OptionsResolverIntrospectorTest extends TestCase
$this->assertSame($closure, $debug->getDeprecationMessage('foo'));
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\NoConfigurationException
- * @expectedExceptionMessage No deprecation was set for the "foo" option.
- */
public function testGetDeprecationMessageThrowsOnNoConfiguredValue()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\NoConfigurationException');
+ $this->expectExceptionMessage('No deprecation was set for the "foo" option.');
$resolver = new OptionsResolver();
$resolver->setDefined('foo');
@@ -270,12 +247,10 @@ class OptionsResolverIntrospectorTest extends TestCase
$this->assertSame('bar', $debug->getDeprecationMessage('foo'));
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException
- * @expectedExceptionMessage The option "foo" does not exist.
- */
public function testGetDeprecationMessageThrowsOnNotDefinedOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException');
+ $this->expectExceptionMessage('The option "foo" does not exist.');
$resolver = new OptionsResolver();
$debug = new OptionsResolverIntrospector($resolver);
diff --git a/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php b/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php
index 239bb170e4..51f86ab97c 100644
--- a/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php
+++ b/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php
@@ -32,35 +32,29 @@ class OptionsResolverTest extends TestCase
$this->resolver = new OptionsResolver();
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException
- * @expectedExceptionMessage The option "foo" does not exist. Defined options are: "a", "z".
- */
public function testResolveFailsIfNonExistingOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException');
+ $this->expectExceptionMessage('The option "foo" does not exist. Defined options are: "a", "z".');
$this->resolver->setDefault('z', '1');
$this->resolver->setDefault('a', '2');
$this->resolver->resolve(['foo' => 'bar']);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException
- * @expectedExceptionMessage The options "baz", "foo", "ping" do not exist. Defined options are: "a", "z".
- */
public function testResolveFailsIfMultipleNonExistingOptions()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException');
+ $this->expectExceptionMessage('The options "baz", "foo", "ping" do not exist. Defined options are: "a", "z".');
$this->resolver->setDefault('z', '1');
$this->resolver->setDefault('a', '2');
$this->resolver->resolve(['ping' => 'pong', 'foo' => 'bar', 'baz' => 'bam']);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException
- */
public function testResolveFailsFromLazyOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
$this->resolver->setDefault('foo', function (Options $options) {
$options->resolve([]);
});
@@ -84,11 +78,9 @@ class OptionsResolverTest extends TestCase
], $this->resolver->resolve());
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException
- */
public function testFailIfSetDefaultFromLazyOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
$this->resolver->setDefault('lazy', function (Options $options) {
$options->setDefault('default', 42);
});
@@ -228,11 +220,9 @@ class OptionsResolverTest extends TestCase
$this->assertSame($this->resolver, $this->resolver->setRequired('foo'));
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException
- */
public function testFailIfSetRequiredFromLazyOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
$this->resolver->setDefault('foo', function (Options $options) {
$options->setRequired('bar');
});
@@ -240,11 +230,9 @@ class OptionsResolverTest extends TestCase
$this->resolver->resolve();
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\MissingOptionsException
- */
public function testResolveFailsIfRequiredOptionMissing()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\MissingOptionsException');
$this->resolver->setRequired('foo');
$this->resolver->resolve();
@@ -356,11 +344,9 @@ class OptionsResolverTest extends TestCase
$this->assertSame(['bar'], $this->resolver->getMissingOptions());
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException
- */
public function testFailIfSetDefinedFromLazyOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
$this->resolver->setDefault('foo', function (Options $options) {
$options->setDefined('bar');
});
@@ -453,11 +439,9 @@ class OptionsResolverTest extends TestCase
$this->assertFalse($this->resolver->isDefined('foo'));
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException
- */
public function testFailIfSetDeprecatedFromLazyOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
$this->resolver
->setDefault('bar', 'baz')
->setDefault('foo', function (Options $options) {
@@ -467,32 +451,26 @@ class OptionsResolverTest extends TestCase
;
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException
- */
public function testSetDeprecatedFailsIfUnknownOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException');
$this->resolver->setDeprecated('foo');
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidArgumentException
- * @expectedExceptionMessage Invalid type for deprecation message argument, expected string or \Closure, but got "boolean".
- */
public function testSetDeprecatedFailsIfInvalidDeprecationMessageType()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Invalid type for deprecation message argument, expected string or \Closure, but got "boolean".');
$this->resolver
->setDefined('foo')
->setDeprecated('foo', true)
;
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidArgumentException
- * @expectedExceptionMessage Invalid type for deprecation message, expected string but got "boolean", return an empty string to ignore.
- */
public function testLazyDeprecationFailsIfInvalidDeprecationMessageType()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Invalid type for deprecation message, expected string but got "boolean", return an empty string to ignore.');
$this->resolver
->setDefined('foo')
->setDeprecated('foo', function (Options $options, $value) {
@@ -502,12 +480,10 @@ class OptionsResolverTest extends TestCase
$this->resolver->resolve(['foo' => null]);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\OptionDefinitionException
- * @expectedExceptionMessage The options "foo", "bar" have a cyclic dependency.
- */
public function testFailsIfCyclicDependencyBetweenDeprecation()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\OptionDefinitionException');
+ $this->expectExceptionMessage('The options "foo", "bar" have a cyclic dependency.');
$this->resolver
->setDefined(['foo', 'bar'])
->setDeprecated('foo', function (Options $options, $value) {
@@ -773,11 +749,9 @@ class OptionsResolverTest extends TestCase
];
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException
- */
public function testSetAllowedTypesFailsIfUnknownOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException');
$this->resolver->setAllowedTypes('foo', 'string');
}
@@ -790,11 +764,9 @@ class OptionsResolverTest extends TestCase
$this->assertSame(['foo' => ['bar', 'baz']], $options);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException
- */
public function testFailIfSetAllowedTypesFromLazyOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
$this->resolver->setDefault('foo', function (Options $options) {
$options->setAllowedTypes('bar', 'string');
});
@@ -804,36 +776,30 @@ class OptionsResolverTest extends TestCase
$this->resolver->resolve();
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- * @expectedExceptionMessage The option "foo" with value array is expected to be of type "int[]", but one of the elements is of type "DateTime[]".
- */
public function testResolveFailsIfInvalidTypedArray()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
+ $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "int[]", but one of the elements is of type "DateTime[]".');
$this->resolver->setDefined('foo');
$this->resolver->setAllowedTypes('foo', 'int[]');
$this->resolver->resolve(['foo' => [new \DateTime()]]);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- * @expectedExceptionMessage The option "foo" with value "bar" is expected to be of type "int[]", but is of type "string".
- */
public function testResolveFailsWithNonArray()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
+ $this->expectExceptionMessage('The option "foo" with value "bar" is expected to be of type "int[]", but is of type "string".');
$this->resolver->setDefined('foo');
$this->resolver->setAllowedTypes('foo', 'int[]');
$this->resolver->resolve(['foo' => 'bar']);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- * @expectedExceptionMessage The option "foo" with value array is expected to be of type "int[]", but one of the elements is of type "stdClass[]".
- */
public function testResolveFailsIfTypedArrayContainsInvalidTypes()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
+ $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "int[]", but one of the elements is of type "stdClass[]".');
$this->resolver->setDefined('foo');
$this->resolver->setAllowedTypes('foo', 'int[]');
$values = range(1, 5);
@@ -845,12 +811,10 @@ class OptionsResolverTest extends TestCase
$this->resolver->resolve(['foo' => $values]);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- * @expectedExceptionMessage The option "foo" with value array is expected to be of type "int[][]", but one of the elements is of type "double[][]".
- */
public function testResolveFailsWithCorrectLevelsButWrongScalar()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
+ $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "int[][]", but one of the elements is of type "double[][]".');
$this->resolver->setDefined('foo');
$this->resolver->setAllowedTypes('foo', 'int[][]');
@@ -897,12 +861,10 @@ class OptionsResolverTest extends TestCase
$this->assertNotEmpty($this->resolver->resolve());
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- * @expectedExceptionMessage The option "foo" with value 42 is expected to be of type "string" or "bool", but is of type "integer".
- */
public function testResolveFailsIfInvalidTypeMultiple()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
+ $this->expectExceptionMessage('The option "foo" with value 42 is expected to be of type "string" or "bool", but is of type "integer".');
$this->resolver->setDefault('foo', 42);
$this->resolver->setAllowedTypes('foo', ['string', 'bool']);
@@ -940,30 +902,24 @@ class OptionsResolverTest extends TestCase
$this->assertEquals($data, $result);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- */
public function testResolveFailsIfNotInstanceOfClass()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
$this->resolver->setDefault('foo', 'bar');
$this->resolver->setAllowedTypes('foo', '\stdClass');
$this->resolver->resolve();
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException
- */
public function testAddAllowedTypesFailsIfUnknownOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException');
$this->resolver->addAllowedTypes('foo', 'string');
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException
- */
public function testFailIfAddAllowedTypesFromLazyOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
$this->resolver->setDefault('foo', function (Options $options) {
$options->addAllowedTypes('bar', 'string');
});
@@ -973,11 +929,9 @@ class OptionsResolverTest extends TestCase
$this->resolver->resolve();
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- */
public function testResolveFailsIfInvalidAddedType()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
$this->resolver->setDefault('foo', 42);
$this->resolver->addAllowedTypes('foo', 'string');
@@ -992,11 +946,9 @@ class OptionsResolverTest extends TestCase
$this->assertNotEmpty($this->resolver->resolve());
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- */
public function testResolveFailsIfInvalidAddedTypeMultiple()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
$this->resolver->setDefault('foo', 42);
$this->resolver->addAllowedTypes('foo', ['string', 'bool']);
@@ -1033,19 +985,15 @@ class OptionsResolverTest extends TestCase
$this->assertNotEmpty($this->resolver->resolve());
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException
- */
public function testSetAllowedValuesFailsIfUnknownOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException');
$this->resolver->setAllowedValues('foo', 'bar');
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException
- */
public function testFailIfSetAllowedValuesFromLazyOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
$this->resolver->setDefault('foo', function (Options $options) {
$options->setAllowedValues('bar', 'baz');
});
@@ -1055,35 +1003,29 @@ class OptionsResolverTest extends TestCase
$this->resolver->resolve();
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- * @expectedExceptionMessage The option "foo" with value 42 is invalid. Accepted values are: "bar".
- */
public function testResolveFailsIfInvalidValue()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
+ $this->expectExceptionMessage('The option "foo" with value 42 is invalid. Accepted values are: "bar".');
$this->resolver->setDefined('foo');
$this->resolver->setAllowedValues('foo', 'bar');
$this->resolver->resolve(['foo' => 42]);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- * @expectedExceptionMessage The option "foo" with value null is invalid. Accepted values are: "bar".
- */
public function testResolveFailsIfInvalidValueIsNull()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
+ $this->expectExceptionMessage('The option "foo" with value null is invalid. Accepted values are: "bar".');
$this->resolver->setDefault('foo', null);
$this->resolver->setAllowedValues('foo', 'bar');
$this->resolver->resolve();
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- */
public function testResolveFailsIfInvalidValueStrict()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
$this->resolver->setDefault('foo', 42);
$this->resolver->setAllowedValues('foo', '42');
@@ -1106,12 +1048,10 @@ class OptionsResolverTest extends TestCase
$this->assertEquals(['foo' => null], $this->resolver->resolve());
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- * @expectedExceptionMessage The option "foo" with value 42 is invalid. Accepted values are: "bar", false, null.
- */
public function testResolveFailsIfInvalidValueMultiple()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
+ $this->expectExceptionMessage('The option "foo" with value 42 is invalid. Accepted values are: "bar", false, null.');
$this->resolver->setDefault('foo', 42);
$this->resolver->setAllowedValues('foo', ['bar', false, null]);
@@ -1157,11 +1097,9 @@ class OptionsResolverTest extends TestCase
$this->assertSame('bar', $passedValue);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- */
public function testResolveFailsIfAllClosuresReturnFalse()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
$this->resolver->setDefault('foo', 42);
$this->resolver->setAllowedValues('foo', [
function () { return false; },
@@ -1184,19 +1122,15 @@ class OptionsResolverTest extends TestCase
$this->assertEquals(['foo' => 'bar'], $this->resolver->resolve());
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException
- */
public function testAddAllowedValuesFailsIfUnknownOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException');
$this->resolver->addAllowedValues('foo', 'bar');
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException
- */
public function testFailIfAddAllowedValuesFromLazyOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
$this->resolver->setDefault('foo', function (Options $options) {
$options->addAllowedValues('bar', 'baz');
});
@@ -1206,11 +1140,9 @@ class OptionsResolverTest extends TestCase
$this->resolver->resolve();
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- */
public function testResolveFailsIfInvalidAddedValue()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
$this->resolver->setDefault('foo', 42);
$this->resolver->addAllowedValues('foo', 'bar');
@@ -1233,11 +1165,9 @@ class OptionsResolverTest extends TestCase
$this->assertEquals(['foo' => null], $this->resolver->resolve());
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- */
public function testResolveFailsIfInvalidAddedValueMultiple()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
$this->resolver->setDefault('foo', 42);
$this->resolver->addAllowedValues('foo', ['bar', 'baz']);
@@ -1270,11 +1200,9 @@ class OptionsResolverTest extends TestCase
$this->assertEquals(['foo' => 'baz'], $this->resolver->resolve());
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- */
public function testResolveFailsIfAllAddedClosuresReturnFalse()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
$this->resolver->setDefault('foo', 42);
$this->resolver->setAllowedValues('foo', function () { return false; });
$this->resolver->addAllowedValues('foo', function () { return false; });
@@ -1316,19 +1244,15 @@ class OptionsResolverTest extends TestCase
$this->assertEquals(['foo' => 'normalized'], $this->resolver->resolve());
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException
- */
public function testSetNormalizerFailsIfUnknownOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException');
$this->resolver->setNormalizer('foo', function () {});
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException
- */
public function testFailIfSetNormalizerFromLazyOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
$this->resolver->setDefault('foo', function (Options $options) {
$options->setNormalizer('foo', function () {});
});
@@ -1362,11 +1286,9 @@ class OptionsResolverTest extends TestCase
$this->assertEquals(['foo' => 'normalized[baz]'], $resolved);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- */
public function testValidateTypeBeforeNormalization()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
$this->resolver->setDefault('foo', 'bar');
$this->resolver->setAllowedTypes('foo', 'int');
@@ -1378,11 +1300,9 @@ class OptionsResolverTest extends TestCase
$this->resolver->resolve();
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- */
public function testValidateValueBeforeNormalization()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
$this->resolver->setDefault('foo', 'bar');
$this->resolver->setAllowedValues('foo', 'baz');
@@ -1432,11 +1352,9 @@ class OptionsResolverTest extends TestCase
], $this->resolver->resolve());
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\OptionDefinitionException
- */
public function testFailIfCyclicDependencyBetweenNormalizers()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\OptionDefinitionException');
$this->resolver->setDefault('norm1', 'bar');
$this->resolver->setDefault('norm2', 'baz');
@@ -1451,11 +1369,9 @@ class OptionsResolverTest extends TestCase
$this->resolver->resolve();
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\OptionDefinitionException
- */
public function testFailIfCyclicDependencyBetweenNormalizerAndLazyOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\OptionDefinitionException');
$this->resolver->setDefault('lazy', function (Options $options) {
$options['norm'];
});
@@ -1588,19 +1504,15 @@ class OptionsResolverTest extends TestCase
$this->assertEquals(['foo' => '2nd-normalized-1st-normalized-bar'], $this->resolver->resolve());
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException
- */
public function testAddNormalizerFailsIfUnknownOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException');
$this->resolver->addNormalizer('foo', function () {});
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException
- */
public function testFailIfAddNormalizerFromLazyOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
$this->resolver->setDefault('foo', function (Options $options) {
$options->addNormalizer('foo', function () {});
});
@@ -1630,11 +1542,9 @@ class OptionsResolverTest extends TestCase
], $this->resolver->resolve());
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException
- */
public function testFailIfSetDefaultsFromLazyOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
$this->resolver->setDefault('foo', function (Options $options) {
$options->setDefaults(['two' => '2']);
});
@@ -1711,11 +1621,9 @@ class OptionsResolverTest extends TestCase
$this->assertSame(['foo' => 'bar'], $this->resolver->resolve());
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException
- */
public function testFailIfRemoveFromLazyOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
$this->resolver->setDefault('foo', function (Options $options) {
$options->remove('bar');
});
@@ -1787,11 +1695,9 @@ class OptionsResolverTest extends TestCase
$this->assertSame(['foo' => 'bar'], $this->resolver->resolve());
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException
- */
public function testFailIfClearFromLazyption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
$this->resolver->setDefault('foo', function (Options $options) {
$options->clear();
});
@@ -1846,50 +1752,40 @@ class OptionsResolverTest extends TestCase
$this->resolver->resolve(['default2' => 42, 'required' => 'value']);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException
- */
public function testArrayAccessGetFailsOutsideResolve()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
$this->resolver->setDefault('default', 0);
$this->resolver['default'];
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException
- */
public function testArrayAccessExistsFailsOutsideResolve()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
$this->resolver->setDefault('default', 0);
isset($this->resolver['default']);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException
- */
public function testArrayAccessSetNotSupported()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
$this->resolver['default'] = 0;
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException
- */
public function testArrayAccessUnsetNotSupported()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
$this->resolver->setDefault('default', 0);
unset($this->resolver['default']);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\NoSuchOptionException
- * @expectedExceptionMessage The option "undefined" does not exist. Defined options are: "foo", "lazy".
- */
public function testFailIfGetNonExisting()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\NoSuchOptionException');
+ $this->expectExceptionMessage('The option "undefined" does not exist. Defined options are: "foo", "lazy".');
$this->resolver->setDefault('foo', 'bar');
$this->resolver->setDefault('lazy', function (Options $options) {
@@ -1899,12 +1795,10 @@ class OptionsResolverTest extends TestCase
$this->resolver->resolve();
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\NoSuchOptionException
- * @expectedExceptionMessage The optional option "defined" has no value set. You should make sure it is set with "isset" before reading it.
- */
public function testFailIfGetDefinedButUnset()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\NoSuchOptionException');
+ $this->expectExceptionMessage('The optional option "defined" has no value set. You should make sure it is set with "isset" before reading it.');
$this->resolver->setDefined('defined');
$this->resolver->setDefault('lazy', function (Options $options) {
@@ -1914,11 +1808,9 @@ class OptionsResolverTest extends TestCase
$this->resolver->resolve();
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\OptionDefinitionException
- */
public function testFailIfCyclicDependency()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\OptionDefinitionException');
$this->resolver->setDefault('lazy1', function (Options $options) {
$options['lazy2'];
});
@@ -1948,11 +1840,10 @@ class OptionsResolverTest extends TestCase
* In resolve() we count the options that are actually set (which may be
* only a subset of the defined options). Outside of resolve(), it's not
* clear what is counted.
- *
- * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException
*/
public function testCountFailsOutsideResolve()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\AccessException');
$this->resolver->setDefault('foo', 0);
$this->resolver->setRequired('bar');
$this->resolver->setDefined('bar');
@@ -2007,12 +1898,10 @@ class OptionsResolverTest extends TestCase
));
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- * @expectedExceptionMessage The option "foo" with value array is expected to be of type "float[][][][]", but one of the elements is of type "integer[][][][]".
- */
public function testNestedArraysException()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
+ $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "float[][][][]", but one of the elements is of type "integer[][][][]".');
$this->resolver->setDefined('foo');
$this->resolver->setAllowedTypes('foo', 'float[][][][]');
@@ -2027,12 +1916,10 @@ class OptionsResolverTest extends TestCase
]);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- * @expectedExceptionMessage The option "foo" with value array is expected to be of type "int[][]", but one of the elements is of type "boolean[][]".
- */
public function testNestedArrayException1()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
+ $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "int[][]", but one of the elements is of type "boolean[][]".');
$this->resolver->setDefined('foo');
$this->resolver->setAllowedTypes('foo', 'int[][]');
$this->resolver->resolve([
@@ -2042,12 +1929,10 @@ class OptionsResolverTest extends TestCase
]);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- * @expectedExceptionMessage The option "foo" with value array is expected to be of type "int[][]", but one of the elements is of type "boolean[][]".
- */
public function testNestedArrayException2()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
+ $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "int[][]", but one of the elements is of type "boolean[][]".');
$this->resolver->setDefined('foo');
$this->resolver->setAllowedTypes('foo', 'int[][]');
$this->resolver->resolve([
@@ -2057,12 +1942,10 @@ class OptionsResolverTest extends TestCase
]);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- * @expectedExceptionMessage The option "foo" with value array is expected to be of type "string[][][]", but one of the elements is of type "string[][]".
- */
public function testNestedArrayException3()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
+ $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "string[][][]", but one of the elements is of type "string[][]".');
$this->resolver->setDefined('foo');
$this->resolver->setAllowedTypes('foo', 'string[][][]');
$this->resolver->resolve([
@@ -2072,12 +1955,10 @@ class OptionsResolverTest extends TestCase
]);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- * @expectedExceptionMessage The option "foo" with value array is expected to be of type "string[][][]", but one of the elements is of type "integer[][][]".
- */
public function testNestedArrayException4()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
+ $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "string[][][]", but one of the elements is of type "integer[][][]".');
$this->resolver->setDefined('foo');
$this->resolver->setAllowedTypes('foo', 'string[][][]');
$this->resolver->resolve([
@@ -2088,12 +1969,10 @@ class OptionsResolverTest extends TestCase
]);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- * @expectedExceptionMessage The option "foo" with value array is expected to be of type "string[]", but one of the elements is of type "array[]".
- */
public function testNestedArrayException5()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
+ $this->expectExceptionMessage('The option "foo" with value array is expected to be of type "string[]", but one of the elements is of type "array[]".');
$this->resolver->setDefined('foo');
$this->resolver->setAllowedTypes('foo', 'string[]');
$this->resolver->resolve([
@@ -2114,12 +1993,10 @@ class OptionsResolverTest extends TestCase
$this->assertTrue($this->resolver->isNested('database'));
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException
- * @expectedExceptionMessage The option "foo" does not exist. Defined options are: "host", "port".
- */
public function testFailsIfUndefinedNestedOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException');
+ $this->expectExceptionMessage('The option "foo" does not exist. Defined options are: "host", "port".');
$this->resolver->setDefaults([
'name' => 'default',
'database' => function (OptionsResolver $resolver) {
@@ -2131,12 +2008,10 @@ class OptionsResolverTest extends TestCase
]);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\MissingOptionsException
- * @expectedExceptionMessage The required option "host" is missing.
- */
public function testFailsIfMissingRequiredNestedOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\MissingOptionsException');
+ $this->expectExceptionMessage('The required option "host" is missing.');
$this->resolver->setDefaults([
'name' => 'default',
'database' => function (OptionsResolver $resolver) {
@@ -2148,12 +2023,10 @@ class OptionsResolverTest extends TestCase
]);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- * @expectedExceptionMessage The option "logging" with value null is expected to be of type "bool", but is of type "NULL".
- */
public function testFailsIfInvalidTypeNestedOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
+ $this->expectExceptionMessage('The option "logging" with value null is expected to be of type "bool", but is of type "NULL".');
$this->resolver->setDefaults([
'name' => 'default',
'database' => function (OptionsResolver $resolver) {
@@ -2167,12 +2040,10 @@ class OptionsResolverTest extends TestCase
]);
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
- * @expectedExceptionMessage The nested option "database" with value null is expected to be of type array, but is of type "NULL".
- */
public function testFailsIfNotArrayIsGivenForNestedOptions()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
+ $this->expectExceptionMessage('The nested option "database" with value null is expected to be of type array, but is of type "NULL".');
$this->resolver->setDefaults([
'name' => 'default',
'database' => function (OptionsResolver $resolver) {
@@ -2376,22 +2247,18 @@ class OptionsResolverTest extends TestCase
$this->assertSame(['foo' => ['bar' => 'baz']], $this->resolver->resolve());
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\OptionDefinitionException
- */
public function testFailsIfCyclicDependencyBetweenSameNestedOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\OptionDefinitionException');
$this->resolver->setDefault('database', function (OptionsResolver $resolver, Options $parent) {
$resolver->setDefault('replicas', $parent['database']);
});
$this->resolver->resolve();
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\OptionDefinitionException
- */
public function testFailsIfCyclicDependencyBetweenNestedOptionAndParentLazyOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\OptionDefinitionException');
$this->resolver->setDefaults([
'version' => function (Options $options) {
return $options['database']['server_version'];
@@ -2403,11 +2270,9 @@ class OptionsResolverTest extends TestCase
$this->resolver->resolve();
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\OptionDefinitionException
- */
public function testFailsIfCyclicDependencyBetweenNormalizerAndNestedOption()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\OptionDefinitionException');
$this->resolver
->setDefault('name', 'default')
->setDefault('database', function (OptionsResolver $resolver, Options $parent) {
@@ -2419,11 +2284,9 @@ class OptionsResolverTest extends TestCase
$this->resolver->resolve();
}
- /**
- * @expectedException \Symfony\Component\OptionsResolver\Exception\OptionDefinitionException
- */
public function testFailsIfCyclicDependencyBetweenNestedOptions()
{
+ $this->expectException('Symfony\Component\OptionsResolver\Exception\OptionDefinitionException');
$this->resolver->setDefault('database', function (OptionsResolver $resolver, Options $parent) {
$resolver->setDefault('host', $parent['replica']['host']);
});
diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php
index cdbb4d6922..47c5f096e3 100644
--- a/src/Symfony/Component/Process/Tests/ProcessTest.php
+++ b/src/Symfony/Component/Process/Tests/ProcessTest.php
@@ -50,13 +50,10 @@ class ProcessTest extends TestCase
}
}
- /**
- * @expectedException \Symfony\Component\Process\Exception\RuntimeException
- * @expectedExceptionMessage The provided cwd "
- * @expectedExceptionMessage "does not exist.
- */
public function testInvalidCwd()
{
+ $this->expectException('Symfony\Component\Process\Exception\RuntimeException');
+ $this->expectExceptionMessageRegExp('/The provided cwd ".*" does not exist\./');
try {
// Check that it works fine if the CWD exists
$cmd = new Process(['echo', 'test'], __DIR__);
@@ -82,19 +79,15 @@ class ProcessTest extends TestCase
$this->assertEquals(E_USER_NOTICE, $actualError['type']);
}
- /**
- * @expectedException \Symfony\Component\Process\Exception\InvalidArgumentException
- */
public function testNegativeTimeoutFromConstructor()
{
+ $this->expectException('Symfony\Component\Process\Exception\InvalidArgumentException');
$this->getProcess('', null, null, null, -1);
}
- /**
- * @expectedException \Symfony\Component\Process\Exception\InvalidArgumentException
- */
public function testNegativeTimeoutFromSetter()
{
+ $this->expectException('Symfony\Component\Process\Exception\InvalidArgumentException');
$p = $this->getProcess('');
$p->setTimeout(-1);
}
@@ -280,12 +273,10 @@ class ProcessTest extends TestCase
$this->assertSame('hello', $p->getOutput());
}
- /**
- * @expectedException \Symfony\Component\Process\Exception\LogicException
- * @expectedExceptionMessage Input can not be set while the process is running.
- */
public function testSetInputWhileRunningThrowsAnException()
{
+ $this->expectException('Symfony\Component\Process\Exception\LogicException');
+ $this->expectExceptionMessage('Input can not be set while the process is running.');
$process = $this->getProcessForCode('sleep(30);');
$process->start();
try {
@@ -301,11 +292,11 @@ class ProcessTest extends TestCase
/**
* @dataProvider provideInvalidInputValues
- * @expectedException \Symfony\Component\Process\Exception\InvalidArgumentException
- * @expectedExceptionMessage Symfony\Component\Process\Process::setInput only accepts strings, Traversable objects or stream resources.
*/
public function testInvalidInput($value)
{
+ $this->expectException('Symfony\Component\Process\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Symfony\Component\Process\Process::setInput only accepts strings, Traversable objects or stream resources.');
$process = $this->getProcess('foo');
$process->setInput($value);
}
@@ -510,12 +501,10 @@ class ProcessTest extends TestCase
$this->assertTrue($process->isSuccessful());
}
- /**
- * @expectedException \Symfony\Component\Process\Exception\RuntimeException
- * @expectedExceptionMessage TTY mode is not supported on Windows platform.
- */
public function testTTYInWindowsEnvironment()
{
+ $this->expectException('Symfony\Component\Process\Exception\RuntimeException');
+ $this->expectExceptionMessage('TTY mode is not supported on Windows platform.');
if ('\\' !== \DIRECTORY_SEPARATOR) {
$this->markTestSkipped('This test is for Windows platform only');
}
@@ -559,11 +548,9 @@ class ProcessTest extends TestCase
$this->assertEquals(0, $process->getExitCode());
}
- /**
- * @expectedException \Symfony\Component\Process\Exception\ProcessFailedException
- */
public function testMustRunThrowsException()
{
+ $this->expectException('Symfony\Component\Process\Exception\ProcessFailedException');
$process = $this->getProcess('exit 1');
$process->mustRun();
}
@@ -713,12 +700,10 @@ class ProcessTest extends TestCase
$this->assertEquals(15, $process->getTermSignal()); // SIGTERM
}
- /**
- * @expectedException \Symfony\Component\Process\Exception\ProcessSignaledException
- * @expectedExceptionMessage The process has been signaled with signal "9".
- */
public function testProcessThrowsExceptionWhenExternallySignaled()
{
+ $this->expectException('Symfony\Component\Process\Exception\ProcessSignaledException');
+ $this->expectExceptionMessage('The process has been signaled with signal "9".');
if (!\function_exists('posix_kill')) {
$this->markTestSkipped('Function posix_kill is required.');
}
@@ -752,12 +737,10 @@ class ProcessTest extends TestCase
$this->assertNotEquals($process1->getOutput(), $process2->getOutput());
}
- /**
- * @expectedException \Symfony\Component\Process\Exception\ProcessTimedOutException
- * @expectedExceptionMessage exceeded the timeout of 0.1 seconds.
- */
public function testRunProcessWithTimeout()
{
+ $this->expectException('Symfony\Component\Process\Exception\ProcessTimedOutException');
+ $this->expectExceptionMessage('exceeded the timeout of 0.1 seconds.');
$process = $this->getProcessForCode('sleep(30);');
$process->setTimeout(0.1);
$start = microtime(true);
@@ -772,12 +755,10 @@ class ProcessTest extends TestCase
throw $e;
}
- /**
- * @expectedException \Symfony\Component\Process\Exception\ProcessTimedOutException
- * @expectedExceptionMessage exceeded the timeout of 0.1 seconds.
- */
public function testIterateOverProcessWithTimeout()
{
+ $this->expectException('Symfony\Component\Process\Exception\ProcessTimedOutException');
+ $this->expectExceptionMessage('exceeded the timeout of 0.1 seconds.');
$process = $this->getProcessForCode('sleep(30);');
$process->setTimeout(0.1);
$start = microtime(true);
@@ -806,12 +787,10 @@ class ProcessTest extends TestCase
$this->assertNull($process->checkTimeout());
}
- /**
- * @expectedException \Symfony\Component\Process\Exception\ProcessTimedOutException
- * @expectedExceptionMessage exceeded the timeout of 0.1 seconds.
- */
public function testCheckTimeoutOnStartedProcess()
{
+ $this->expectException('Symfony\Component\Process\Exception\ProcessTimedOutException');
+ $this->expectExceptionMessage('exceeded the timeout of 0.1 seconds.');
$process = $this->getProcessForCode('sleep(33);');
$process->setTimeout(0.1);
@@ -871,12 +850,10 @@ class ProcessTest extends TestCase
}
}
- /**
- * @expectedException \Symfony\Component\Process\Exception\ProcessTimedOutException
- * @expectedExceptionMessage exceeded the timeout of 0.1 seconds.
- */
public function testStartAfterATimeout()
{
+ $this->expectException('Symfony\Component\Process\Exception\ProcessTimedOutException');
+ $this->expectExceptionMessage('exceeded the timeout of 0.1 seconds.');
$process = $this->getProcessForCode('sleep(35);');
$process->setTimeout(0.1);
@@ -950,12 +927,10 @@ class ProcessTest extends TestCase
$this->assertEquals(137, $process->getExitCode());
}
- /**
- * @expectedException \Symfony\Component\Process\Exception\LogicException
- * @expectedExceptionMessage Can not send signal on a non running process.
- */
public function testSignalProcessNotRunning()
{
+ $this->expectException('Symfony\Component\Process\Exception\LogicException');
+ $this->expectExceptionMessage('Can not send signal on a non running process.');
$process = $this->getProcess('foo');
$process->signal(1); // SIGHUP
}
@@ -986,11 +961,11 @@ class ProcessTest extends TestCase
/**
* @dataProvider provideMethodsThatNeedATerminatedProcess
- * @expectedException \Symfony\Component\Process\Exception\LogicException
- * @expectedExceptionMessage Process must be terminated before calling
*/
public function testMethodsThatNeedATerminatedProcess($method)
{
+ $this->expectException('Symfony\Component\Process\Exception\LogicException');
+ $this->expectExceptionMessage('Process must be terminated before calling');
$process = $this->getProcessForCode('sleep(37);');
$process->start();
try {
@@ -1014,11 +989,9 @@ class ProcessTest extends TestCase
];
}
- /**
- * @expectedException \Symfony\Component\Process\Exception\RuntimeException
- */
public function testWrongSignal()
{
+ $this->expectException('Symfony\Component\Process\Exception\RuntimeException');
if ('\\' === \DIRECTORY_SEPARATOR) {
$this->markTestSkipped('POSIX signals do not work on Windows');
}
@@ -1045,23 +1018,19 @@ class ProcessTest extends TestCase
$this->assertFalse($p->isOutputDisabled());
}
- /**
- * @expectedException \Symfony\Component\Process\Exception\RuntimeException
- * @expectedExceptionMessage Disabling output while the process is running is not possible.
- */
public function testDisableOutputWhileRunningThrowsException()
{
+ $this->expectException('Symfony\Component\Process\Exception\RuntimeException');
+ $this->expectExceptionMessage('Disabling output while the process is running is not possible.');
$p = $this->getProcessForCode('sleep(39);');
$p->start();
$p->disableOutput();
}
- /**
- * @expectedException \Symfony\Component\Process\Exception\RuntimeException
- * @expectedExceptionMessage Enabling output while the process is running is not possible.
- */
public function testEnableOutputWhileRunningThrowsException()
{
+ $this->expectException('Symfony\Component\Process\Exception\RuntimeException');
+ $this->expectExceptionMessage('Enabling output while the process is running is not possible.');
$p = $this->getProcessForCode('sleep(40);');
$p->disableOutput();
$p->start();
@@ -1078,23 +1047,19 @@ class ProcessTest extends TestCase
$this->assertTrue($p->isOutputDisabled());
}
- /**
- * @expectedException \Symfony\Component\Process\Exception\LogicException
- * @expectedExceptionMessage Output can not be disabled while an idle timeout is set.
- */
public function testDisableOutputWhileIdleTimeoutIsSet()
{
+ $this->expectException('Symfony\Component\Process\Exception\LogicException');
+ $this->expectExceptionMessage('Output can not be disabled while an idle timeout is set.');
$process = $this->getProcess('foo');
$process->setIdleTimeout(1);
$process->disableOutput();
}
- /**
- * @expectedException \Symfony\Component\Process\Exception\LogicException
- * @expectedExceptionMessage timeout can not be set while the output is disabled.
- */
public function testSetIdleTimeoutWhileOutputIsDisabled()
{
+ $this->expectException('Symfony\Component\Process\Exception\LogicException');
+ $this->expectExceptionMessage('timeout can not be set while the output is disabled.');
$process = $this->getProcess('foo');
$process->disableOutput();
$process->setIdleTimeout(1);
@@ -1109,11 +1074,11 @@ class ProcessTest extends TestCase
/**
* @dataProvider provideOutputFetchingMethods
- * @expectedException \Symfony\Component\Process\Exception\LogicException
- * @expectedExceptionMessage Output has been disabled.
*/
public function testGetOutputWhileDisabled($fetchMethod)
{
+ $this->expectException('Symfony\Component\Process\Exception\LogicException');
+ $this->expectExceptionMessage('Output has been disabled.');
$p = $this->getProcessForCode('sleep(41);');
$p->disableOutput();
$p->start();
@@ -1521,22 +1486,18 @@ EOTXT;
$this->assertSame('"DEF"', rtrim($p->getOutput()));
}
- /**
- * @expectedException \Symfony\Component\Process\Exception\InvalidArgumentException
- * @expectedExceptionMessage Command line is missing a value for key "$abc": echo "$abc".
- */
public function testPreparedCommandWithMissingValue()
{
+ $this->expectException('Symfony\Component\Process\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Command line is missing a value for key "$abc": echo "$abc".');
$p = Process::fromShellCommandline('echo "$abc"');
$p->run(null, ['bcd' => 'BCD']);
}
- /**
- * @expectedException \Symfony\Component\Process\Exception\InvalidArgumentException
- * @expectedExceptionMessage Command line is missing a value for key "$abc": echo "$abc".
- */
public function testPreparedCommandWithNoValues()
{
+ $this->expectException('Symfony\Component\Process\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Command line is missing a value for key "$abc": echo "$abc".');
$p = Process::fromShellCommandline('echo "$abc"');
$p->run(null, []);
}
diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorArrayAccessTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorArrayAccessTest.php
index 5749cfae6f..071f70d360 100644
--- a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorArrayAccessTest.php
+++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorArrayAccessTest.php
@@ -48,11 +48,9 @@ abstract class PropertyAccessorArrayAccessTest extends TestCase
$this->assertSame($value, $this->propertyAccessor->getValue($collection, $path));
}
- /**
- * @expectedException \Symfony\Component\PropertyAccess\Exception\NoSuchIndexException
- */
public function testGetValueFailsIfNoSuchIndex()
{
+ $this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchIndexException');
$this->propertyAccessor = PropertyAccess::createPropertyAccessorBuilder()
->enableExceptionOnInvalidIndex()
->getPropertyAccessor();
diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php
index 61ce5f1272..533de1173a 100644
--- a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php
+++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php
@@ -11,6 +11,8 @@
namespace Symfony\Component\PropertyAccess\Tests;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
+
class PropertyAccessorCollectionTest_Car
{
private $axes;
@@ -100,6 +102,8 @@ class PropertyAccessorCollectionTest_CarStructure
abstract class PropertyAccessorCollectionTest extends PropertyAccessorArrayAccessTest
{
+ use ForwardCompatTestTrait;
+
public function testSetValueCallsAdderAndRemoverForCollections()
{
$axesBefore = $this->getContainer([1 => 'second', 3 => 'fourth', 4 => 'fifth']);
@@ -146,12 +150,10 @@ abstract class PropertyAccessorCollectionTest extends PropertyAccessorArrayAcces
$this->propertyAccessor->setValue($car, 'structure.axes', $axesAfter);
}
- /**
- * @expectedException \Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException
- * @expectedExceptionMessageRegExp /Could not determine access type for property "axes" in class "Mock_PropertyAccessorCollectionTest_CarNoAdderAndRemover_[^"]*"./
- */
public function testSetValueFailsIfNoAdderNorRemoverFound()
{
+ $this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException');
+ $this->expectExceptionMessageRegExp('/Could not determine access type for property "axes" in class "Mock_PropertyAccessorCollectionTest_CarNoAdderAndRemover_[^"]*"./');
$car = $this->getMockBuilder(__CLASS__.'_CarNoAdderAndRemover')->getMock();
$axesBefore = $this->getContainer([1 => 'second', 3 => 'fourth']);
$axesAfter = $this->getContainer([0 => 'first', 1 => 'second', 2 => 'third']);
@@ -187,12 +189,10 @@ abstract class PropertyAccessorCollectionTest extends PropertyAccessorArrayAcces
$this->assertFalse($this->propertyAccessor->isWritable($car, 'axes'));
}
- /**
- * @expectedException \Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException
- * @expectedExceptionMessageRegExp /Could not determine access type for property "axes" in class "Symfony\\Component\\PropertyAccess\\Tests\\PropertyAccessorCollectionTest_Car[^"]*": The property "axes" in class "Symfony\\Component\\PropertyAccess\\Tests\\PropertyAccessorCollectionTest_Car[^"]*" can be defined with the methods "addAxis\(\)", "removeAxis\(\)" but the new value must be an array or an instance of \\Traversable, "string" given./
- */
public function testSetValueFailsIfAdderAndRemoverExistButValueIsNotTraversable()
{
+ $this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException');
+ $this->expectExceptionMessageRegExp('/Could not determine access type for property "axes" in class "Symfony\\\\Component\\\\PropertyAccess\\\\Tests\\\\PropertyAccessorCollectionTest_Car[^"]*": The property "axes" in class "Symfony\\\\Component\\\\PropertyAccess\\\\Tests\\\\PropertyAccessorCollectionTest_Car[^"]*" can be defined with the methods "addAxis\(\)", "removeAxis\(\)" but the new value must be an array or an instance of \\\\Traversable, "string" given./');
$car = new PropertyAccessorCollectionTest_Car();
$this->propertyAccessor->setValue($car, 'axes', 'Not an array or Traversable');
diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php
index d9eef22357..c2bc79219d 100644
--- a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php
+++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php
@@ -99,10 +99,10 @@ class PropertyAccessorTest extends TestCase
/**
* @dataProvider getPathsWithMissingProperty
- * @expectedException \Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException
*/
public function testGetValueThrowsExceptionIfPropertyNotFound($objectOrArray, $path)
{
+ $this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException');
$this->propertyAccessor->getValue($objectOrArray, $path);
}
@@ -126,19 +126,17 @@ class PropertyAccessorTest extends TestCase
/**
* @dataProvider getPathsWithMissingIndex
- * @expectedException \Symfony\Component\PropertyAccess\Exception\NoSuchIndexException
*/
public function testGetValueThrowsExceptionIfIndexNotFoundAndIndexExceptionsEnabled($objectOrArray, $path)
{
+ $this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchIndexException');
$this->propertyAccessor = new PropertyAccessor(false, true);
$this->propertyAccessor->getValue($objectOrArray, $path);
}
- /**
- * @expectedException \Symfony\Component\PropertyAccess\Exception\NoSuchIndexException
- */
public function testGetValueThrowsExceptionIfNotArrayAccess()
{
+ $this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchIndexException');
$this->propertyAccessor->getValue(new \stdClass(), '[index]');
}
@@ -185,11 +183,9 @@ class PropertyAccessorTest extends TestCase
$this->assertSame(['Bernhard'], $object->firstName);
}
- /**
- * @expectedException \Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException
- */
public function testGetValueDoesNotReadMagicCallByDefault()
{
+ $this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException');
$this->propertyAccessor->getValue(new TestClassMagicCall('Bernhard'), 'magicCallProperty');
}
@@ -210,11 +206,11 @@ class PropertyAccessorTest extends TestCase
/**
* @dataProvider getPathsWithUnexpectedType
- * @expectedException \Symfony\Component\PropertyAccess\Exception\UnexpectedTypeException
- * @expectedExceptionMessage PropertyAccessor requires a graph of objects or arrays to operate on
*/
public function testGetValueThrowsExceptionIfNotObjectOrArray($objectOrArray, $path)
{
+ $this->expectException('Symfony\Component\PropertyAccess\Exception\UnexpectedTypeException');
+ $this->expectExceptionMessage('PropertyAccessor requires a graph of objects or arrays to operate on');
$this->propertyAccessor->getValue($objectOrArray, $path);
}
@@ -230,10 +226,10 @@ class PropertyAccessorTest extends TestCase
/**
* @dataProvider getPathsWithMissingProperty
- * @expectedException \Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException
*/
public function testSetValueThrowsExceptionIfPropertyNotFound($objectOrArray, $path)
{
+ $this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException');
$this->propertyAccessor->setValue($objectOrArray, $path, 'Updated');
}
@@ -258,11 +254,9 @@ class PropertyAccessorTest extends TestCase
$this->assertSame('Updated', $this->propertyAccessor->getValue($objectOrArray, $path));
}
- /**
- * @expectedException \Symfony\Component\PropertyAccess\Exception\NoSuchIndexException
- */
public function testSetValueThrowsExceptionIfNotArrayAccess()
{
+ $this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchIndexException');
$object = new \stdClass();
$this->propertyAccessor->setValue($object, '[index]', 'Updated');
@@ -277,21 +271,17 @@ class PropertyAccessorTest extends TestCase
$this->assertEquals('Updated', $author->__get('magicProperty'));
}
- /**
- * @expectedException \Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException
- */
public function testSetValueThrowsExceptionIfThereAreMissingParameters()
{
+ $this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException');
$object = new TestClass('Bernhard');
$this->propertyAccessor->setValue($object, 'publicAccessorWithMoreRequiredParameters', 'Updated');
}
- /**
- * @expectedException \Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException
- */
public function testSetValueDoesNotUpdateMagicCallByDefault()
{
+ $this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException');
$author = new TestClassMagicCall('Bernhard');
$this->propertyAccessor->setValue($author, 'magicCallProperty', 'Updated');
@@ -310,11 +300,11 @@ class PropertyAccessorTest extends TestCase
/**
* @dataProvider getPathsWithUnexpectedType
- * @expectedException \Symfony\Component\PropertyAccess\Exception\UnexpectedTypeException
- * @expectedExceptionMessage PropertyAccessor requires a graph of objects or arrays to operate on
*/
public function testSetValueThrowsExceptionIfNotObjectOrArray($objectOrArray, $path)
{
+ $this->expectException('Symfony\Component\PropertyAccess\Exception\UnexpectedTypeException');
+ $this->expectExceptionMessage('PropertyAccessor requires a graph of objects or arrays to operate on');
$this->propertyAccessor->setValue($objectOrArray, $path, 'value');
}
@@ -547,23 +537,19 @@ class PropertyAccessorTest extends TestCase
$this->assertEquals($value, $this->propertyAccessor->isWritable($object, $path));
}
- /**
- * @expectedException \Symfony\Component\PropertyAccess\Exception\InvalidArgumentException
- * @expectedExceptionMessage Expected argument of type "DateTime", "string" given at property path "date"
- */
public function testThrowTypeError()
{
+ $this->expectException('Symfony\Component\PropertyAccess\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Expected argument of type "DateTime", "string" given at property path "date"');
$object = new TypeHinted();
$this->propertyAccessor->setValue($object, 'date', 'This is a string, \DateTime expected.');
}
- /**
- * @expectedException \Symfony\Component\PropertyAccess\Exception\InvalidArgumentException
- * @expectedExceptionMessage Expected argument of type "DateTime", "NULL" given
- */
public function testThrowTypeErrorWithNullArgument()
{
+ $this->expectException('Symfony\Component\PropertyAccess\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Expected argument of type "DateTime", "NULL" given');
$object = new TypeHinted();
$this->propertyAccessor->setValue($object, 'date', null);
@@ -612,12 +598,10 @@ class PropertyAccessorTest extends TestCase
$this->assertSame('2', $propertyAccessor->getValue($obj, 'a%2Fb'));
}
- /**
- * @expectedException \Symfony\Component\PropertyAccess\Exception\InvalidArgumentException
- * @expectedExceptionMessage Expected argument of type "Countable", "string" given
- */
public function testThrowTypeErrorWithInterface()
{
+ $this->expectException('Symfony\Component\PropertyAccess\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Expected argument of type "Countable", "string" given');
$object = new TypeHinted();
$this->propertyAccessor->setValue($object, 'countable', 'This is a string, \Countable expected.');
@@ -634,11 +618,9 @@ class PropertyAccessorTest extends TestCase
$this->assertEquals($value, $propertyAccessor->getValue($obj, 'foo'));
}
- /**
- * @expectedException \Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException
- */
public function testAnonymousClassReadThrowExceptionOnInvalidPropertyPath()
{
+ $this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException');
$obj = $this->generateAnonymousClass('bar');
$this->propertyAccessor->getValue($obj, 'invalid_property');
@@ -696,31 +678,25 @@ class PropertyAccessorTest extends TestCase
return $obj;
}
- /**
- * @expectedException \TypeError
- */
public function testThrowTypeErrorInsideSetterCall()
{
+ $this->expectException('TypeError');
$object = new TestClassTypeErrorInsideCall();
$this->propertyAccessor->setValue($object, 'property', 'foo');
}
- /**
- * @expectedException \TypeError
- */
public function testDoNotDiscardReturnTypeError()
{
+ $this->expectException('TypeError');
$object = new ReturnTyped();
$this->propertyAccessor->setValue($object, 'foos', [new \DateTime()]);
}
- /**
- * @expectedException \TypeError
- */
public function testDoNotDiscardReturnTypeErrorWhenWriterMethodIsMisconfigured()
{
+ $this->expectException('TypeError');
$object = new ReturnTyped();
$this->propertyAccessor->setValue($object, 'name', 'foo');
@@ -768,52 +744,42 @@ class PropertyAccessorTest extends TestCase
$this->assertEquals(['aeroplane'], $object->getAircraft());
}
- /**
- * @expectedException \Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException
- * @expectedExceptionMessageRegExp /.*The add method "addFoo" in class "Symfony\\Component\\PropertyAccess\\Tests\\Fixtures\\TestAdderRemoverInvalidMethods" was found, but the corresponding remove method "removeFoo" was not found\./
- */
public function testAdderWithoutRemover()
{
+ $this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException');
+ $this->expectExceptionMessageRegExp('/.*The add method "addFoo" in class "Symfony\\\Component\\\PropertyAccess\\\Tests\\\Fixtures\\\TestAdderRemoverInvalidMethods" was found, but the corresponding remove method "removeFoo" was not found\./');
$object = new TestAdderRemoverInvalidMethods();
$this->propertyAccessor->setValue($object, 'foos', [1, 2]);
}
- /**
- * @expectedException \Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException
- * @expectedExceptionMessageRegExp /.*The remove method "removeBar" in class "Symfony\\Component\\PropertyAccess\\Tests\\Fixtures\\TestAdderRemoverInvalidMethods" was found, but the corresponding add method "addBar" was not found\./
- */
public function testRemoverWithoutAdder()
{
+ $this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException');
+ $this->expectExceptionMessageRegExp('/.*The remove method "removeBar" in class "Symfony\\\Component\\\PropertyAccess\\\Tests\\\Fixtures\\\TestAdderRemoverInvalidMethods" was found, but the corresponding add method "addBar" was not found\./');
$object = new TestAdderRemoverInvalidMethods();
$this->propertyAccessor->setValue($object, 'bars', [1, 2]);
}
- /**
- * @expectedException \Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException
- * @expectedExceptionMessageRegExp /.*The method "addFoo" in class "Symfony\\Component\\PropertyAccess\\Tests\\Fixtures\\TestAdderRemoverInvalidArgumentLength" requires 0 arguments, but should accept only 1\. The method "removeFoo" in class "Symfony\\Component\\PropertyAccess\\Tests\\Fixtures\\TestAdderRemoverInvalidArgumentLength" requires 2 arguments, but should accept only 1\./
- */
public function testAdderAndRemoveNeedsTheExactParametersDefined()
{
+ $this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException');
+ $this->expectExceptionMessageRegExp('/.*The method "addFoo" in class "Symfony\\\Component\\\PropertyAccess\\\Tests\\\Fixtures\\\TestAdderRemoverInvalidArgumentLength" requires 0 arguments, but should accept only 1\. The method "removeFoo" in class "Symfony\\\Component\\\PropertyAccess\\\Tests\\\Fixtures\\\TestAdderRemoverInvalidArgumentLength" requires 2 arguments, but should accept only 1\./');
$object = new TestAdderRemoverInvalidArgumentLength();
$this->propertyAccessor->setValue($object, 'foo', [1, 2]);
}
- /**
- * @expectedException \Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException
- * @expectedExceptionMessageRegExp /.*The method "setBar" in class "Symfony\\Component\\PropertyAccess\\Tests\\Fixtures\\TestAdderRemoverInvalidArgumentLength" requires 2 arguments, but should accept only 1\./
- */
public function testSetterNeedsTheExactParametersDefined()
{
+ $this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException');
+ $this->expectExceptionMessageRegExp('/.*The method "setBar" in class "Symfony\\\Component\\\PropertyAccess\\\Tests\\\Fixtures\\\TestAdderRemoverInvalidArgumentLength" requires 2 arguments, but should accept only 1\./');
$object = new TestAdderRemoverInvalidArgumentLength();
$this->propertyAccessor->setValue($object, 'bar', [1, 2]);
}
- /**
- * @expectedException \Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException
- * @expectedExceptionMessageRegExp /.*The method "setFoo" in class "Symfony\\Component\\PropertyAccess\\Tests\\Fixtures\\TestClassSetValue" was found but does not have public access./
- */
public function testSetterNeedsPublicAccess()
{
+ $this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException');
+ $this->expectExceptionMessageRegExp('/.*The method "setFoo" in class "Symfony\\\Component\\\PropertyAccess\\\Tests\\\Fixtures\\\TestClassSetValue" was found but does not have public access./');
$object = new TestClassSetValue(0);
$this->propertyAccessor->setValue($object, 'foo', 1);
}
diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyPathBuilderTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyPathBuilderTest.php
index fcc400b8c5..e4ff364439 100644
--- a/src/Symfony/Component/PropertyAccess/Tests/PropertyPathBuilderTest.php
+++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyPathBuilderTest.php
@@ -119,19 +119,15 @@ class PropertyPathBuilderTest extends TestCase
$this->assertEquals($path, $this->builder->getPropertyPath());
}
- /**
- * @expectedException \OutOfBoundsException
- */
public function testReplaceByIndexDoesNotAllowInvalidOffsets()
{
+ $this->expectException('OutOfBoundsException');
$this->builder->replaceByIndex(6, 'new1');
}
- /**
- * @expectedException \OutOfBoundsException
- */
public function testReplaceByIndexDoesNotAllowNegativeOffsets()
{
+ $this->expectException('OutOfBoundsException');
$this->builder->replaceByIndex(-1, 'new1');
}
@@ -153,19 +149,15 @@ class PropertyPathBuilderTest extends TestCase
$this->assertEquals($path, $this->builder->getPropertyPath());
}
- /**
- * @expectedException \OutOfBoundsException
- */
public function testReplaceByPropertyDoesNotAllowInvalidOffsets()
{
+ $this->expectException('OutOfBoundsException');
$this->builder->replaceByProperty(6, 'new1');
}
- /**
- * @expectedException \OutOfBoundsException
- */
public function testReplaceByPropertyDoesNotAllowNegativeOffsets()
{
+ $this->expectException('OutOfBoundsException');
$this->builder->replaceByProperty(-1, 'new1');
}
@@ -198,10 +190,10 @@ class PropertyPathBuilderTest extends TestCase
/**
* @dataProvider provideInvalidOffsets
- * @expectedException \OutOfBoundsException
*/
public function testReplaceDoesNotAllowInvalidOffsets($offset)
{
+ $this->expectException('OutOfBoundsException');
$this->builder->replace($offset, 1, new PropertyPath('new1[new2].new3'));
}
@@ -273,19 +265,15 @@ class PropertyPathBuilderTest extends TestCase
$this->assertEquals($path, $this->builder->getPropertyPath());
}
- /**
- * @expectedException \OutOfBoundsException
- */
public function testRemoveDoesNotAllowInvalidOffsets()
{
+ $this->expectException('OutOfBoundsException');
$this->builder->remove(6);
}
- /**
- * @expectedException \OutOfBoundsException
- */
public function testRemoveDoesNotAllowNegativeOffsets()
{
+ $this->expectException('OutOfBoundsException');
$this->builder->remove(-1);
}
diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyPathTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyPathTest.php
index c58ebf510c..dbe63a258f 100644
--- a/src/Symfony/Component/PropertyAccess/Tests/PropertyPathTest.php
+++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyPathTest.php
@@ -12,10 +12,13 @@
namespace Symfony\Component\PropertyAccess\Tests;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\PropertyAccess\PropertyPath;
class PropertyPathTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testToString()
{
$path = new PropertyPath('reference.traversable[index].property');
@@ -23,19 +26,15 @@ class PropertyPathTest extends TestCase
$this->assertEquals('reference.traversable[index].property', $path->__toString());
}
- /**
- * @expectedException \Symfony\Component\PropertyAccess\Exception\InvalidPropertyPathException
- */
public function testDotIsRequiredBeforeProperty()
{
+ $this->expectException('Symfony\Component\PropertyAccess\Exception\InvalidPropertyPathException');
new PropertyPath('[index]property');
}
- /**
- * @expectedException \Symfony\Component\PropertyAccess\Exception\InvalidPropertyPathException
- */
public function testDotCannotBePresentAtTheBeginning()
{
+ $this->expectException('Symfony\Component\PropertyAccess\Exception\InvalidPropertyPathException');
new PropertyPath('.property');
}
@@ -54,34 +53,28 @@ class PropertyPathTest extends TestCase
/**
* @dataProvider providePathsContainingUnexpectedCharacters
- * @expectedException \Symfony\Component\PropertyAccess\Exception\InvalidPropertyPathException
*/
public function testUnexpectedCharacters($path)
{
+ $this->expectException('Symfony\Component\PropertyAccess\Exception\InvalidPropertyPathException');
new PropertyPath($path);
}
- /**
- * @expectedException \Symfony\Component\PropertyAccess\Exception\InvalidPropertyPathException
- */
public function testPathCannotBeEmpty()
{
+ $this->expectException('Symfony\Component\PropertyAccess\Exception\InvalidPropertyPathException');
new PropertyPath('');
}
- /**
- * @expectedException \Symfony\Component\PropertyAccess\Exception\InvalidArgumentException
- */
public function testPathCannotBeNull()
{
+ $this->expectException('Symfony\Component\PropertyAccess\Exception\InvalidArgumentException');
new PropertyPath(null);
}
- /**
- * @expectedException \Symfony\Component\PropertyAccess\Exception\InvalidArgumentException
- */
public function testPathCannotBeFalse()
{
+ $this->expectException('Symfony\Component\PropertyAccess\Exception\InvalidArgumentException');
new PropertyPath(false);
}
@@ -128,21 +121,17 @@ class PropertyPathTest extends TestCase
$this->assertEquals('child', $propertyPath->getElement(2));
}
- /**
- * @expectedException \OutOfBoundsException
- */
public function testGetElementDoesNotAcceptInvalidIndices()
{
+ $this->expectException('OutOfBoundsException');
$propertyPath = new PropertyPath('grandpa.parent[child]');
$propertyPath->getElement(3);
}
- /**
- * @expectedException \OutOfBoundsException
- */
public function testGetElementDoesNotAcceptNegativeIndices()
{
+ $this->expectException('OutOfBoundsException');
$propertyPath = new PropertyPath('grandpa.parent[child]');
$propertyPath->getElement(-1);
@@ -156,21 +145,17 @@ class PropertyPathTest extends TestCase
$this->assertFalse($propertyPath->isProperty(2));
}
- /**
- * @expectedException \OutOfBoundsException
- */
public function testIsPropertyDoesNotAcceptInvalidIndices()
{
+ $this->expectException('OutOfBoundsException');
$propertyPath = new PropertyPath('grandpa.parent[child]');
$propertyPath->isProperty(3);
}
- /**
- * @expectedException \OutOfBoundsException
- */
public function testIsPropertyDoesNotAcceptNegativeIndices()
{
+ $this->expectException('OutOfBoundsException');
$propertyPath = new PropertyPath('grandpa.parent[child]');
$propertyPath->isProperty(-1);
@@ -184,21 +169,17 @@ class PropertyPathTest extends TestCase
$this->assertTrue($propertyPath->isIndex(2));
}
- /**
- * @expectedException \OutOfBoundsException
- */
public function testIsIndexDoesNotAcceptInvalidIndices()
{
+ $this->expectException('OutOfBoundsException');
$propertyPath = new PropertyPath('grandpa.parent[child]');
$propertyPath->isIndex(3);
}
- /**
- * @expectedException \OutOfBoundsException
- */
public function testIsIndexDoesNotAcceptNegativeIndices()
{
+ $this->expectException('OutOfBoundsException');
$propertyPath = new PropertyPath('grandpa.parent[child]');
$propertyPath->isIndex(-1);
diff --git a/src/Symfony/Component/PropertyInfo/Tests/TypeTest.php b/src/Symfony/Component/PropertyInfo/Tests/TypeTest.php
index cd1cab9167..ced7231450 100644
--- a/src/Symfony/Component/PropertyInfo/Tests/TypeTest.php
+++ b/src/Symfony/Component/PropertyInfo/Tests/TypeTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\PropertyInfo\Tests;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\PropertyInfo\Type;
/**
@@ -19,6 +20,8 @@ use Symfony\Component\PropertyInfo\Type;
*/
class TypeTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testConstruct()
{
$type = new Type('object', true, 'ArrayObject', true, new Type('int'), new Type('string'));
@@ -43,12 +46,10 @@ class TypeTest extends TestCase
$this->assertSame('iterable', $type->getBuiltinType());
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage "foo" is not a valid PHP type.
- */
public function testInvalidType()
{
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('"foo" is not a valid PHP type.');
new Type('foo');
}
}
diff --git a/src/Symfony/Component/Routing/Tests/Annotation/RouteTest.php b/src/Symfony/Component/Routing/Tests/Annotation/RouteTest.php
index 9697aac88b..2f066f7cad 100644
--- a/src/Symfony/Component/Routing/Tests/Annotation/RouteTest.php
+++ b/src/Symfony/Component/Routing/Tests/Annotation/RouteTest.php
@@ -12,23 +12,22 @@
namespace Symfony\Component\Routing\Tests\Annotation;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Routing\Annotation\Route;
class RouteTest extends TestCase
{
- /**
- * @expectedException \BadMethodCallException
- */
+ use ForwardCompatTestTrait;
+
public function testInvalidRouteParameter()
{
+ $this->expectException('BadMethodCallException');
$route = new Route(['foo' => 'bar']);
}
- /**
- * @expectedException \BadMethodCallException
- */
public function testTryingToSetLocalesDirectly()
{
+ $this->expectException('BadMethodCallException');
$route = new Route(['locales' => ['nl' => 'bar']]);
}
diff --git a/src/Symfony/Component/Routing/Tests/Generator/Dumper/CompiledUrlGeneratorDumperTest.php b/src/Symfony/Component/Routing/Tests/Generator/Dumper/CompiledUrlGeneratorDumperTest.php
index e6b076302c..513e1c80e1 100644
--- a/src/Symfony/Component/Routing/Tests/Generator/Dumper/CompiledUrlGeneratorDumperTest.php
+++ b/src/Symfony/Component/Routing/Tests/Generator/Dumper/CompiledUrlGeneratorDumperTest.php
@@ -116,12 +116,10 @@ class CompiledUrlGeneratorDumperTest extends TestCase
$this->assertEquals('/app.php/foo', $projectUrlGenerator->generate('test'));
}
- /**
- * @expectedException \Symfony\Component\Routing\Exception\RouteNotFoundException
- * @expectedExceptionMessage Unable to generate a URL for the named route "test" as such route does not exist.
- */
public function testDumpWithRouteNotFoundLocalizedRoutes()
{
+ $this->expectException('Symfony\Component\Routing\Exception\RouteNotFoundException');
+ $this->expectExceptionMessage('Unable to generate a URL for the named route "test" as such route does not exist.');
$this->routeCollection->add('test.en', (new Route('/testing/is/fun'))->setDefault('_locale', 'en')->setDefault('_canonical_route', 'test'));
$code = $this->generatorDumper->dump();
@@ -178,11 +176,9 @@ class CompiledUrlGeneratorDumperTest extends TestCase
$this->assertEquals('/app.php/testing2', $relativeUrlWithoutParameter);
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testDumpWithoutRoutes()
{
+ $this->expectException('InvalidArgumentException');
file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump());
$projectUrlGenerator = new CompiledUrlGenerator(require $this->testTmpFilepath, new RequestContext('/app.php'));
@@ -190,11 +186,9 @@ class CompiledUrlGeneratorDumperTest extends TestCase
$projectUrlGenerator->generate('Test', []);
}
- /**
- * @expectedException \Symfony\Component\Routing\Exception\RouteNotFoundException
- */
public function testGenerateNonExistingRoute()
{
+ $this->expectException('Symfony\Component\Routing\Exception\RouteNotFoundException');
$this->routeCollection->add('Test', new Route('/test'));
file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump());
diff --git a/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php b/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php
index 77a2098ab9..c9e3753d35 100644
--- a/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php
+++ b/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php
@@ -79,11 +79,9 @@ class UrlGeneratorTest extends TestCase
$this->assertEquals('/app.php/testing', $url);
}
- /**
- * @expectedException \Symfony\Component\Routing\Exception\InvalidParameterException
- */
public function testRelativeUrlWithNullParameterButNotOptional()
{
+ $this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException');
$routes = $this->getRoutes('test', new Route('/testing/{foo}/bar', ['foo' => null]));
// This must raise an exception because the default requirement for "foo" is "[^/]+" which is not met with these params.
// Generating path "/testing//bar" would be wrong as matching this route would fail.
@@ -241,20 +239,16 @@ class UrlGeneratorTest extends TestCase
);
}
- /**
- * @expectedException \Symfony\Component\Routing\Exception\RouteNotFoundException
- */
public function testGenerateWithoutRoutes()
{
+ $this->expectException('Symfony\Component\Routing\Exception\RouteNotFoundException');
$routes = $this->getRoutes('foo', new Route('/testing/{foo}'));
$this->getGenerator($routes)->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL);
}
- /**
- * @expectedException \Symfony\Component\Routing\Exception\RouteNotFoundException
- */
public function testGenerateWithInvalidLocale()
{
+ $this->expectException('Symfony\Component\Routing\Exception\RouteNotFoundException');
$routes = new RouteCollection();
$route = new Route('');
@@ -273,29 +267,23 @@ class UrlGeneratorTest extends TestCase
$generator->generate($name);
}
- /**
- * @expectedException \Symfony\Component\Routing\Exception\MissingMandatoryParametersException
- */
public function testGenerateForRouteWithoutMandatoryParameter()
{
+ $this->expectException('Symfony\Component\Routing\Exception\MissingMandatoryParametersException');
$routes = $this->getRoutes('test', new Route('/testing/{foo}'));
$this->getGenerator($routes)->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL);
}
- /**
- * @expectedException \Symfony\Component\Routing\Exception\InvalidParameterException
- */
public function testGenerateForRouteWithInvalidOptionalParameter()
{
+ $this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException');
$routes = $this->getRoutes('test', new Route('/testing/{foo}', ['foo' => '1'], ['foo' => 'd+']));
$this->getGenerator($routes)->generate('test', ['foo' => 'bar'], UrlGeneratorInterface::ABSOLUTE_URL);
}
- /**
- * @expectedException \Symfony\Component\Routing\Exception\InvalidParameterException
- */
public function testGenerateForRouteWithInvalidParameter()
{
+ $this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException');
$routes = $this->getRoutes('test', new Route('/testing/{foo}', [], ['foo' => '1|2']));
$this->getGenerator($routes)->generate('test', ['foo' => '0'], UrlGeneratorInterface::ABSOLUTE_URL);
}
@@ -327,29 +315,23 @@ class UrlGeneratorTest extends TestCase
$this->assertSame('/app.php/testing/bar', $generator->generate('test', ['foo' => 'bar']));
}
- /**
- * @expectedException \Symfony\Component\Routing\Exception\InvalidParameterException
- */
public function testGenerateForRouteWithInvalidMandatoryParameter()
{
+ $this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException');
$routes = $this->getRoutes('test', new Route('/testing/{foo}', [], ['foo' => 'd+']));
$this->getGenerator($routes)->generate('test', ['foo' => 'bar'], UrlGeneratorInterface::ABSOLUTE_URL);
}
- /**
- * @expectedException \Symfony\Component\Routing\Exception\InvalidParameterException
- */
public function testGenerateForRouteWithInvalidUtf8Parameter()
{
+ $this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException');
$routes = $this->getRoutes('test', new Route('/testing/{foo}', [], ['foo' => '\pL+'], ['utf8' => true]));
$this->getGenerator($routes)->generate('test', ['foo' => 'abc123'], UrlGeneratorInterface::ABSOLUTE_URL);
}
- /**
- * @expectedException \Symfony\Component\Routing\Exception\InvalidParameterException
- */
public function testRequiredParamAndEmptyPassed()
{
+ $this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException');
$routes = $this->getRoutes('test', new Route('/{slug}', [], ['slug' => '.+']));
$this->getGenerator($routes)->generate('test', ['slug' => '']);
}
@@ -509,31 +491,25 @@ class UrlGeneratorTest extends TestCase
$this->assertSame('/app.php/index.mobile.html', $generator->generate('test', ['page' => 'index']));
}
- /**
- * @expectedException \Symfony\Component\Routing\Exception\MissingMandatoryParametersException
- */
public function testImportantVariableWithNoDefault()
{
+ $this->expectException('Symfony\Component\Routing\Exception\MissingMandatoryParametersException');
$routes = $this->getRoutes('test', new Route('/{page}.{!_format}'));
$generator = $this->getGenerator($routes);
$generator->generate('test', ['page' => 'index']);
}
- /**
- * @expectedException \Symfony\Component\Routing\Exception\InvalidParameterException
- */
public function testDefaultRequirementOfVariableDisallowsSlash()
{
+ $this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException');
$routes = $this->getRoutes('test', new Route('/{page}.{_format}'));
$this->getGenerator($routes)->generate('test', ['page' => 'index', '_format' => 'sl/ash']);
}
- /**
- * @expectedException \Symfony\Component\Routing\Exception\InvalidParameterException
- */
public function testDefaultRequirementOfVariableDisallowsNextSeparator()
{
+ $this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException');
$routes = $this->getRoutes('test', new Route('/{page}.{_format}'));
$this->getGenerator($routes)->generate('test', ['page' => 'do.t', '_format' => 'html']);
}
@@ -559,29 +535,23 @@ class UrlGeneratorTest extends TestCase
$this->assertEquals('http://fr.example.com/app.php/Fabien', $this->getGenerator($routes, ['host' => 'fr.example.com'])->generate('test', ['name' => 'Fabien', 'locale' => 'fr'], UrlGeneratorInterface::ABSOLUTE_URL));
}
- /**
- * @expectedException \Symfony\Component\Routing\Exception\InvalidParameterException
- */
public function testUrlWithInvalidParameterInHost()
{
+ $this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException');
$routes = $this->getRoutes('test', new Route('/', [], ['foo' => 'bar'], [], '{foo}.example.com'));
$this->getGenerator($routes)->generate('test', ['foo' => 'baz'], UrlGeneratorInterface::ABSOLUTE_PATH);
}
- /**
- * @expectedException \Symfony\Component\Routing\Exception\InvalidParameterException
- */
public function testUrlWithInvalidParameterInHostWhenParamHasADefaultValue()
{
+ $this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException');
$routes = $this->getRoutes('test', new Route('/', ['foo' => 'bar'], ['foo' => 'bar'], [], '{foo}.example.com'));
$this->getGenerator($routes)->generate('test', ['foo' => 'baz'], UrlGeneratorInterface::ABSOLUTE_PATH);
}
- /**
- * @expectedException \Symfony\Component\Routing\Exception\InvalidParameterException
- */
public function testUrlWithInvalidParameterEqualsDefaultValueInHost()
{
+ $this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException');
$routes = $this->getRoutes('test', new Route('/', ['foo' => 'baz'], ['foo' => 'bar'], [], '{foo}.example.com'));
$this->getGenerator($routes)->generate('test', ['foo' => 'baz'], UrlGeneratorInterface::ABSOLUTE_PATH);
}
diff --git a/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php
index e86cb26cc7..0d2c99fea5 100644
--- a/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php
+++ b/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php
@@ -93,12 +93,11 @@ class AnnotationClassLoaderTest extends AbstractAnnotationLoaderTest
$this->assertEquals('/path', $routes->get('action')->getPath());
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage A placeholder name must be a string (0 given). Did you forget to specify the placeholder key for the requirement "foo"
- */
public function testRequirementsWithoutPlaceholderName()
{
+ $this->expectException(\InvalidArgumentException::class);
+ $this->expectExceptionMessage('A placeholder name must be a string (0 given). Did you forget to specify the placeholder key for the requirement "foo"');
+
$this->loader->load(RequirementsWithoutPlaceholderNameController::class);
}
diff --git a/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php
index 3981b9377e..3ef7b7c157 100644
--- a/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php
+++ b/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php
@@ -45,12 +45,10 @@ class AnnotationFileLoaderTest extends AbstractAnnotationLoaderTest
$this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/FooTrait.php');
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage Did you forgot to add the "expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('Did you forgot to add the "loader->load(__DIR__.'/../Fixtures/OtherAnnotatedClasses/NoStartTagClass.php');
}
diff --git a/src/Symfony/Component/Routing/Tests/Loader/ObjectLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/ObjectLoaderTest.php
index 1267f540d0..bf94ef34ae 100644
--- a/src/Symfony/Component/Routing/Tests/Loader/ObjectLoaderTest.php
+++ b/src/Symfony/Component/Routing/Tests/Loader/ObjectLoaderTest.php
@@ -41,11 +41,11 @@ class ObjectLoaderTest extends TestCase
}
/**
- * @expectedException \InvalidArgumentException
* @dataProvider getBadResourceStrings
*/
public function testExceptionWithoutSyntax(string $resourceString): void
{
+ $this->expectException('InvalidArgumentException');
$loader = new TestObjectLoader();
$loader->load($resourceString);
}
@@ -62,31 +62,25 @@ class ObjectLoaderTest extends TestCase
];
}
- /**
- * @expectedException \LogicException
- */
public function testExceptionOnNoObjectReturned()
{
+ $this->expectException('LogicException');
$loader = new TestObjectLoader();
$loader->loaderMap = ['my_service' => 'NOT_AN_OBJECT'];
$loader->load('my_service::method');
}
- /**
- * @expectedException \BadMethodCallException
- */
public function testExceptionOnBadMethod()
{
+ $this->expectException('BadMethodCallException');
$loader = new TestObjectLoader();
$loader->loaderMap = ['my_service' => new \stdClass()];
$loader->load('my_service::method');
}
- /**
- * @expectedException \LogicException
- */
public function testExceptionOnMethodNotReturningCollection()
{
+ $this->expectException('LogicException');
$service = $this->getMockBuilder('stdClass')
->setMethods(['loadRoutes'])
->getMock();
diff --git a/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php
index da86e6308c..ff2f2f8add 100644
--- a/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php
+++ b/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\Routing\Tests\Loader;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\Routing\Loader\XmlFileLoader;
@@ -21,6 +22,8 @@ use Symfony\Component\Routing\Tests\Fixtures\CustomXmlFileLoader;
class XmlFileLoaderTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testSupports()
{
$loader = new XmlFileLoader($this->getMockBuilder('Symfony\Component\Config\FileLocator')->getMock());
@@ -201,21 +204,21 @@ class XmlFileLoaderTest extends TestCase
}
/**
- * @expectedException \InvalidArgumentException
* @dataProvider getPathsToInvalidFiles
*/
public function testLoadThrowsExceptionWithInvalidFile($filePath)
{
+ $this->expectException('InvalidArgumentException');
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
$loader->load($filePath);
}
/**
- * @expectedException \InvalidArgumentException
* @dataProvider getPathsToInvalidFiles
*/
public function testLoadThrowsExceptionWithInvalidFileEvenWithoutSchemaValidation($filePath)
{
+ $this->expectException('InvalidArgumentException');
$loader = new CustomXmlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
$loader->load($filePath);
}
@@ -225,12 +228,10 @@ class XmlFileLoaderTest extends TestCase
return [['nonvalidnode.xml'], ['nonvalidroute.xml'], ['nonvalid.xml'], ['missing_id.xml'], ['missing_path.xml']];
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage Document types are not allowed.
- */
public function testDocTypeIsNotAllowed()
{
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('Document types are not allowed.');
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
$loader->load('withdoctype.xml');
}
@@ -435,12 +436,10 @@ class XmlFileLoaderTest extends TestCase
$this->assertSame('AppBundle:Blog:list', $route->getDefault('_controller'));
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessageRegExp /The routing file "[^"]*" must not specify both the "controller" attribute and the defaults key "_controller" for "app_blog"/
- */
public function testOverrideControllerInDefaults()
{
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessageRegExp('/The routing file "[^"]*" must not specify both the "controller" attribute and the defaults key "_controller" for "app_blog"/');
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures/controller']));
$loader->load('override_defaults.xml');
}
@@ -469,12 +468,10 @@ class XmlFileLoaderTest extends TestCase
yield ['import__controller.xml'];
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessageRegExp /The routing file "[^"]*" must not specify both the "controller" attribute and the defaults key "_controller" for the "import" tag/
- */
public function testImportWithOverriddenController()
{
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessageRegExp('/The routing file "[^"]*" must not specify both the "controller" attribute and the defaults key "_controller" for the "import" tag/');
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures/controller']));
$loader->load('import_override_defaults.xml');
}
diff --git a/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php
index ce908f828c..7aa48fc74f 100644
--- a/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php
+++ b/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\Routing\Tests\Loader;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\Routing\Loader\YamlFileLoader;
@@ -20,6 +21,8 @@ use Symfony\Component\Routing\RouteCollection;
class YamlFileLoaderTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testSupports()
{
$loader = new YamlFileLoader($this->getMockBuilder('Symfony\Component\Config\FileLocator')->getMock());
@@ -43,11 +46,11 @@ class YamlFileLoaderTest extends TestCase
}
/**
- * @expectedException \InvalidArgumentException
* @dataProvider getPathsToInvalidFiles
*/
public function testLoadThrowsExceptionWithInvalidFile($filePath)
{
+ $this->expectException('InvalidArgumentException');
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
$loader->load($filePath);
}
@@ -141,12 +144,10 @@ class YamlFileLoaderTest extends TestCase
$this->assertSame('AppBundle:Blog:list', $route->getDefault('_controller'));
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessageRegExp /The routing file "[^"]*" must not specify both the "controller" key and the defaults key "_controller" for "app_blog"/
- */
public function testOverrideControllerInDefaults()
{
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessageRegExp('/The routing file "[^"]*" must not specify both the "controller" key and the defaults key "_controller" for "app_blog"/');
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures/controller']));
$loader->load('override_defaults.yml');
}
@@ -175,12 +176,10 @@ class YamlFileLoaderTest extends TestCase
yield ['import__controller.yml'];
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessageRegExp /The routing file "[^"]*" must not specify both the "controller" key and the defaults key "_controller" for "_static"/
- */
public function testImportWithOverriddenController()
{
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessageRegExp('/The routing file "[^"]*" must not specify both the "controller" key and the defaults key "_controller" for "_static"/');
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures/controller']));
$loader->load('import_override_defaults.yml');
}
@@ -381,12 +380,11 @@ class YamlFileLoaderTest extends TestCase
$this->assertEquals('/no-slash', $routeCollection->get('b_app_homepage')->getPath());
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage A placeholder name must be a string (0 given). Did you forget to specify the placeholder key for the requirement "\d+" of route "foo"
- */
public function testRequirementsWithoutPlaceholderName()
{
+ $this->expectException(\InvalidArgumentException::class);
+ $this->expectExceptionMessage('A placeholder name must be a string (0 given). Did you forget to specify the placeholder key for the requirement "\\d+" of route "foo"');
+
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
$loader->load('requirements_without_placeholder_name.yml');
}
diff --git a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/CompiledUrlMatcherDumperTest.php b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/CompiledUrlMatcherDumperTest.php
index e0e7018cc3..c90c448f95 100644
--- a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/CompiledUrlMatcherDumperTest.php
+++ b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/CompiledUrlMatcherDumperTest.php
@@ -474,12 +474,10 @@ class CompiledUrlMatcherDumperTest extends TestCase
->getMock();
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage Symfony\Component\Routing\Route cannot contain objects
- */
public function testGenerateDumperMatcherWithObject()
{
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('Symfony\Component\Routing\Route cannot contain objects');
$routeCollection = new RouteCollection();
$routeCollection->add('_', new Route('/', [new \stdClass()]));
$dumper = new CompiledUrlMatcherDumper($routeCollection);
diff --git a/src/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php b/src/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php
index 426958e07e..e3577045b8 100644
--- a/src/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php
+++ b/src/Symfony/Component/Routing/Tests/Matcher/RedirectableUrlMatcherTest.php
@@ -11,12 +11,15 @@
namespace Symfony\Component\Routing\Tests\Matcher;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
class RedirectableUrlMatcherTest extends UrlMatcherTest
{
+ use ForwardCompatTestTrait;
+
public function testMissingTrailingSlash()
{
$coll = new RouteCollection();
@@ -37,11 +40,9 @@ class RedirectableUrlMatcherTest extends UrlMatcherTest
$matcher->match('/foo/');
}
- /**
- * @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException
- */
public function testRedirectWhenNoSlashForNonSafeMethod()
{
+ $this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException');
$coll = new RouteCollection();
$coll->add('foo', new Route('/foo/'));
diff --git a/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php b/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php
index 3897ee4a65..4c9206a6fa 100644
--- a/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php
+++ b/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php
@@ -199,22 +199,19 @@ class UrlMatcherTest extends TestCase
$this->assertEquals(['_route' => 'index', '_format' => 'xml'], $matcher->match('/index.xml'));
}
- /**
- * @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException
- */
public function testShortPathDoesNotMatchImportantVariable()
{
+ $this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException');
+
$collection = new RouteCollection();
$collection->add('index', new Route('/index.{!_format}', ['_format' => 'xml']));
$this->getUrlMatcher($collection)->match('/index');
}
- /**
- * @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException
- */
public function testTrailingEncodedNewlineIsNotOverlooked()
{
+ $this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException');
$collection = new RouteCollection();
$collection->add('foo', new Route('/foo'));
@@ -361,11 +358,9 @@ class UrlMatcherTest extends TestCase
$this->assertEquals(['page' => 'index', '_format' => 'mobile.html', '_route' => 'test'], $matcher->match('/index.mobile.html'));
}
- /**
- * @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException
- */
public function testDefaultRequirementOfVariableDisallowsSlash()
{
+ $this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException');
$coll = new RouteCollection();
$coll->add('test', new Route('/{page}.{_format}'));
$matcher = $this->getUrlMatcher($coll);
@@ -373,11 +368,9 @@ class UrlMatcherTest extends TestCase
$matcher->match('/index.sl/ash');
}
- /**
- * @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException
- */
public function testDefaultRequirementOfVariableDisallowsNextSeparator()
{
+ $this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException');
$coll = new RouteCollection();
$coll->add('test', new Route('/{page}.{_format}', [], ['_format' => 'html|xml']));
$matcher = $this->getUrlMatcher($coll);
@@ -385,11 +378,9 @@ class UrlMatcherTest extends TestCase
$matcher->match('/do.t.html');
}
- /**
- * @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException
- */
public function testMissingTrailingSlash()
{
+ $this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException');
$coll = new RouteCollection();
$coll->add('foo', new Route('/foo/'));
@@ -397,11 +388,9 @@ class UrlMatcherTest extends TestCase
$matcher->match('/foo');
}
- /**
- * @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException
- */
public function testExtraTrailingSlash()
{
+ $this->getExpectedException() ?: $this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException');
$coll = new RouteCollection();
$coll->add('foo', new Route('/foo'));
@@ -409,11 +398,9 @@ class UrlMatcherTest extends TestCase
$matcher->match('/foo/');
}
- /**
- * @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException
- */
public function testMissingTrailingSlashForNonSafeMethod()
{
+ $this->getExpectedException() ?: $this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException');
$coll = new RouteCollection();
$coll->add('foo', new Route('/foo/'));
@@ -423,11 +410,9 @@ class UrlMatcherTest extends TestCase
$matcher->match('/foo');
}
- /**
- * @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException
- */
public function testExtraTrailingSlashForNonSafeMethod()
{
+ $this->getExpectedException() ?: $this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException');
$coll = new RouteCollection();
$coll->add('foo', new Route('/foo'));
@@ -437,22 +422,18 @@ class UrlMatcherTest extends TestCase
$matcher->match('/foo/');
}
- /**
- * @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException
- */
public function testSchemeRequirement()
{
+ $this->getExpectedException() ?: $this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException');
$coll = new RouteCollection();
$coll->add('foo', new Route('/foo', [], [], [], '', ['https']));
$matcher = $this->getUrlMatcher($coll);
$matcher->match('/foo');
}
- /**
- * @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException
- */
public function testSchemeRequirementForNonSafeMethod()
{
+ $this->getExpectedException() ?: $this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException');
$coll = new RouteCollection();
$coll->add('foo', new Route('/foo', [], [], [], '', ['https']));
@@ -471,11 +452,9 @@ class UrlMatcherTest extends TestCase
$this->assertEquals(['_route' => 'http_route'], $matcher->match('/'));
}
- /**
- * @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException
- */
public function testCondition()
{
+ $this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException');
$coll = new RouteCollection();
$route = new Route('/foo');
$route->setCondition('context.getMethod() == "POST"');
@@ -680,11 +659,9 @@ class UrlMatcherTest extends TestCase
$this->assertEquals(['foo' => 'foo', '_route' => 'bar'], $matcher->match('/foo'));
}
- /**
- * @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException
- */
public function testWithOutHostHostDoesNotMatch()
{
+ $this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException');
$coll = new RouteCollection();
$coll->add('foo', new Route('/foo/{foo}', [], [], [], '{locale}.example.com'));
@@ -692,11 +669,9 @@ class UrlMatcherTest extends TestCase
$matcher->match('/foo/bar');
}
- /**
- * @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException
- */
public function testPathIsCaseSensitive()
{
+ $this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException');
$coll = new RouteCollection();
$coll->add('foo', new Route('/locale', [], ['locale' => 'EN|FR|DE']));
@@ -713,11 +688,9 @@ class UrlMatcherTest extends TestCase
$this->assertEquals(['_route' => 'foo', 'locale' => 'en'], $matcher->match('/'));
}
- /**
- * @expectedException \Symfony\Component\Routing\Exception\NoConfigurationException
- */
public function testNoConfiguration()
{
+ $this->expectException('Symfony\Component\Routing\Exception\NoConfigurationException');
$coll = new RouteCollection();
$matcher = $this->getUrlMatcher($coll);
@@ -748,12 +721,10 @@ class UrlMatcherTest extends TestCase
$this->assertEquals(['_route' => 'buz'], $matcher->match('/prefix/buz'));
}
- /**
- * @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException
- * @expectedExceptionMessage No routes found for "/".
- */
public function testSchemeAndMethodMismatch()
{
+ $this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException');
+ $this->expectExceptionMessage('No routes found for "/".');
$coll = new RouteCollection();
$coll->add('foo', new Route('/', [], [], [], null, ['https'], ['POST']));
diff --git a/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php b/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php
index 11d9453e09..3ce024751c 100644
--- a/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php
+++ b/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\Routing\Tests;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\Routing\Loader\YamlFileLoader;
@@ -21,6 +22,8 @@ use Symfony\Component\Routing\RouteCollectionBuilder;
class RouteCollectionBuilderTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testImport()
{
$resolvedLoader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
@@ -75,11 +78,9 @@ class RouteCollectionBuilderTest extends TestCase
$this->assertCount(1, $routeCollection->getResources());
}
- /**
- * @expectedException \BadMethodCallException
- */
public function testImportWithoutLoaderThrowsException()
{
+ $this->expectException('BadMethodCallException');
$collectionBuilder = new RouteCollectionBuilder();
$collectionBuilder->import('routing.yml');
}
diff --git a/src/Symfony/Component/Routing/Tests/RouteCompilerTest.php b/src/Symfony/Component/Routing/Tests/RouteCompilerTest.php
index 705b5a0616..2387619a05 100644
--- a/src/Symfony/Component/Routing/Tests/RouteCompilerTest.php
+++ b/src/Symfony/Component/Routing/Tests/RouteCompilerTest.php
@@ -12,11 +12,14 @@
namespace Symfony\Component\Routing\Tests;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCompiler;
class RouteCompilerTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
/**
* @dataProvider provideCompileData
*/
@@ -185,10 +188,10 @@ class RouteCompilerTest extends TestCase
/**
* @dataProvider provideCompileImplicitUtf8Data
- * @expectedException \LogicException
*/
public function testCompileImplicitUtf8Data($name, $arguments, $prefix, $regex, $variables, $tokens, $deprecationType)
{
+ $this->expectException('LogicException');
$r = new \ReflectionClass('Symfony\\Component\\Routing\\Route');
$route = $r->newInstanceArgs($arguments);
@@ -242,41 +245,33 @@ class RouteCompilerTest extends TestCase
];
}
- /**
- * @expectedException \LogicException
- */
public function testRouteWithSameVariableTwice()
{
+ $this->expectException('LogicException');
$route = new Route('/{name}/{name}');
$compiled = $route->compile();
}
- /**
- * @expectedException \LogicException
- */
public function testRouteCharsetMismatch()
{
+ $this->expectException('LogicException');
$route = new Route("/\xE9/{bar}", [], ['bar' => '.'], ['utf8' => true]);
$compiled = $route->compile();
}
- /**
- * @expectedException \LogicException
- */
public function testRequirementCharsetMismatch()
{
+ $this->expectException('LogicException');
$route = new Route('/foo/{bar}', [], ['bar' => "\xE9"], ['utf8' => true]);
$compiled = $route->compile();
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testRouteWithFragmentAsPathParameter()
{
+ $this->expectException('InvalidArgumentException');
$route = new Route('/{_fragment}');
$compiled = $route->compile();
@@ -284,10 +279,10 @@ class RouteCompilerTest extends TestCase
/**
* @dataProvider getVariableNamesStartingWithADigit
- * @expectedException \DomainException
*/
public function testRouteWithVariableNameStartingWithADigit($name)
{
+ $this->expectException('DomainException');
$route = new Route('/{'.$name.'}');
$route->compile();
}
@@ -372,11 +367,9 @@ class RouteCompilerTest extends TestCase
];
}
- /**
- * @expectedException \DomainException
- */
public function testRouteWithTooLongVariableName()
{
+ $this->expectException('DomainException');
$route = new Route(sprintf('/{%s}', str_repeat('a', RouteCompiler::VARIABLE_MAXIMUM_LENGTH + 1)));
$route->compile();
}
diff --git a/src/Symfony/Component/Routing/Tests/RouteTest.php b/src/Symfony/Component/Routing/Tests/RouteTest.php
index 46edb55896..3963afd162 100644
--- a/src/Symfony/Component/Routing/Tests/RouteTest.php
+++ b/src/Symfony/Component/Routing/Tests/RouteTest.php
@@ -12,10 +12,13 @@
namespace Symfony\Component\Routing\Tests;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Routing\Route;
class RouteTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testConstructor()
{
$route = new Route('/{foo}', ['foo' => 'bar'], ['foo' => '\d+'], ['foo' => 'bar'], '{locale}.example.com');
@@ -124,10 +127,10 @@ class RouteTest extends TestCase
/**
* @dataProvider getInvalidRequirements
- * @expectedException \InvalidArgumentException
*/
public function testSetInvalidRequirement($req)
{
+ $this->expectException('InvalidArgumentException');
$route = new Route('/{foo}');
$route->setRequirement('foo', $req);
}
diff --git a/src/Symfony/Component/Routing/Tests/RouterTest.php b/src/Symfony/Component/Routing/Tests/RouterTest.php
index 55f09da4d4..fd6fafd719 100644
--- a/src/Symfony/Component/Routing/Tests/RouterTest.php
+++ b/src/Symfony/Component/Routing/Tests/RouterTest.php
@@ -44,12 +44,10 @@ class RouterTest extends TestCase
$this->assertSame('ResourceType', $this->router->getOption('resource_type'));
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage The Router does not support the following options: "option_foo", "option_bar"
- */
public function testSetOptionsWithUnsupportedOptions()
{
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('The Router does not support the following options: "option_foo", "option_bar"');
$this->router->setOptions([
'cache_dir' => './cache',
'option_foo' => true,
@@ -65,21 +63,17 @@ class RouterTest extends TestCase
$this->assertSame('./cache', $this->router->getOption('cache_dir'));
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage The Router does not support the "option_foo" option
- */
public function testSetOptionWithUnsupportedOption()
{
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('The Router does not support the "option_foo" option');
$this->router->setOption('option_foo', true);
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage The Router does not support the "option_foo" option
- */
public function testGetOptionWithUnsupportedOption()
{
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('The Router does not support the "option_foo" option');
$this->router->getOption('option_foo', true);
}
diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationProviderManagerTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationProviderManagerTest.php
index deb05918f4..2fd9217395 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationProviderManagerTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationProviderManagerTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\Security\Core\Tests\Authentication;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
@@ -24,19 +25,17 @@ use Symfony\Component\Security\Core\Exception\ProviderNotFoundException;
class AuthenticationProviderManagerTest extends TestCase
{
- /**
- * @expectedException \InvalidArgumentException
- */
+ use ForwardCompatTestTrait;
+
public function testAuthenticateWithoutProviders()
{
+ $this->expectException('InvalidArgumentException');
new AuthenticationProviderManager([]);
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testAuthenticateWithProvidersWithIncorrectInterface()
{
+ $this->expectException('InvalidArgumentException');
(new AuthenticationProviderManager([
new \stdClass(),
]))->authenticate($this->getMockBuilder(TokenInterface::class)->getMock());
diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php
index a888d2bf81..613d28382d 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php
@@ -12,10 +12,13 @@
namespace Symfony\Component\Security\Core\Tests\Authentication\Provider;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Security\Core\Authentication\Provider\AnonymousAuthenticationProvider;
class AnonymousAuthenticationProviderTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testSupports()
{
$provider = $this->getProvider('foo');
@@ -24,22 +27,18 @@ class AnonymousAuthenticationProviderTest extends TestCase
$this->assertFalse($provider->supports($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()));
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\AuthenticationException
- * @expectedExceptionMessage The token is not supported by this authentication provider.
- */
public function testAuthenticateWhenTokenIsNotSupported()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationException');
+ $this->expectExceptionMessage('The token is not supported by this authentication provider.');
$provider = $this->getProvider('foo');
$provider->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
- */
public function testAuthenticateWhenSecretIsNotValid()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException');
$provider = $this->getProvider('foo');
$provider->authenticate($this->getSupportedToken('bar'));
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 4949ce8a76..eca27b56af 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\Security\Core\Tests\Authentication\Provider;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Security\Core\Authentication\Provider\DaoAuthenticationProvider;
use Symfony\Component\Security\Core\Encoder\PlaintextPasswordEncoder;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
@@ -19,11 +20,11 @@ use Symfony\Component\Security\Core\User\UserInterface;
class DaoAuthenticationProviderTest extends TestCase
{
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\AuthenticationServiceException
- */
+ use ForwardCompatTestTrait;
+
public function testRetrieveUserWhenProviderDoesNotReturnAnUserInterface()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationServiceException');
$provider = $this->getProvider('fabien');
$method = new \ReflectionMethod($provider, 'retrieveUser');
$method->setAccessible(true);
@@ -31,11 +32,9 @@ class DaoAuthenticationProviderTest extends TestCase
$method->invoke($provider, 'fabien', $this->getSupportedToken());
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\UsernameNotFoundException
- */
public function testRetrieveUserWhenUsernameIsNotFound()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\UsernameNotFoundException');
$userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock();
$userProvider->expects($this->once())
->method('loadUserByUsername')
@@ -49,11 +48,9 @@ class DaoAuthenticationProviderTest extends TestCase
$method->invoke($provider, 'fabien', $this->getSupportedToken());
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\AuthenticationServiceException
- */
public function testRetrieveUserWhenAnExceptionOccurs()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationServiceException');
$userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock();
$userProvider->expects($this->once())
->method('loadUserByUsername')
@@ -106,11 +103,9 @@ class DaoAuthenticationProviderTest extends TestCase
$this->assertSame($user, $method->invoke($provider, 'fabien', $this->getSupportedToken()));
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
- */
public function testCheckAuthenticationWhenCredentialsAreEmpty()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException');
$encoder = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface')->getMock();
$encoder
->expects($this->never())
@@ -154,11 +149,9 @@ class DaoAuthenticationProviderTest extends TestCase
$method->invoke($provider, new TestUser(), $token);
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
- */
public function testCheckAuthenticationWhenCredentialsAreNotValid()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException');
$encoder = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface')->getMock();
$encoder->expects($this->once())
->method('isPasswordValid')
@@ -178,11 +171,9 @@ class DaoAuthenticationProviderTest extends TestCase
$method->invoke($provider, new TestUser(), $token);
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
- */
public function testCheckAuthenticationDoesNotReauthenticateWhenPasswordHasChanged()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException');
$user = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock();
$user->expects($this->once())
->method('getPassword')
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 438b575cc9..fadaa75aa7 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\Security\Core\Tests\Authentication\Provider;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Ldap\Adapter\CollectionInterface;
use Symfony\Component\Ldap\Adapter\QueryInterface;
use Symfony\Component\Ldap\Entry;
@@ -28,12 +29,12 @@ use Symfony\Component\Security\Core\User\UserProviderInterface;
*/
class LdapBindAuthenticationProviderTest extends TestCase
{
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
- * @expectedExceptionMessage The presented password must not be empty.
- */
+ use ForwardCompatTestTrait;
+
public function testEmptyPasswordShouldThrowAnException()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException');
+ $this->expectExceptionMessage('The presented password must not be empty.');
$userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock();
$ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
@@ -45,12 +46,10 @@ class LdapBindAuthenticationProviderTest extends TestCase
$reflection->invoke($provider, new User('foo', null), new UsernamePasswordToken('foo', '', 'key'));
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
- * @expectedExceptionMessage The presented password must not be empty.
- */
public function testNullPasswordShouldThrowAnException()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException');
+ $this->expectExceptionMessage('The presented password must not be empty.');
$userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock();
$ldap = $this->getMockBuilder('Symfony\Component\Ldap\LdapInterface')->getMock();
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
@@ -62,12 +61,10 @@ class LdapBindAuthenticationProviderTest extends TestCase
$reflection->invoke($provider, new User('foo', null), new UsernamePasswordToken('foo', null, 'key'));
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
- * @expectedExceptionMessage The presented password is invalid.
- */
public function testBindFailureShouldThrowAnException()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException');
+ $this->expectExceptionMessage('The presented password is invalid.');
$userProvider = $this->getMockBuilder(UserProviderInterface::class)->getMock();
$ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
$ldap
@@ -184,12 +181,10 @@ class LdapBindAuthenticationProviderTest extends TestCase
$reflection->invoke($provider, new User('foo', null), new UsernamePasswordToken('foo', 'bar', 'key'));
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
- * @expectedExceptionMessage The presented username is invalid.
- */
public function testEmptyQueryResultShouldThrowAnException()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException');
+ $this->expectExceptionMessage('The presented username is invalid.');
$userProvider = $this->getMockBuilder(UserProviderInterface::class)->getMock();
$collection = $this->getMockBuilder(CollectionInterface::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 3e452cfed8..a79b380263 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php
@@ -12,11 +12,14 @@
namespace Symfony\Component\Security\Core\Tests\Authentication\Provider;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Security\Core\Authentication\Provider\PreAuthenticatedAuthenticationProvider;
use Symfony\Component\Security\Core\Exception\LockedException;
class PreAuthenticatedAuthenticationProviderTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testSupports()
{
$provider = $this->getProvider();
@@ -36,22 +39,18 @@ class PreAuthenticatedAuthenticationProviderTest extends TestCase
$this->assertFalse($provider->supports($token));
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\AuthenticationException
- * @expectedExceptionMessage The token is not supported by this authentication provider.
- */
public function testAuthenticateWhenTokenIsNotSupported()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationException');
+ $this->expectExceptionMessage('The token is not supported by this authentication provider.');
$provider = $this->getProvider();
$provider->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
- */
public function testAuthenticateWhenNoUserIsSet()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException');
$provider = $this->getProvider();
$provider->authenticate($this->getSupportedToken(''));
}
@@ -75,11 +74,9 @@ class PreAuthenticatedAuthenticationProviderTest extends TestCase
$this->assertSame($user, $token->getUser());
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\LockedException
- */
public function testAuthenticateWhenUserCheckerThrowsException()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\LockedException');
$user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
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 da3129c0e0..eff06150b2 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php
@@ -12,11 +12,14 @@
namespace Symfony\Component\Security\Core\Tests\Authentication\Provider;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Security\Core\Authentication\Provider\RememberMeAuthenticationProvider;
use Symfony\Component\Security\Core\Exception\DisabledException;
class RememberMeAuthenticationProviderTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testSupports()
{
$provider = $this->getProvider();
@@ -25,34 +28,28 @@ class RememberMeAuthenticationProviderTest extends TestCase
$this->assertFalse($provider->supports($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()));
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\AuthenticationException
- * @expectedExceptionMessage The token is not supported by this authentication provider.
- */
public function testAuthenticateWhenTokenIsNotSupported()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationException');
+ $this->expectExceptionMessage('The token is not supported by this authentication provider.');
$provider = $this->getProvider();
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$provider->authenticate($token);
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
- */
public function testAuthenticateWhenSecretsDoNotMatch()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException');
$provider = $this->getProvider(null, 'secret1');
$token = $this->getSupportedToken(null, 'secret2');
$provider->authenticate($token);
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\DisabledException
- */
public function testAuthenticateWhenPreChecksFails()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\DisabledException');
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
$userChecker->expects($this->once())
->method('checkPreAuth')
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 f00d71241e..d89ea088ba 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\Security\Core\Tests\Authentication\Provider;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Security\Core\Authentication\Token\SwitchUserToken;
use Symfony\Component\Security\Core\Exception\AccountExpiredException;
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
@@ -20,6 +21,8 @@ use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
class UserAuthenticationProviderTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testSupports()
{
$provider = $this->getProvider();
@@ -28,22 +31,18 @@ class UserAuthenticationProviderTest extends TestCase
$this->assertFalse($provider->supports($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()));
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\AuthenticationException
- * @expectedExceptionMessage The token is not supported by this authentication provider.
- */
public function testAuthenticateWhenTokenIsNotSupported()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationException');
+ $this->expectExceptionMessage('The token is not supported by this authentication provider.');
$provider = $this->getProvider();
$provider->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\UsernameNotFoundException
- */
public function testAuthenticateWhenUsernameIsNotFound()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\UsernameNotFoundException');
$provider = $this->getProvider(false, false);
$provider->expects($this->once())
->method('retrieveUser')
@@ -53,11 +52,9 @@ class UserAuthenticationProviderTest extends TestCase
$provider->authenticate($this->getSupportedToken());
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
- */
public function testAuthenticateWhenUsernameIsNotFoundAndHideIsTrue()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException');
$provider = $this->getProvider(false, true);
$provider->expects($this->once())
->method('retrieveUser')
@@ -67,11 +64,9 @@ class UserAuthenticationProviderTest extends TestCase
$provider->authenticate($this->getSupportedToken());
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\AuthenticationServiceException
- */
public function testAuthenticateWhenProviderDoesNotReturnAnUserInterface()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationServiceException');
$provider = $this->getProvider(false, true);
$provider->expects($this->once())
->method('retrieveUser')
@@ -81,11 +76,9 @@ class UserAuthenticationProviderTest extends TestCase
$provider->authenticate($this->getSupportedToken());
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\CredentialsExpiredException
- */
public function testAuthenticateWhenPreChecksFails()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\CredentialsExpiredException');
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
$userChecker->expects($this->once())
->method('checkPreAuth')
@@ -101,11 +94,9 @@ class UserAuthenticationProviderTest extends TestCase
$provider->authenticate($this->getSupportedToken());
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\AccountExpiredException
- */
public function testAuthenticateWhenPostChecksFails()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\AccountExpiredException');
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
$userChecker->expects($this->once())
->method('checkPostAuth')
@@ -121,12 +112,10 @@ class UserAuthenticationProviderTest extends TestCase
$provider->authenticate($this->getSupportedToken());
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
- * @expectedExceptionMessage Bad credentials
- */
public function testAuthenticateWhenPostCheckAuthenticationFails()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException');
+ $this->expectExceptionMessage('Bad credentials');
$provider = $this->getProvider();
$provider->expects($this->once())
->method('retrieveUser')
@@ -140,12 +129,10 @@ class UserAuthenticationProviderTest extends TestCase
$provider->authenticate($this->getSupportedToken());
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
- * @expectedExceptionMessage Foo
- */
public function testAuthenticateWhenPostCheckAuthenticationFailsWithHideFalse()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException');
+ $this->expectExceptionMessage('Foo');
$provider = $this->getProvider(false, false);
$provider->expects($this->once())
->method('retrieveUser')
diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/RememberMe/InMemoryTokenProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/RememberMe/InMemoryTokenProviderTest.php
index 1413b6d402..62ace03633 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authentication/RememberMe/InMemoryTokenProviderTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authentication/RememberMe/InMemoryTokenProviderTest.php
@@ -12,11 +12,14 @@
namespace Symfony\Component\Security\Core\Tests\Authentication\RememberMe;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Security\Core\Authentication\RememberMe\InMemoryTokenProvider;
use Symfony\Component\Security\Core\Authentication\RememberMe\PersistentToken;
class InMemoryTokenProviderTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testCreateNewToken()
{
$provider = new InMemoryTokenProvider();
@@ -27,11 +30,9 @@ class InMemoryTokenProviderTest extends TestCase
$this->assertSame($provider->loadTokenBySeries('foo'), $token);
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\TokenNotFoundException
- */
public function testLoadTokenBySeriesThrowsNotFoundException()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\TokenNotFoundException');
$provider = new InMemoryTokenProvider();
$provider->loadTokenBySeries('foo');
}
@@ -49,11 +50,9 @@ class InMemoryTokenProviderTest extends TestCase
$this->assertSame($token->getLastUsed(), $lastUsed);
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\TokenNotFoundException
- */
public function testDeleteToken()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\TokenNotFoundException');
$provider = new InMemoryTokenProvider();
$token = new PersistentToken('foo', 'foo', 'foo', 'foo', new \DateTime());
diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php
index 4a56cf2881..5240d7bf21 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php
@@ -12,10 +12,13 @@
namespace Symfony\Component\Security\Core\Tests\Authentication\Token;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Security\Core\Authentication\Token\RememberMeToken;
class RememberMeTokenTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testConstructor()
{
$user = $this->getUser();
@@ -28,11 +31,9 @@ class RememberMeTokenTest extends TestCase
$this->assertTrue($token->isAuthenticated());
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testConstructorSecretCannotBeEmptyString()
{
+ $this->expectException('InvalidArgumentException');
new RememberMeToken(
$this->getUser(),
'',
diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/UsernamePasswordTokenTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/UsernamePasswordTokenTest.php
index ab0abaf653..acaadc07b6 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/UsernamePasswordTokenTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/UsernamePasswordTokenTest.php
@@ -12,10 +12,13 @@
namespace Symfony\Component\Security\Core\Tests\Authentication\Token;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
class UsernamePasswordTokenTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testConstructor()
{
$token = new UsernamePasswordToken('foo', 'bar', 'key');
@@ -27,11 +30,9 @@ class UsernamePasswordTokenTest extends TestCase
$this->assertEquals('key', $token->getProviderKey());
}
- /**
- * @expectedException \LogicException
- */
public function testSetAuthenticatedToTrue()
{
+ $this->expectException('LogicException');
$token = new UsernamePasswordToken('foo', 'bar', 'key');
$token->setAuthenticated(true);
}
diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php
index 690fcf70d5..5e6277dd6c 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php
@@ -20,11 +20,9 @@ class AccessDecisionManagerTest extends TestCase
{
use ForwardCompatTestTrait;
- /**
- * @expectedException \InvalidArgumentException
- */
public function testSetUnsupportedStrategy()
{
+ $this->expectException('InvalidArgumentException');
new AccessDecisionManager([$this->getVoter(VoterInterface::ACCESS_GRANTED)], 'fooBar');
}
diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php
index 843f5783f8..4a60dae421 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authorization/AuthorizationCheckerTest.php
@@ -70,11 +70,9 @@ class AuthorizationCheckerTest extends TestCase
$this->assertSame($newToken, $this->tokenStorage->getToken());
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException
- */
public function testVoteWithoutAuthenticationToken()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException');
$this->authorizationChecker->isGranted('ROLE_FOO');
}
diff --git a/src/Symfony/Component/Security/Core/Tests/Encoder/EncoderFactoryTest.php b/src/Symfony/Component/Security/Core/Tests/Encoder/EncoderFactoryTest.php
index ae8467af57..5fc489e426 100644
--- a/src/Symfony/Component/Security/Core/Tests/Encoder/EncoderFactoryTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Encoder/EncoderFactoryTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\Security\Core\Tests\Encoder;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Security\Core\Encoder\EncoderAwareInterface;
use Symfony\Component\Security\Core\Encoder\EncoderFactory;
use Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder;
@@ -20,6 +21,8 @@ use Symfony\Component\Security\Core\User\UserInterface;
class EncoderFactoryTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testGetEncoderWithMessageDigestEncoder()
{
$factory = new EncoderFactory(['Symfony\Component\Security\Core\User\UserInterface' => [
@@ -107,11 +110,9 @@ class EncoderFactoryTest extends TestCase
$this->assertEquals($expectedEncoder->encodePassword('foo', ''), $encoder->encodePassword('foo', ''));
}
- /**
- * @expectedException \RuntimeException
- */
public function testGetInvalidNamedEncoderForEncoderAware()
{
+ $this->expectException('RuntimeException');
$factory = new EncoderFactory([
'Symfony\Component\Security\Core\Tests\Encoder\EncAwareUser' => new MessageDigestPasswordEncoder('sha1'),
'encoder_name' => new MessageDigestPasswordEncoder('sha256'),
diff --git a/src/Symfony/Component/Security/Core/Tests/Encoder/MessageDigestPasswordEncoderTest.php b/src/Symfony/Component/Security/Core/Tests/Encoder/MessageDigestPasswordEncoderTest.php
index c449194f8d..50cd47bf0c 100644
--- a/src/Symfony/Component/Security/Core/Tests/Encoder/MessageDigestPasswordEncoderTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Encoder/MessageDigestPasswordEncoderTest.php
@@ -12,10 +12,13 @@
namespace Symfony\Component\Security\Core\Tests\Encoder;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder;
class MessageDigestPasswordEncoderTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testIsPasswordValid()
{
$encoder = new MessageDigestPasswordEncoder('sha256', false, 1);
@@ -35,20 +38,16 @@ class MessageDigestPasswordEncoderTest extends TestCase
$this->assertSame(hash('sha256', hash('sha256', 'password', true).'password'), $encoder->encodePassword('password', ''));
}
- /**
- * @expectedException \LogicException
- */
public function testEncodePasswordAlgorithmDoesNotExist()
{
+ $this->expectException('LogicException');
$encoder = new MessageDigestPasswordEncoder('foobar');
$encoder->encodePassword('password', '');
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
- */
public function testEncodePasswordLength()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException');
$encoder = new MessageDigestPasswordEncoder();
$encoder->encodePassword(str_repeat('a', 5000), 'salt');
diff --git a/src/Symfony/Component/Security/Core/Tests/Encoder/NativePasswordEncoderTest.php b/src/Symfony/Component/Security/Core/Tests/Encoder/NativePasswordEncoderTest.php
index 55e518b491..ae65f99764 100644
--- a/src/Symfony/Component/Security/Core/Tests/Encoder/NativePasswordEncoderTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Encoder/NativePasswordEncoderTest.php
@@ -19,19 +19,15 @@ use Symfony\Component\Security\Core\Encoder\NativePasswordEncoder;
*/
class NativePasswordEncoderTest extends TestCase
{
- /**
- * @expectedException \InvalidArgumentException
- */
public function testCostBelowRange()
{
+ $this->expectException('InvalidArgumentException');
new NativePasswordEncoder(null, null, 3);
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testCostAboveRange()
{
+ $this->expectException('InvalidArgumentException');
new NativePasswordEncoder(null, null, 32);
}
diff --git a/src/Symfony/Component/Security/Core/Tests/Encoder/Pbkdf2PasswordEncoderTest.php b/src/Symfony/Component/Security/Core/Tests/Encoder/Pbkdf2PasswordEncoderTest.php
index e65eef5bba..0795c4b5d6 100644
--- a/src/Symfony/Component/Security/Core/Tests/Encoder/Pbkdf2PasswordEncoderTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Encoder/Pbkdf2PasswordEncoderTest.php
@@ -12,10 +12,13 @@
namespace Symfony\Component\Security\Core\Tests\Encoder;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Security\Core\Encoder\Pbkdf2PasswordEncoder;
class Pbkdf2PasswordEncoderTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testIsPasswordValid()
{
$encoder = new Pbkdf2PasswordEncoder('sha256', false, 1, 40);
@@ -35,20 +38,16 @@ class Pbkdf2PasswordEncoderTest extends TestCase
$this->assertSame('8bc2f9167a81cdcfad1235cd9047f1136271c1f978fcfcb35e22dbeafa4634f6fd2214218ed63ebb', $encoder->encodePassword('password', ''));
}
- /**
- * @expectedException \LogicException
- */
public function testEncodePasswordAlgorithmDoesNotExist()
{
+ $this->expectException('LogicException');
$encoder = new Pbkdf2PasswordEncoder('foobar');
$encoder->encodePassword('password', '');
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
- */
public function testEncodePasswordLength()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException');
$encoder = new Pbkdf2PasswordEncoder('foobar');
$encoder->encodePassword(str_repeat('a', 5000), 'salt');
diff --git a/src/Symfony/Component/Security/Core/Tests/Encoder/PlaintextPasswordEncoderTest.php b/src/Symfony/Component/Security/Core/Tests/Encoder/PlaintextPasswordEncoderTest.php
index 1196651a86..1ef0e0c778 100644
--- a/src/Symfony/Component/Security/Core/Tests/Encoder/PlaintextPasswordEncoderTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Encoder/PlaintextPasswordEncoderTest.php
@@ -12,10 +12,13 @@
namespace Symfony\Component\Security\Core\Tests\Encoder;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Security\Core\Encoder\PlaintextPasswordEncoder;
class PlaintextPasswordEncoderTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testIsPasswordValid()
{
$encoder = new PlaintextPasswordEncoder();
@@ -38,11 +41,9 @@ class PlaintextPasswordEncoderTest extends TestCase
$this->assertSame('foo', $encoder->encodePassword('foo', ''));
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
- */
public function testEncodePasswordLength()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException');
$encoder = new PlaintextPasswordEncoder();
$encoder->encodePassword(str_repeat('a', 5000), 'salt');
diff --git a/src/Symfony/Component/Security/Core/Tests/Encoder/SodiumPasswordEncoderTest.php b/src/Symfony/Component/Security/Core/Tests/Encoder/SodiumPasswordEncoderTest.php
index cb0b336905..9075fc4e8a 100644
--- a/src/Symfony/Component/Security/Core/Tests/Encoder/SodiumPasswordEncoderTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Encoder/SodiumPasswordEncoderTest.php
@@ -37,11 +37,9 @@ class SodiumPasswordEncoderTest extends TestCase
$this->assertTrue($encoder->isPasswordValid('$2y$04$M8GDODMoGQLQRpkYCdoJh.lbiZPee3SZI32RcYK49XYTolDGwoRMm', 'abc', null));
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
- */
public function testEncodePasswordLength()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException');
$encoder = new SodiumPasswordEncoder();
$encoder->encodePassword(str_repeat('a', 4097), 'salt');
}
diff --git a/src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php b/src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php
index 05a7fbba19..6852273aef 100644
--- a/src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/User/ChainUserProviderTest.php
@@ -12,12 +12,15 @@
namespace Symfony\Component\Security\Core\Tests\User;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
use Symfony\Component\Security\Core\User\ChainUserProvider;
class ChainUserProviderTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testLoadUserByUsername()
{
$provider1 = $this->getProvider();
@@ -40,11 +43,9 @@ class ChainUserProviderTest extends TestCase
$this->assertSame($account, $provider->loadUserByUsername('foo'));
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\UsernameNotFoundException
- */
public function testLoadUserByUsernameThrowsUsernameNotFoundException()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\UsernameNotFoundException');
$provider1 = $this->getProvider();
$provider1
->expects($this->once())
@@ -105,11 +106,9 @@ class ChainUserProviderTest extends TestCase
$this->assertSame($account, $provider->refreshUser($this->getAccount()));
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\UnsupportedUserException
- */
public function testRefreshUserThrowsUnsupportedUserException()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\UnsupportedUserException');
$provider1 = $this->getProvider();
$provider1
->expects($this->once())
diff --git a/src/Symfony/Component/Security/Core/Tests/User/InMemoryUserProviderTest.php b/src/Symfony/Component/Security/Core/Tests/User/InMemoryUserProviderTest.php
index b1ff3b66e1..6b78260b09 100644
--- a/src/Symfony/Component/Security/Core/Tests/User/InMemoryUserProviderTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/User/InMemoryUserProviderTest.php
@@ -12,11 +12,14 @@
namespace Symfony\Component\Security\Core\Tests\User;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Security\Core\User\InMemoryUserProvider;
use Symfony\Component\Security\Core\User\User;
class InMemoryUserProviderTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testConstructor()
{
$provider = $this->createProvider();
@@ -63,21 +66,17 @@ class InMemoryUserProviderTest extends TestCase
$this->assertEquals('foo', $user->getPassword());
}
- /**
- * @expectedException \LogicException
- */
public function testCreateUserAlreadyExist()
{
+ $this->expectException('LogicException');
$provider = new InMemoryUserProvider();
$provider->createUser(new User('fabien', 'foo'));
$provider->createUser(new User('fabien', 'foo'));
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\UsernameNotFoundException
- */
public function testLoadUserByUsernameDoesNotExist()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\UsernameNotFoundException');
$provider = new InMemoryUserProvider();
$provider->loadUserByUsername('fabien');
}
diff --git a/src/Symfony/Component/Security/Core/Tests/User/LdapUserProviderTest.php b/src/Symfony/Component/Security/Core/Tests/User/LdapUserProviderTest.php
index bca36c7b7f..c232e96e01 100644
--- a/src/Symfony/Component/Security/Core/Tests/User/LdapUserProviderTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/User/LdapUserProviderTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\Security\Core\Tests\User;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Ldap\Adapter\CollectionInterface;
use Symfony\Component\Ldap\Adapter\QueryInterface;
use Symfony\Component\Ldap\Entry;
@@ -24,11 +25,11 @@ use Symfony\Component\Security\Core\User\LdapUserProvider;
*/
class LdapUserProviderTest extends TestCase
{
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\UsernameNotFoundException
- */
+ use ForwardCompatTestTrait;
+
public function testLoadUserByUsernameFailsIfCantConnectToLdap()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\UsernameNotFoundException');
$ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
$ldap
->expects($this->once())
@@ -40,11 +41,9 @@ class LdapUserProviderTest extends TestCase
$provider->loadUserByUsername('foo');
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\UsernameNotFoundException
- */
public function testLoadUserByUsernameFailsIfNoLdapEntries()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\UsernameNotFoundException');
$result = $this->getMockBuilder(CollectionInterface::class)->getMock();
$query = $this->getMockBuilder(QueryInterface::class)->getMock();
$query
@@ -73,11 +72,9 @@ class LdapUserProviderTest extends TestCase
$provider->loadUserByUsername('foo');
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\UsernameNotFoundException
- */
public function testLoadUserByUsernameFailsIfMoreThanOneLdapEntry()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\UsernameNotFoundException');
$result = $this->getMockBuilder(CollectionInterface::class)->getMock();
$query = $this->getMockBuilder(QueryInterface::class)->getMock();
$query
@@ -106,11 +103,9 @@ class LdapUserProviderTest extends TestCase
$provider->loadUserByUsername('foo');
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\InvalidArgumentException
- */
public function testLoadUserByUsernameFailsIfMoreThanOneLdapPasswordsInEntry()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\InvalidArgumentException');
$result = $this->getMockBuilder(CollectionInterface::class)->getMock();
$query = $this->getMockBuilder(QueryInterface::class)->getMock();
$query
@@ -191,11 +186,9 @@ class LdapUserProviderTest extends TestCase
);
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\InvalidArgumentException
- */
public function testLoadUserByUsernameFailsIfEntryHasNoPasswordAttribute()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\InvalidArgumentException');
$result = $this->getMockBuilder(CollectionInterface::class)->getMock();
$query = $this->getMockBuilder(QueryInterface::class)->getMock();
$query
diff --git a/src/Symfony/Component/Security/Core/Tests/User/UserCheckerTest.php b/src/Symfony/Component/Security/Core/Tests/User/UserCheckerTest.php
index b7eeaea0db..774d5015f1 100644
--- a/src/Symfony/Component/Security/Core/Tests/User/UserCheckerTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/User/UserCheckerTest.php
@@ -12,11 +12,14 @@
namespace Symfony\Component\Security\Core\Tests\User;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Security\Core\User\User;
use Symfony\Component\Security\Core\User\UserChecker;
class UserCheckerTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testCheckPostAuthNotAdvancedUserInterface()
{
$checker = new UserChecker();
@@ -30,38 +33,30 @@ class UserCheckerTest extends TestCase
$this->assertNull($checker->checkPostAuth(new User('John', 'password')));
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\CredentialsExpiredException
- */
public function testCheckPostAuthCredentialsExpired()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\CredentialsExpiredException');
$checker = new UserChecker();
$checker->checkPostAuth(new User('John', 'password', [], true, true, false, true));
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\LockedException
- */
public function testCheckPreAuthAccountLocked()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\LockedException');
$checker = new UserChecker();
$checker->checkPreAuth(new User('John', 'password', [], true, true, false, false));
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\DisabledException
- */
public function testCheckPreAuthDisabled()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\DisabledException');
$checker = new UserChecker();
$checker->checkPreAuth(new User('John', 'password', [], false, true, false, true));
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\AccountExpiredException
- */
public function testCheckPreAuthAccountExpired()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\AccountExpiredException');
$checker = new UserChecker();
$checker->checkPreAuth(new User('John', 'password', [], true, false, true, true));
}
diff --git a/src/Symfony/Component/Security/Core/Tests/User/UserTest.php b/src/Symfony/Component/Security/Core/Tests/User/UserTest.php
index e132d01660..b4ed713a22 100644
--- a/src/Symfony/Component/Security/Core/Tests/User/UserTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/User/UserTest.php
@@ -12,17 +12,18 @@
namespace Symfony\Component\Security\Core\Tests\User;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Security\Core\User\EquatableInterface;
use Symfony\Component\Security\Core\User\User;
use Symfony\Component\Security\Core\User\UserInterface;
class UserTest extends TestCase
{
- /**
- * @expectedException \InvalidArgumentException
- */
+ use ForwardCompatTestTrait;
+
public function testConstructorException()
{
+ $this->expectException('InvalidArgumentException');
new User('', 'superpass');
}
diff --git a/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php b/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php
index 131b7f3b1f..c10011ac24 100644
--- a/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php
@@ -115,11 +115,9 @@ abstract class UserPasswordValidatorTest extends ConstraintValidatorTestCase
];
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- */
public function testUserIsNotValid()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
$user = $this->getMockBuilder('Foo\Bar\User')->getMock();
$this->tokenStorage = $this->createTokenStorage($user);
diff --git a/src/Symfony/Component/Security/Csrf/Tests/TokenStorage/NativeSessionTokenStorageTest.php b/src/Symfony/Component/Security/Csrf/Tests/TokenStorage/NativeSessionTokenStorageTest.php
index ac4c19b895..7574635dd4 100644
--- a/src/Symfony/Component/Security/Csrf/Tests/TokenStorage/NativeSessionTokenStorageTest.php
+++ b/src/Symfony/Component/Security/Csrf/Tests/TokenStorage/NativeSessionTokenStorageTest.php
@@ -89,11 +89,9 @@ class NativeSessionTokenStorageTest extends TestCase
$this->assertSame('TOKEN', $this->storage->getToken('token_id'));
}
- /**
- * @expectedException \Symfony\Component\Security\Csrf\Exception\TokenNotFoundException
- */
public function testGetNonExistingToken()
{
+ $this->expectException('Symfony\Component\Security\Csrf\Exception\TokenNotFoundException');
$this->storage->getToken('token_id');
}
diff --git a/src/Symfony/Component/Security/Csrf/Tests/TokenStorage/SessionTokenStorageTest.php b/src/Symfony/Component/Security/Csrf/Tests/TokenStorage/SessionTokenStorageTest.php
index d90278b16a..4ad0e08640 100644
--- a/src/Symfony/Component/Security/Csrf/Tests/TokenStorage/SessionTokenStorageTest.php
+++ b/src/Symfony/Component/Security/Csrf/Tests/TokenStorage/SessionTokenStorageTest.php
@@ -89,19 +89,15 @@ class SessionTokenStorageTest extends TestCase
$this->assertSame('RESULT', $this->storage->getToken('token_id'));
}
- /**
- * @expectedException \Symfony\Component\Security\Csrf\Exception\TokenNotFoundException
- */
public function testGetNonExistingTokenFromClosedSession()
{
+ $this->expectException('Symfony\Component\Security\Csrf\Exception\TokenNotFoundException');
$this->storage->getToken('token_id');
}
- /**
- * @expectedException \Symfony\Component\Security\Csrf\Exception\TokenNotFoundException
- */
public function testGetNonExistingTokenFromActiveSession()
{
+ $this->expectException('Symfony\Component\Security\Csrf\Exception\TokenNotFoundException');
$this->session->start();
$this->storage->getToken('token_id');
}
diff --git a/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php b/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php
index 7b27af093a..3e7b06d842 100644
--- a/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php
+++ b/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php
@@ -235,11 +235,9 @@ class GuardAuthenticationListenerTest extends TestCase
$listener($this->event);
}
- /**
- * @expectedException \UnexpectedValueException
- */
public function testReturnNullFromGetCredentials()
{
+ $this->expectException('UnexpectedValueException');
$authenticator = $this->getMockBuilder(AuthenticatorInterface::class)->getMock();
$providerKey = 'my_firewall4';
diff --git a/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php b/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php
index 5efca595fc..92262bcdab 100644
--- a/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php
+++ b/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php
@@ -90,11 +90,9 @@ class GuardAuthenticationProviderTest extends TestCase
$this->assertSame($authedToken, $actualAuthedToken);
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
- */
public function testCheckCredentialsReturningNonTrueFailsAuthentication()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException');
$providerKey = 'my_uncool_firewall';
$authenticator = $this->getMockBuilder(AuthenticatorInterface::class)->getMock();
@@ -123,11 +121,9 @@ class GuardAuthenticationProviderTest extends TestCase
$provider->authenticate($this->preAuthenticationToken);
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\AuthenticationExpiredException
- */
public function testGuardWithNoLongerAuthenticatedTriggersLogout()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationExpiredException');
$providerKey = 'my_firewall_abc';
// create a token and mark it as NOT authenticated anymore
@@ -158,12 +154,10 @@ class GuardAuthenticationProviderTest extends TestCase
$this->assertFalse($supports);
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\AuthenticationException
- * @expectedExceptionMessageRegExp /second_firewall_0/
- */
public function testAuthenticateFailsOnNonOriginatingToken()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationException');
+ $this->expectExceptionMessageRegExp('/second_firewall_0/');
$authenticatorA = $this->getMockBuilder(AuthenticatorInterface::class)->getMock();
$authenticators = [$authenticatorA];
diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php
index e0f4304e03..ab549a597a 100644
--- a/src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php
@@ -12,16 +12,17 @@
namespace Symfony\Component\Security\Http\Tests\Firewall;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\Security\Http\Firewall\AccessListener;
class AccessListenerTest extends TestCase
{
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\AccessDeniedException
- */
+ use ForwardCompatTestTrait;
+
public function testHandleWhenTheAccessDecisionManagerDecidesToRefuseAccess()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\AccessDeniedException');
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock();
$accessMap = $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock();
@@ -184,11 +185,9 @@ class AccessListenerTest extends TestCase
$listener($event);
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException
- */
public function testHandleWhenTheSecurityTokenStorageHasNoToken()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException');
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$tokenStorage
->expects($this->any())
diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/BasicAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/BasicAuthenticationListenerTest.php
index 7a62671431..0a03f825cb 100644
--- a/src/Symfony/Component/Security/Http/Tests/Firewall/BasicAuthenticationListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Firewall/BasicAuthenticationListenerTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\Security\Http\Tests\Firewall;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\RequestEvent;
@@ -22,6 +23,8 @@ use Symfony\Component\Security\Http\Firewall\BasicAuthenticationListener;
class BasicAuthenticationListenerTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testHandleWithValidUsernameAndPasswordServerParameters()
{
$request = new Request([], [], [], [], [], [
@@ -183,12 +186,10 @@ class BasicAuthenticationListenerTest extends TestCase
$listener($event);
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage $providerKey must not be empty
- */
public function testItRequiresProviderKey()
{
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('$providerKey must not be empty');
new BasicAuthenticationListener(
$this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(),
$this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(),
diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php
index 74c37d42fc..4bd56c911b 100644
--- a/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\Security\Http\Tests\Firewall;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Request;
@@ -36,12 +37,12 @@ use Symfony\Component\Security\Http\Firewall\ContextListener;
class ContextListenerTest extends TestCase
{
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage $contextKey must not be empty
- */
+ use ForwardCompatTestTrait;
+
public function testItRequiresContextKey()
{
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('$contextKey must not be empty');
new ContextListener(
$this->getMockBuilder(TokenStorageInterface::class)->getMock(),
[],
@@ -49,12 +50,10 @@ class ContextListenerTest extends TestCase
);
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage User provider "stdClass" must implement "Symfony\Component\Security\Core\User\UserProviderInterface
- */
public function testUserProvidersNeedToImplementAnInterface()
{
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('User provider "stdClass" must implement "Symfony\Component\Security\Core\User\UserProviderInterface');
$this->handleEventWithPreviousSession(new TokenStorage(), [new \stdClass()]);
}
@@ -297,11 +296,9 @@ class ContextListenerTest extends TestCase
$this->assertNull($tokenStorage->getToken());
}
- /**
- * @expectedException \RuntimeException
- */
public function testRuntimeExceptionIsThrownIfNoSupportingUserProviderWasRegistered()
{
+ $this->expectException('RuntimeException');
$this->handleEventWithPreviousSession(new TokenStorage(), [new NotSupportingUserProvider(), new NotSupportingUserProvider()]);
}
diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php
index b68888ef77..64ad404a7a 100644
--- a/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Firewall/LogoutListenerTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\Security\Http\Tests\Firewall;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\RequestEvent;
@@ -19,6 +20,8 @@ use Symfony\Component\Security\Http\Firewall\LogoutListener;
class LogoutListenerTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testHandleUnmatchedPath()
{
list($listener, $tokenStorage, $httpUtils, $options) = $this->getListener();
@@ -123,11 +126,9 @@ class LogoutListenerTest extends TestCase
$listener($event);
}
- /**
- * @expectedException \RuntimeException
- */
public function testSuccessHandlerReturnsNonResponse()
{
+ $this->expectException('RuntimeException');
$successHandler = $this->getSuccessHandler();
list($listener, $tokenStorage, $httpUtils, $options) = $this->getListener($successHandler);
@@ -147,11 +148,9 @@ class LogoutListenerTest extends TestCase
$listener($event);
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\LogoutException
- */
public function testCsrfValidationFails()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\LogoutException');
$tokenManager = $this->getTokenManager();
list($listener, $tokenStorage, $httpUtils, $options) = $this->getListener(null, $tokenManager);
diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php
index 850f88c61c..8ca2ec24ea 100644
--- a/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\Security\Http\Tests\Firewall;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
@@ -22,6 +23,8 @@ use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
class RememberMeListenerTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testOnCoreSecurityDoesNotTryToPopulateNonEmptyTokenStorage()
{
list($listener, $tokenStorage) = $this->getListener();
@@ -106,12 +109,10 @@ class RememberMeListenerTest extends TestCase
$listener($event);
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\AuthenticationException
- * @expectedExceptionMessage Authentication failed.
- */
public function testOnCoreSecurityIgnoresAuthenticationOptionallyRethrowsExceptionThrownAuthenticationManagerImplementation()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationException');
+ $this->expectExceptionMessage('Authentication failed.');
list($listener, $tokenStorage, $service, $manager) = $this->getListener(false, false);
$tokenStorage
diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/RemoteUserAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/RemoteUserAuthenticationListenerTest.php
index ee5334c1e7..6328ddf523 100644
--- a/src/Symfony/Component/Security/Http/Tests/Firewall/RemoteUserAuthenticationListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Firewall/RemoteUserAuthenticationListenerTest.php
@@ -12,11 +12,14 @@
namespace Symfony\Component\Security\Http\Tests\Firewall;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Http\Firewall\RemoteUserAuthenticationListener;
class RemoteUserAuthenticationListenerTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testGetPreAuthenticatedData()
{
$serverVars = [
@@ -42,11 +45,9 @@ class RemoteUserAuthenticationListenerTest extends TestCase
$this->assertSame($result, ['TheUser', null]);
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
- */
public function testGetPreAuthenticatedDataNoUser()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException');
$request = new Request([], [], [], [], [], []);
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php
index 43696475aa..3a233aa689 100644
--- a/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php
@@ -51,12 +51,10 @@ class SwitchUserListenerTest extends TestCase
$this->event = new RequestEvent($this->getMockBuilder(HttpKernelInterface::class)->getMock(), $this->request, HttpKernelInterface::MASTER_REQUEST);
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage $providerKey must not be empty
- */
public function testProviderKeyIsRequired()
{
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('$providerKey must not be empty');
new SwitchUserListener($this->tokenStorage, $this->userProvider, $this->userChecker, '', $this->accessDecisionManager);
}
@@ -69,22 +67,18 @@ class SwitchUserListenerTest extends TestCase
$this->assertNull($this->tokenStorage->getToken());
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException
- */
public function testExitUserThrowsAuthenticationExceptionIfNoCurrentToken()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException');
$this->tokenStorage->setToken(null);
$this->request->query->set('_switch_user', '_exit');
$listener = new SwitchUserListener($this->tokenStorage, $this->userProvider, $this->userChecker, 'provider123', $this->accessDecisionManager);
$listener($this->event);
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException
- */
public function testExitUserThrowsAuthenticationExceptionIfOriginalTokenCannotBeFound()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException');
$token = new UsernamePasswordToken('username', '', 'key', ['ROLE_FOO']);
$this->tokenStorage->setToken($token);
@@ -162,11 +156,9 @@ class SwitchUserListenerTest extends TestCase
$listener($this->event);
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\AccessDeniedException
- */
public function testSwitchUserIsDisallowed()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\AccessDeniedException');
$token = new UsernamePasswordToken('username', '', 'key', ['ROLE_FOO']);
$this->tokenStorage->setToken($token);
@@ -276,11 +268,9 @@ class SwitchUserListenerTest extends TestCase
$this->assertSame($replacedToken, $this->tokenStorage->getToken());
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException
- */
public function testSwitchtUserThrowsAuthenticationExceptionIfNoCurrentToken()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException');
$this->tokenStorage->setToken(null);
$this->request->query->set('_switch_user', 'username');
$listener = new SwitchUserListener($this->tokenStorage, $this->userProvider, $this->userChecker, 'provider123', $this->accessDecisionManager);
diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php
index 6fc4b07ea8..a93377d308 100644
--- a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\Security\Tests\Http\Firewall;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\RequestEvent;
@@ -26,6 +27,8 @@ use Symfony\Component\Security\Http\Session\SessionAuthenticationStrategy;
class UsernamePasswordFormAuthenticationListenerTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
/**
* @dataProvider getUsernameForLength
*/
@@ -78,11 +81,11 @@ class UsernamePasswordFormAuthenticationListenerTest extends TestCase
/**
* @dataProvider postOnlyDataProvider
- * @expectedException \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
- * @expectedExceptionMessage The key "_username" must be a string, "array" given.
*/
public function testHandleNonStringUsernameWithArray($postOnly)
{
+ $this->expectException('Symfony\Component\HttpKernel\Exception\BadRequestHttpException');
+ $this->expectExceptionMessage('The key "_username" must be a string, "array" given.');
$request = Request::create('/login_check', 'POST', ['_username' => []]);
$request->setSession($this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock());
$listener = new UsernamePasswordFormAuthenticationListener(
@@ -101,11 +104,11 @@ class UsernamePasswordFormAuthenticationListenerTest extends TestCase
/**
* @dataProvider postOnlyDataProvider
- * @expectedException \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
- * @expectedExceptionMessage The key "_username" must be a string, "integer" given.
*/
public function testHandleNonStringUsernameWithInt($postOnly)
{
+ $this->expectException('Symfony\Component\HttpKernel\Exception\BadRequestHttpException');
+ $this->expectExceptionMessage('The key "_username" must be a string, "integer" given.');
$request = Request::create('/login_check', 'POST', ['_username' => 42]);
$request->setSession($this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock());
$listener = new UsernamePasswordFormAuthenticationListener(
@@ -124,11 +127,11 @@ class UsernamePasswordFormAuthenticationListenerTest extends TestCase
/**
* @dataProvider postOnlyDataProvider
- * @expectedException \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
- * @expectedExceptionMessage The key "_username" must be a string, "object" given.
*/
public function testHandleNonStringUsernameWithObject($postOnly)
{
+ $this->expectException('Symfony\Component\HttpKernel\Exception\BadRequestHttpException');
+ $this->expectExceptionMessage('The key "_username" must be a string, "object" given.');
$request = Request::create('/login_check', 'POST', ['_username' => new \stdClass()]);
$request->setSession($this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock());
$listener = new UsernamePasswordFormAuthenticationListener(
diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordJsonAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordJsonAuthenticationListenerTest.php
index fb3227ce21..84d733b2b2 100644
--- a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordJsonAuthenticationListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordJsonAuthenticationListenerTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\Security\Tests\Http\Firewall;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\RequestEvent;
@@ -31,6 +32,8 @@ use Symfony\Component\Security\Http\HttpUtils;
*/
class UsernamePasswordJsonAuthenticationListenerTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
/**
* @var UsernamePasswordJsonAuthenticationListener
*/
@@ -104,12 +107,10 @@ class UsernamePasswordJsonAuthenticationListenerTest extends TestCase
$this->assertEquals('ok', $event->getResponse()->getContent());
}
- /**
- * @expectedException \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
- * @expectedExceptionMessage Invalid JSON
- */
public function testAttemptAuthenticationNoJson()
{
+ $this->expectException('Symfony\Component\HttpKernel\Exception\BadRequestHttpException');
+ $this->expectExceptionMessage('Invalid JSON');
$this->createListener();
$request = new Request();
$request->setRequestFormat('json');
@@ -118,12 +119,10 @@ class UsernamePasswordJsonAuthenticationListenerTest extends TestCase
($this->listener)($event);
}
- /**
- * @expectedException \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
- * @expectedExceptionMessage The key "username" must be provided
- */
public function testAttemptAuthenticationNoUsername()
{
+ $this->expectException('Symfony\Component\HttpKernel\Exception\BadRequestHttpException');
+ $this->expectExceptionMessage('The key "username" must be provided');
$this->createListener();
$request = new Request([], [], [], [], [], ['HTTP_CONTENT_TYPE' => 'application/json'], '{"usr": "dunglas", "password": "foo"}');
$event = new RequestEvent($this->getMockBuilder(KernelInterface::class)->getMock(), $request, KernelInterface::MASTER_REQUEST);
@@ -131,12 +130,10 @@ class UsernamePasswordJsonAuthenticationListenerTest extends TestCase
($this->listener)($event);
}
- /**
- * @expectedException \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
- * @expectedExceptionMessage The key "password" must be provided
- */
public function testAttemptAuthenticationNoPassword()
{
+ $this->expectException('Symfony\Component\HttpKernel\Exception\BadRequestHttpException');
+ $this->expectExceptionMessage('The key "password" must be provided');
$this->createListener();
$request = new Request([], [], [], [], [], ['HTTP_CONTENT_TYPE' => 'application/json'], '{"username": "dunglas", "pass": "foo"}');
$event = new RequestEvent($this->getMockBuilder(KernelInterface::class)->getMock(), $request, KernelInterface::MASTER_REQUEST);
@@ -144,12 +141,10 @@ class UsernamePasswordJsonAuthenticationListenerTest extends TestCase
($this->listener)($event);
}
- /**
- * @expectedException \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
- * @expectedExceptionMessage The key "username" must be a string.
- */
public function testAttemptAuthenticationUsernameNotAString()
{
+ $this->expectException('Symfony\Component\HttpKernel\Exception\BadRequestHttpException');
+ $this->expectExceptionMessage('The key "username" must be a string.');
$this->createListener();
$request = new Request([], [], [], [], [], ['HTTP_CONTENT_TYPE' => 'application/json'], '{"username": 1, "password": "foo"}');
$event = new RequestEvent($this->getMockBuilder(KernelInterface::class)->getMock(), $request, KernelInterface::MASTER_REQUEST);
@@ -157,12 +152,10 @@ class UsernamePasswordJsonAuthenticationListenerTest extends TestCase
($this->listener)($event);
}
- /**
- * @expectedException \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
- * @expectedExceptionMessage The key "password" must be a string.
- */
public function testAttemptAuthenticationPasswordNotAString()
{
+ $this->expectException('Symfony\Component\HttpKernel\Exception\BadRequestHttpException');
+ $this->expectExceptionMessage('The key "password" must be a string.');
$this->createListener();
$request = new Request([], [], [], [], [], ['HTTP_CONTENT_TYPE' => 'application/json'], '{"username": "dunglas", "password": 1}');
$event = new RequestEvent($this->getMockBuilder(KernelInterface::class)->getMock(), $request, KernelInterface::MASTER_REQUEST);
diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/X509AuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/X509AuthenticationListenerTest.php
index 577ca7c38f..b82b616a63 100644
--- a/src/Symfony/Component/Security/Http/Tests/Firewall/X509AuthenticationListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Firewall/X509AuthenticationListenerTest.php
@@ -12,11 +12,14 @@
namespace Symfony\Component\Security\Http\Tests\Firewall;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Http\Firewall\X509AuthenticationListener;
class X509AuthenticationListenerTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
/**
* @dataProvider dataProviderGetPreAuthenticatedData
*/
@@ -83,11 +86,9 @@ class X509AuthenticationListenerTest extends TestCase
yield ['cert+something@example.com', 'emailAddress=cert+something@example.com'];
}
- /**
- * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
- */
public function testGetPreAuthenticatedDataNoData()
{
+ $this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException');
$request = new Request([], [], [], [], [], []);
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
diff --git a/src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php b/src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php
index a4a76747e5..016a22655a 100644
--- a/src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\Security\Http\Tests;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
@@ -21,6 +22,8 @@ use Symfony\Component\Security\Http\HttpUtils;
class HttpUtilsTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testCreateRedirectResponseWithPath()
{
$utils = new HttpUtils($this->getUrlGenerator());
@@ -251,11 +254,9 @@ class HttpUtilsTest extends TestCase
$this->assertTrue($utils->checkRequestPath($request, 'foobar'));
}
- /**
- * @expectedException \RuntimeException
- */
public function testCheckRequestPathWithUrlMatcherLoadingException()
{
+ $this->expectException('RuntimeException');
$urlMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\UrlMatcherInterface')->getMock();
$urlMatcher
->expects($this->any())
@@ -280,12 +281,10 @@ class HttpUtilsTest extends TestCase
$this->assertFalse($utils->checkRequestPath($this->getRequest(), 'path/index.html'));
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage Matcher must either implement UrlMatcherInterface or RequestMatcherInterface
- */
public function testUrlMatcher()
{
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('Matcher must either implement UrlMatcherInterface or RequestMatcherInterface');
new HttpUtils($this->getUrlGenerator(), new \stdClass());
}
@@ -307,12 +306,10 @@ class HttpUtilsTest extends TestCase
$this->assertEquals('/foo/bar#fragment', $utils->generateUri(new Request(), 'route_name'));
}
- /**
- * @expectedException \LogicException
- * @expectedExceptionMessage You must provide a UrlGeneratorInterface instance to be able to use routes.
- */
public function testUrlGeneratorIsRequiredToGenerateUrl()
{
+ $this->expectException('LogicException');
+ $this->expectExceptionMessage('You must provide a UrlGeneratorInterface instance to be able to use routes.');
$utils = new HttpUtils();
$utils->generateUri(new Request(), 'route_name');
}
diff --git a/src/Symfony/Component/Security/Http/Tests/Logout/LogoutUrlGeneratorTest.php b/src/Symfony/Component/Security/Http/Tests/Logout/LogoutUrlGeneratorTest.php
index 8cf3da687f..f2e0154d92 100644
--- a/src/Symfony/Component/Security/Http/Tests/Logout/LogoutUrlGeneratorTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Logout/LogoutUrlGeneratorTest.php
@@ -49,12 +49,10 @@ class LogoutUrlGeneratorTest extends TestCase
$this->assertSame('/logout', $this->generator->getLogoutPath('secured_area'));
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage No LogoutListener found for firewall key "unregistered_key".
- */
public function testGetLogoutPathWithoutLogoutListenerRegisteredForKeyThrowsException()
{
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('No LogoutListener found for firewall key "unregistered_key".');
$this->generator->registerListener('secured_area', '/logout', null, null, null);
$this->generator->getLogoutPath('unregistered_key');
@@ -68,12 +66,10 @@ class LogoutUrlGeneratorTest extends TestCase
$this->assertSame('/logout', $this->generator->getLogoutPath());
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage Unable to generate a logout url for an anonymous token.
- */
public function testGuessFromAnonymousTokenThrowsException()
{
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('Unable to generate a logout url for an anonymous token.');
$this->tokenStorage->setToken(new AnonymousToken('default', 'anon.'));
$this->generator->getLogoutPath();
@@ -104,12 +100,10 @@ class LogoutUrlGeneratorTest extends TestCase
$this->assertSame('/logout', $this->generator->getLogoutPath());
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage Unable to find the current firewall LogoutListener, please provide the provider key manually
- */
public function testUnableToGuessThrowsException()
{
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('Unable to find the current firewall LogoutListener, please provide the provider key manually');
$this->generator->registerListener('secured_area', '/logout', null, null);
$this->generator->getLogoutPath();
diff --git a/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php b/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php
index 3709a92bba..0cf4654bcc 100644
--- a/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php
@@ -42,11 +42,9 @@ class AbstractRememberMeServicesTest extends TestCase
$this->assertNull($service->autoLogin(new Request()));
}
- /**
- * @expectedException \RuntimeException
- */
public function testAutoLoginThrowsExceptionWhenImplementationDoesNotReturnUserInterface()
{
+ $this->expectException('RuntimeException');
$service = $this->getService(null, ['name' => 'foo', 'path' => null, 'domain' => null]);
$request = new Request();
$request->cookies->set('foo', 'foo');
@@ -270,12 +268,10 @@ class AbstractRememberMeServicesTest extends TestCase
$this->assertSame($cookieParts, $decoded);
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage cookie delimiter
- */
public function testThereShouldBeNoCookieDelimiterInCookieParts()
{
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('cookie delimiter');
$cookieParts = ['aa', 'b'.AbstractRememberMeServices::COOKIE_DELIMITER.'b', 'cc'];
$service = $this->getService();
diff --git a/src/Symfony/Component/Security/Http/Tests/Session/SessionAuthenticationStrategyTest.php b/src/Symfony/Component/Security/Http/Tests/Session/SessionAuthenticationStrategyTest.php
index 6c0df8cb5f..4ef0b80b06 100644
--- a/src/Symfony/Component/Security/Http/Tests/Session/SessionAuthenticationStrategyTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Session/SessionAuthenticationStrategyTest.php
@@ -12,10 +12,13 @@
namespace Symfony\Component\Security\Http\Tests\Session;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Security\Http\Session\SessionAuthenticationStrategy;
class SessionAuthenticationStrategyTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testSessionIsNotChanged()
{
$request = $this->getRequest();
@@ -25,12 +28,10 @@ class SessionAuthenticationStrategyTest extends TestCase
$strategy->onAuthentication($request, $this->getToken());
}
- /**
- * @expectedException \RuntimeException
- * @expectedExceptionMessage Invalid session authentication strategy "foo"
- */
public function testUnsupportedStrategy()
{
+ $this->expectException('RuntimeException');
+ $this->expectExceptionMessage('Invalid session authentication strategy "foo"');
$request = $this->getRequest();
$request->expects($this->never())->method('getSession');
diff --git a/src/Symfony/Component/Serializer/Tests/Annotation/DiscriminatorMapTest.php b/src/Symfony/Component/Serializer/Tests/Annotation/DiscriminatorMapTest.php
index 3f3f166636..81f2db2cdd 100644
--- a/src/Symfony/Component/Serializer/Tests/Annotation/DiscriminatorMapTest.php
+++ b/src/Symfony/Component/Serializer/Tests/Annotation/DiscriminatorMapTest.php
@@ -33,35 +33,27 @@ class DiscriminatorMapTest extends TestCase
], $annotation->getMapping());
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
- */
public function testExceptionWithoutTypeProperty()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException');
new DiscriminatorMap(['mapping' => ['foo' => 'FooClass']]);
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
- */
public function testExceptionWithEmptyTypeProperty()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException');
new DiscriminatorMap(['typeProperty' => '', 'mapping' => ['foo' => 'FooClass']]);
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
- */
public function testExceptionWithoutMappingProperty()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException');
new DiscriminatorMap(['typeProperty' => 'type']);
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
- */
public function testExceptionWitEmptyMappingProperty()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException');
new DiscriminatorMap(['typeProperty' => 'type', 'mapping' => []]);
}
}
diff --git a/src/Symfony/Component/Serializer/Tests/Annotation/GroupsTest.php b/src/Symfony/Component/Serializer/Tests/Annotation/GroupsTest.php
index 9b54221d76..203eb3c92b 100644
--- a/src/Symfony/Component/Serializer/Tests/Annotation/GroupsTest.php
+++ b/src/Symfony/Component/Serializer/Tests/Annotation/GroupsTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\Serializer\Tests\Annotation;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Serializer\Annotation\Groups;
/**
@@ -19,27 +20,23 @@ use Symfony\Component\Serializer\Annotation\Groups;
*/
class GroupsTest extends TestCase
{
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
- */
+ use ForwardCompatTestTrait;
+
public function testEmptyGroupsParameter()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException');
new Groups(['value' => []]);
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
- */
public function testNotAnArrayGroupsParameter()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException');
new Groups(['value' => 12]);
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
- */
public function testInvalidGroupsParameter()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException');
new Groups(['value' => ['a', 1, new \stdClass()]]);
}
diff --git a/src/Symfony/Component/Serializer/Tests/Annotation/MaxDepthTest.php b/src/Symfony/Component/Serializer/Tests/Annotation/MaxDepthTest.php
index 16f10e1434..8cca874ecd 100644
--- a/src/Symfony/Component/Serializer/Tests/Annotation/MaxDepthTest.php
+++ b/src/Symfony/Component/Serializer/Tests/Annotation/MaxDepthTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\Serializer\Tests\Annotation;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Serializer\Annotation\MaxDepth;
/**
@@ -19,12 +20,12 @@ use Symfony\Component\Serializer\Annotation\MaxDepth;
*/
class MaxDepthTest extends TestCase
{
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
- * @expectedExceptionMessage Parameter of annotation "Symfony\Component\Serializer\Annotation\MaxDepth" should be set.
- */
+ use ForwardCompatTestTrait;
+
public function testNotSetMaxDepthParameter()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Parameter of annotation "Symfony\Component\Serializer\Annotation\MaxDepth" should be set.');
new MaxDepth([]);
}
@@ -40,12 +41,11 @@ class MaxDepthTest extends TestCase
/**
* @dataProvider provideInvalidValues
- *
- * @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
- * @expectedExceptionMessage Parameter of annotation "Symfony\Component\Serializer\Annotation\MaxDepth" must be a positive integer.
*/
public function testNotAnIntMaxDepthParameter($value)
{
+ $this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Parameter of annotation "Symfony\Component\Serializer\Annotation\MaxDepth" must be a positive integer.');
new MaxDepth(['value' => $value]);
}
diff --git a/src/Symfony/Component/Serializer/Tests/Annotation/SerializedNameTest.php b/src/Symfony/Component/Serializer/Tests/Annotation/SerializedNameTest.php
index 1b6f4ff9f0..cb934580b0 100644
--- a/src/Symfony/Component/Serializer/Tests/Annotation/SerializedNameTest.php
+++ b/src/Symfony/Component/Serializer/Tests/Annotation/SerializedNameTest.php
@@ -19,12 +19,10 @@ use Symfony\Component\Serializer\Annotation\SerializedName;
*/
class SerializedNameTest extends TestCase
{
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
- * @expectedExceptionMessage Parameter of annotation "Symfony\Component\Serializer\Annotation\SerializedName" should be set.
- */
public function testNotSetSerializedNameParameter()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Parameter of annotation "Symfony\Component\Serializer\Annotation\SerializedName" should be set.');
new SerializedName([]);
}
@@ -38,12 +36,11 @@ class SerializedNameTest extends TestCase
/**
* @dataProvider provideInvalidValues
- *
- * @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
- * @expectedExceptionMessage Parameter of annotation "Symfony\Component\Serializer\Annotation\SerializedName" must be a non-empty string.
*/
public function testNotAStringSerializedNameParameter($value)
{
+ $this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Parameter of annotation "Symfony\Component\Serializer\Annotation\SerializedName" must be a non-empty string.');
new SerializedName(['value' => $value]);
}
diff --git a/src/Symfony/Component/Serializer/Tests/DependencyInjection/SerializerPassTest.php b/src/Symfony/Component/Serializer/Tests/DependencyInjection/SerializerPassTest.php
index 5c3fedfe89..d5e044504f 100644
--- a/src/Symfony/Component/Serializer/Tests/DependencyInjection/SerializerPassTest.php
+++ b/src/Symfony/Component/Serializer/Tests/DependencyInjection/SerializerPassTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\Serializer\Tests\DependencyInjection;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\Serializer\DependencyInjection\SerializerPass;
@@ -23,12 +24,12 @@ use Symfony\Component\Serializer\DependencyInjection\SerializerPass;
*/
class SerializerPassTest extends TestCase
{
- /**
- * @expectedException \RuntimeException
- * @expectedExceptionMessage You must tag at least one service as "serializer.normalizer" to use the "serializer" service
- */
+ use ForwardCompatTestTrait;
+
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');
@@ -36,12 +37,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([])
diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/ChainDecoderTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/ChainDecoderTest.php
index ecb37f2300..659930c41e 100644
--- a/src/Symfony/Component/Serializer/Tests/Encoder/ChainDecoderTest.php
+++ b/src/Symfony/Component/Serializer/Tests/Encoder/ChainDecoderTest.php
@@ -73,11 +73,9 @@ class ChainDecoderTest extends TestCase
$this->chainDecoder->decode('string_to_decode', self::FORMAT_2);
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\RuntimeException
- */
public function testDecodeUnsupportedFormat()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\RuntimeException');
$this->chainDecoder->decode('string_to_decode', self::FORMAT_3);
}
}
diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/ChainEncoderTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/ChainEncoderTest.php
index 2a0f85d04a..bfec205a27 100644
--- a/src/Symfony/Component/Serializer/Tests/Encoder/ChainEncoderTest.php
+++ b/src/Symfony/Component/Serializer/Tests/Encoder/ChainEncoderTest.php
@@ -75,11 +75,9 @@ class ChainEncoderTest extends TestCase
$this->chainEncoder->encode(['foo' => 123], self::FORMAT_2);
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\RuntimeException
- */
public function testEncodeUnsupportedFormat()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\RuntimeException');
$this->chainEncoder->encode(['foo' => 123], self::FORMAT_3);
}
diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/JsonDecodeTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/JsonDecodeTest.php
index e10da56661..8ff1482eb5 100644
--- a/src/Symfony/Component/Serializer/Tests/Encoder/JsonDecodeTest.php
+++ b/src/Symfony/Component/Serializer/Tests/Encoder/JsonDecodeTest.php
@@ -60,10 +60,10 @@ class JsonDecodeTest extends TestCase
/**
* @dataProvider decodeProviderException
- * @expectedException \Symfony\Component\Serializer\Exception\UnexpectedValueException
*/
public function testDecodeWithException($value)
{
+ $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException');
$this->decode->decode($value, JsonEncoder::FORMAT);
}
diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/JsonEncodeTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/JsonEncodeTest.php
index 72703f873f..68ea7da068 100644
--- a/src/Symfony/Component/Serializer/Tests/Encoder/JsonEncodeTest.php
+++ b/src/Symfony/Component/Serializer/Tests/Encoder/JsonEncodeTest.php
@@ -52,11 +52,9 @@ class JsonEncodeTest extends TestCase
];
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\UnexpectedValueException
- */
public function testEncodeWithError()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException');
$this->encode->encode("\xB1\x31", JsonEncoder::FORMAT);
}
}
diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/JsonEncoderTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/JsonEncoderTest.php
index 0080112baa..27e1a55b02 100644
--- a/src/Symfony/Component/Serializer/Tests/Encoder/JsonEncoderTest.php
+++ b/src/Symfony/Component/Serializer/Tests/Encoder/JsonEncoderTest.php
@@ -68,11 +68,9 @@ class JsonEncoderTest extends TestCase
$this->assertEquals($expected, $this->serializer->serialize($arr, 'json'), 'Context should not be persistent');
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\UnexpectedValueException
- */
public function testEncodeNotUtf8WithoutPartialOnError()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException');
$arr = [
'utf8' => 'Hello World!',
'notUtf8' => "\xb0\xd0\xb5\xd0",
diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php
index f1284334d8..f4a1ea7458 100644
--- a/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php
+++ b/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php
@@ -50,12 +50,10 @@ class XmlEncoderTest extends TestCase
$this->assertEquals($expected, $this->encoder->encode($obj, 'xml'));
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\UnexpectedValueException
- * @expectedExceptionMessage Document types are not allowed.
- */
public function testDocTypeIsNotAllowed()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException');
+ $this->expectExceptionMessage('Document types are not allowed.');
$this->encoder->decode('', 'foo');
}
@@ -636,19 +634,15 @@ XML;
$this->assertEquals($expected, $this->encoder->decode($xml, 'xml'));
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\UnexpectedValueException
- */
public function testDecodeInvalidXml()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException');
$this->encoder->decode('', 'xml');
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\UnexpectedValueException
- */
public function testPreventsComplexExternalEntities()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException');
$this->encoder->decode(']>&test;', 'xml');
}
diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/Factory/CacheMetadataFactoryTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/Factory/CacheMetadataFactoryTest.php
index 067f16acf9..8c5d61e261 100644
--- a/src/Symfony/Component/Serializer/Tests/Mapping/Factory/CacheMetadataFactoryTest.php
+++ b/src/Symfony/Component/Serializer/Tests/Mapping/Factory/CacheMetadataFactoryTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\Serializer\Tests\Mapping\Factory;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\Serializer\Mapping\ClassMetadata;
use Symfony\Component\Serializer\Mapping\Factory\CacheClassMetadataFactory;
@@ -23,6 +24,8 @@ use Symfony\Component\Serializer\Tests\Fixtures\Dummy;
*/
class CacheMetadataFactoryTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testGetMetadataFor()
{
$metadata = new ClassMetadata(Dummy::class);
@@ -55,11 +58,9 @@ class CacheMetadataFactoryTest extends TestCase
$this->assertTrue($factory->hasMetadataFor(Dummy::class));
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
- */
public function testInvalidClassThrowsException()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException');
$decorated = $this->getMockBuilder(ClassMetadataFactoryInterface::class)->getMock();
$factory = new CacheClassMetadataFactory($decorated, new ArrayAdapter());
diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/Loader/YamlFileLoaderTest.php
index 73f5f4a4f1..cc00ae2d79 100644
--- a/src/Symfony/Component/Serializer/Tests/Mapping/Loader/YamlFileLoaderTest.php
+++ b/src/Symfony/Component/Serializer/Tests/Mapping/Loader/YamlFileLoaderTest.php
@@ -60,11 +60,9 @@ class YamlFileLoaderTest extends TestCase
$this->assertFalse($loader->loadClassMetadata($this->metadata));
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\MappingException
- */
public function testLoadClassMetadataReturnsThrowsInvalidMapping()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\MappingException');
$loader = new YamlFileLoader(__DIR__.'/../../Fixtures/invalid-mapping.yml');
$loader->loadClassMetadata($this->metadata);
}
diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php
index f8d0f88cc1..677f0a6f6f 100644
--- a/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php
+++ b/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php
@@ -59,12 +59,10 @@ class AbstractObjectNormalizerTest extends TestCase
$this->assertInstanceOf(__NAMESPACE__.'\Dummy', $normalizer->instantiateObject($data, $class, $context, new \ReflectionClass($class), []));
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\ExtraAttributesException
- * @expectedExceptionMessage Extra attributes are not allowed ("fooFoo", "fooBar" are unknown).
- */
public function testDenormalizeWithExtraAttributes()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\ExtraAttributesException');
+ $this->expectExceptionMessage('Extra attributes are not allowed ("fooFoo", "fooBar" are unknown).');
$factory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
$normalizer = new AbstractObjectNormalizerDummy($factory);
$normalizer->denormalize(
@@ -75,12 +73,10 @@ class AbstractObjectNormalizerTest extends TestCase
);
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\ExtraAttributesException
- * @expectedExceptionMessage Extra attributes are not allowed ("fooFoo", "fooBar" are unknown).
- */
public function testDenormalizeWithExtraAttributesAndNoGroupsWithMetadataFactory()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\ExtraAttributesException');
+ $this->expectExceptionMessage('Extra attributes are not allowed ("fooFoo", "fooBar" are unknown).');
$normalizer = new AbstractObjectNormalizerWithMetadata();
$normalizer->denormalize(
['fooFoo' => 'foo', 'fooBar' => 'bar', 'bar' => 'bar'],
@@ -194,12 +190,11 @@ class AbstractObjectNormalizerTest extends TestCase
/**
* Test that additional attributes throw an exception if no metadata factory is specified.
- *
- * @expectedException \Symfony\Component\Serializer\Exception\LogicException
- * @expectedExceptionMessage A class metadata factory must be provided in the constructor when setting "allow_extra_attributes" to false.
*/
public function testExtraAttributesException()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\LogicException');
+ $this->expectExceptionMessage('A class metadata factory must be provided in the constructor when setting "allow_extra_attributes" to false.');
$normalizer = new ObjectNormalizer();
$normalizer->denormalize([], \stdClass::class, 'xml', [
diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/DataUriNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/DataUriNormalizerTest.php
index 62a55ac02c..82a4f2d74b 100644
--- a/src/Symfony/Component/Serializer/Tests/Normalizer/DataUriNormalizerTest.php
+++ b/src/Symfony/Component/Serializer/Tests/Normalizer/DataUriNormalizerTest.php
@@ -114,21 +114,19 @@ class DataUriNormalizerTest extends TestCase
$this->assertSame(file_get_contents(self::TEST_GIF_DATA), $this->getContent($file->openFile()));
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\UnexpectedValueException
- * @expectedExceptionMessage The provided "data:" URI is not valid.
- */
public function testGiveNotAccessToLocalFiles()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException');
+ $this->expectExceptionMessage('The provided "data:" URI is not valid.');
$this->normalizer->denormalize('/etc/shadow', 'SplFileObject');
}
/**
- * @expectedException \Symfony\Component\Serializer\Exception\UnexpectedValueException
* @dataProvider invalidUriProvider
*/
public function testInvalidData($uri)
{
+ $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException');
$this->normalizer->denormalize($uri, 'SplFileObject');
}
diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/DateIntervalNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/DateIntervalNormalizerTest.php
index 75061fffb5..fb6f01fbb9 100644
--- a/src/Symfony/Component/Serializer/Tests/Normalizer/DateIntervalNormalizerTest.php
+++ b/src/Symfony/Component/Serializer/Tests/Normalizer/DateIntervalNormalizerTest.php
@@ -65,12 +65,10 @@ class DateIntervalNormalizerTest extends TestCase
$this->assertEquals($output, $normalizer->normalize(new \DateInterval($input)));
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
- * @expectedExceptionMessage The object must be an instance of "\DateInterval".
- */
public function testNormalizeInvalidObjectThrowsException()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('The object must be an instance of "\DateInterval".');
$this->normalizer->normalize(new \stdClass());
}
@@ -102,36 +100,28 @@ class DateIntervalNormalizerTest extends TestCase
$this->assertDateIntervalEquals(new \DateInterval($output), $normalizer->denormalize($input, \DateInterval::class));
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
- */
public function testDenormalizeExpectsString()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException');
$this->normalizer->denormalize(1234, \DateInterval::class);
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\UnexpectedValueException
- * @expectedExceptionMessage Expected a valid ISO 8601 interval string.
- */
public function testDenormalizeNonISO8601IntervalStringThrowsException()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException');
+ $this->expectExceptionMessage('Expected a valid ISO 8601 interval string.');
$this->normalizer->denormalize('10 years 2 months 3 days', \DateInterval::class, null);
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\UnexpectedValueException
- */
public function testDenormalizeInvalidDataThrowsException()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException');
$this->normalizer->denormalize('invalid interval', \DateInterval::class);
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\UnexpectedValueException
- */
public function testDenormalizeFormatMismatchThrowsException()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException');
$this->normalizer->denormalize('P00Y00M00DT00H00M00S', \DateInterval::class, null, [DateIntervalNormalizer::FORMAT_KEY => 'P%yY%mM%dD']);
}
diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/DateTimeNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/DateTimeNormalizerTest.php
index 138c50ac05..e8cd3ceeda 100644
--- a/src/Symfony/Component/Serializer/Tests/Normalizer/DateTimeNormalizerTest.php
+++ b/src/Symfony/Component/Serializer/Tests/Normalizer/DateTimeNormalizerTest.php
@@ -158,12 +158,10 @@ class DateTimeNormalizerTest extends TestCase
];
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
- * @expectedExceptionMessage The object must implement the "\DateTimeInterface".
- */
public function testNormalizeInvalidObjectThrowsException()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('The object must implement the "\DateTimeInterface".');
$this->normalizer->normalize(new \stdClass());
}
@@ -239,37 +237,29 @@ class DateTimeNormalizerTest extends TestCase
];
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\UnexpectedValueException
- */
public function testDenormalizeInvalidDataThrowsException()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException');
$this->normalizer->denormalize('invalid date', \DateTimeInterface::class);
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\UnexpectedValueException
- * @expectedExceptionMessage The data is either an empty string or null, you should pass a string that can be parsed with the passed format or a valid DateTime string.
- */
public function testDenormalizeNullThrowsException()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException');
+ $this->expectExceptionMessage('The data is either an empty string or null, you should pass a string that can be parsed with the passed format or a valid DateTime string.');
$this->normalizer->denormalize(null, \DateTimeInterface::class);
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\UnexpectedValueException
- * @expectedExceptionMessage The data is either an empty string or null, you should pass a string that can be parsed with the passed format or a valid DateTime string.
- */
public function testDenormalizeEmptyStringThrowsException()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException');
+ $this->expectExceptionMessage('The data is either an empty string or null, you should pass a string that can be parsed with the passed format or a valid DateTime string.');
$this->normalizer->denormalize('', \DateTimeInterface::class);
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\UnexpectedValueException
- */
public function testDenormalizeFormatMismatchThrowsException()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException');
$this->normalizer->denormalize('2016-01-01T00:00:00+00:00', \DateTimeInterface::class, null, [DateTimeNormalizer::FORMAT_KEY => 'Y-m-d|']);
}
}
diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/DateTimeZoneNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/DateTimeZoneNormalizerTest.php
index c2a851ef78..91d144e844 100644
--- a/src/Symfony/Component/Serializer/Tests/Normalizer/DateTimeZoneNormalizerTest.php
+++ b/src/Symfony/Component/Serializer/Tests/Normalizer/DateTimeZoneNormalizerTest.php
@@ -42,11 +42,9 @@ class DateTimeZoneNormalizerTest extends TestCase
$this->assertEquals('Asia/Tokyo', $this->normalizer->normalize(new \DateTimeZone('Asia/Tokyo')));
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
- */
public function testNormalizeBadObjectTypeThrowsException()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException');
$this->normalizer->normalize(new \stdClass());
}
@@ -63,19 +61,15 @@ class DateTimeZoneNormalizerTest extends TestCase
$this->assertEquals(new \DateTimeZone('Asia/Tokyo'), $this->normalizer->denormalize('Asia/Tokyo', \DateTimeZone::class, null));
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\NotNormalizableValueException
- */
public function testDenormalizeNullTimeZoneThrowsException()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\NotNormalizableValueException');
$this->normalizer->denormalize(null, \DateTimeZone::class, null);
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\NotNormalizableValueException
- */
public function testDenormalizeBadTimeZoneThrowsException()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\NotNormalizableValueException');
$this->normalizer->denormalize('Jupiter/Europa', \DateTimeZone::class, null);
}
}
diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php
index f2adbb8c25..5fa964740e 100644
--- a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php
+++ b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php
@@ -364,12 +364,10 @@ class GetSetMethodNormalizerTest extends TestCase
return $normalizer;
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\LogicException
- * @expectedExceptionMessage Cannot normalize attribute "object" because the injected serializer is not a normalizer
- */
public function testUnableToNormalizeObjectAttribute()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\LogicException');
+ $this->expectExceptionMessage('Cannot normalize attribute "object" because the injected serializer is not a normalizer');
$serializer = $this->getMockBuilder('Symfony\Component\Serializer\SerializerInterface')->getMock();
$this->normalizer->setSerializer($serializer);
diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/JsonSerializableNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/JsonSerializableNormalizerTest.php
index f3d7f0d6e9..dfe5988e23 100644
--- a/src/Symfony/Component/Serializer/Tests/Normalizer/JsonSerializableNormalizerTest.php
+++ b/src/Symfony/Component/Serializer/Tests/Normalizer/JsonSerializableNormalizerTest.php
@@ -68,11 +68,9 @@ class JsonSerializableNormalizerTest extends TestCase
$this->assertEquals('string_object', $this->normalizer->normalize(new JsonSerializableDummy()));
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\CircularReferenceException
- */
public function testCircularNormalize()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\CircularReferenceException');
$this->createNormalizer([JsonSerializableNormalizer::CIRCULAR_REFERENCE_LIMIT => 1]);
$this->serializer
@@ -88,12 +86,10 @@ class JsonSerializableNormalizerTest extends TestCase
$this->assertEquals('string_object', $this->normalizer->normalize(new JsonSerializableDummy()));
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
- * @expectedExceptionMessage The object must implement "JsonSerializable".
- */
public function testInvalidDataThrowException()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('The object must implement "JsonSerializable".');
$this->normalizer->normalize(new \stdClass());
}
}
diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php
index 3ece2a0df5..3cc2e11d47 100644
--- a/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php
+++ b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php
@@ -230,12 +230,10 @@ class ObjectNormalizerTest extends TestCase
$this->assertNull($obj->getInner());
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\RuntimeException
- * @expectedExceptionMessage Could not determine the class of the parameter "unknown".
- */
public function testConstructorWithUnknownObjectTypeHintDenormalize()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\RuntimeException');
+ $this->expectExceptionMessage('Could not determine the class of the parameter "unknown".');
$data = [
'id' => 10,
'unknown' => [
@@ -490,12 +488,10 @@ class ObjectNormalizerTest extends TestCase
return $normalizer;
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\LogicException
- * @expectedExceptionMessage Cannot normalize attribute "object" because the injected serializer is not a normalizer
- */
public function testUnableToNormalizeObjectAttribute()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\LogicException');
+ $this->expectExceptionMessage('Cannot normalize attribute "object" because the injected serializer is not a normalizer');
$serializer = $this->getMockBuilder('Symfony\Component\Serializer\SerializerInterface')->getMock();
$this->normalizer->setSerializer($serializer);
@@ -545,11 +541,9 @@ class ObjectNormalizerTest extends TestCase
}]));
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\UnexpectedValueException
- */
public function testThrowUnexpectedValueException()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException');
$this->normalizer->denormalize(['foo' => 'bar'], ObjectTypeHinted::class);
}
diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php
index dbe281f62b..0ed5e34c00 100644
--- a/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php
+++ b/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php
@@ -313,12 +313,10 @@ class PropertyNormalizerTest extends TestCase
$this->assertEquals('out_of_scope', PropertyDummy::$outOfScope);
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\LogicException
- * @expectedExceptionMessage Cannot normalize attribute "bar" because the injected serializer is not a normalizer
- */
public function testUnableToNormalizeObjectAttribute()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\LogicException');
+ $this->expectExceptionMessage('Cannot normalize attribute "bar" because the injected serializer is not a normalizer');
$serializer = $this->getMockBuilder('Symfony\Component\Serializer\SerializerInterface')->getMock();
$this->normalizer->setSerializer($serializer);
diff --git a/src/Symfony/Component/Serializer/Tests/SerializerTest.php b/src/Symfony/Component/Serializer/Tests/SerializerTest.php
index bac467caf8..400668d0aa 100644
--- a/src/Symfony/Component/Serializer/Tests/SerializerTest.php
+++ b/src/Symfony/Component/Serializer/Tests/SerializerTest.php
@@ -13,6 +13,7 @@ namespace Symfony\Component\Serializer\Tests;
use Doctrine\Common\Annotations\AnnotationReader;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor;
use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
@@ -46,6 +47,8 @@ use Symfony\Component\Serializer\Tests\Normalizer\TestNormalizer;
class SerializerTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testInterface()
{
$serializer = new Serializer();
@@ -57,29 +60,25 @@ class SerializerTest extends TestCase
$this->assertInstanceOf('Symfony\Component\Serializer\Encoder\DecoderInterface', $serializer);
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
- * @expectedExceptionMessage The class "stdClass" neither implements "Symfony\Component\Serializer\Normalizer\NormalizerInterface" nor "Symfony\Component\Serializer\Normalizer\DenormalizerInterface".
- */
public function testItThrowsExceptionOnInvalidNormalizer()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('The class "stdClass" neither implements "Symfony\\Component\\Serializer\\Normalizer\\NormalizerInterface" nor "Symfony\\Component\\Serializer\\Normalizer\\DenormalizerInterface".');
+
new Serializer([new \stdClass()]);
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
- * @expectedExceptionMessage The class "stdClass" neither implements "Symfony\Component\Serializer\Encoder\EncoderInterface" nor "Symfony\Component\Serializer\Encoder\DecoderInterface"
- */
public function testItThrowsExceptionOnInvalidEncoder()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('The class "stdClass" neither implements "Symfony\\Component\\Serializer\\Encoder\\EncoderInterface" nor "Symfony\\Component\\Serializer\\Encoder\\DecoderInterface"');
+
new Serializer([], [new \stdClass()]);
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\UnexpectedValueException
- */
public function testNormalizeNoMatch()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException');
$serializer = new Serializer([$this->getMockBuilder('Symfony\Component\Serializer\Normalizer\CustomNormalizer')->getMock()]);
$serializer->normalize(new \stdClass(), 'xml');
}
@@ -98,29 +97,23 @@ class SerializerTest extends TestCase
$this->assertEquals('{"foo":"normalizedFoo","bar":"normalizedBar"}', $result);
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\UnexpectedValueException
- */
public function testNormalizeOnDenormalizer()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException');
$serializer = new Serializer([new TestDenormalizer()], []);
$this->assertTrue($serializer->normalize(new \stdClass(), 'json'));
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\UnexpectedValueException
- */
public function testDenormalizeNoMatch()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException');
$serializer = new Serializer([$this->getMockBuilder('Symfony\Component\Serializer\Normalizer\CustomNormalizer')->getMock()]);
$serializer->denormalize('foo', 'stdClass');
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\UnexpectedValueException
- */
public function testDenormalizeOnNormalizer()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException');
$serializer = new Serializer([new TestNormalizer()], []);
$data = ['title' => 'foo', 'numbers' => [5, 3]];
$this->assertTrue($serializer->denormalize(json_encode($data), 'stdClass', 'json'));
@@ -202,21 +195,17 @@ class SerializerTest extends TestCase
$this->assertEquals(json_encode($data), $result);
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\UnexpectedValueException
- */
public function testSerializeNoEncoder()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException');
$serializer = new Serializer([], []);
$data = ['title' => 'foo', 'numbers' => [5, 3]];
$serializer->serialize($data, 'json');
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\LogicException
- */
public function testSerializeNoNormalizer()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\LogicException');
$serializer = new Serializer([], ['json' => new JsonEncoder()]);
$data = ['title' => 'foo', 'numbers' => [5, 3]];
$serializer->serialize(Model::fromArray($data), 'json');
@@ -240,31 +229,25 @@ class SerializerTest extends TestCase
$this->assertEquals($data, $result->toArray());
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\LogicException
- */
public function testDeserializeNoNormalizer()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\LogicException');
$serializer = new Serializer([], ['json' => new JsonEncoder()]);
$data = ['title' => 'foo', 'numbers' => [5, 3]];
$serializer->deserialize(json_encode($data), '\Symfony\Component\Serializer\Tests\Model', 'json');
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\UnexpectedValueException
- */
public function testDeserializeWrongNormalizer()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException');
$serializer = new Serializer([new CustomNormalizer()], ['json' => new JsonEncoder()]);
$data = ['title' => 'foo', 'numbers' => [5, 3]];
$serializer->deserialize(json_encode($data), '\Symfony\Component\Serializer\Tests\Model', 'json');
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\UnexpectedValueException
- */
public function testDeserializeNoEncoder()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException');
$serializer = new Serializer([], []);
$data = ['title' => 'foo', 'numbers' => [5, 3]];
$serializer->deserialize(json_encode($data), '\Symfony\Component\Serializer\Tests\Model', 'json');
@@ -469,21 +452,17 @@ class SerializerTest extends TestCase
$this->assertEquals($example, $deserialized);
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\RuntimeException
- * @expectedExceptionMessage The type "second" has no mapped class for the abstract object "Symfony\Component\Serializer\Tests\Fixtures\DummyMessageInterface"
- */
public function testExceptionWhenTypeIsNotKnownInDiscriminator()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\RuntimeException');
+ $this->expectExceptionMessage('The type "second" has no mapped class for the abstract object "Symfony\Component\Serializer\Tests\Fixtures\DummyMessageInterface"');
$this->serializerWithClassDiscriminator()->deserialize('{"type":"second","one":1}', DummyMessageInterface::class, 'json');
}
- /**
- * @expectedException \Symfony\Component\Serializer\Exception\RuntimeException
- * @expectedExceptionMessage Type property "type" not found for the abstract object "Symfony\Component\Serializer\Tests\Fixtures\DummyMessageInterface"
- */
public function testExceptionWhenTypeIsNotInTheBodyToDeserialiaze()
{
+ $this->expectException('Symfony\Component\Serializer\Exception\RuntimeException');
+ $this->expectExceptionMessage('Type property "type" not found for the abstract object "Symfony\Component\Serializer\Tests\Fixtures\DummyMessageInterface"');
$this->serializerWithClassDiscriminator()->deserialize('{"one":1}', DummyMessageInterface::class, 'json');
}
diff --git a/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php b/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php
index 5d94e48fe8..dade44350f 100644
--- a/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php
+++ b/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\Stopwatch\Tests;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Stopwatch\StopwatchEvent;
/**
@@ -23,6 +24,8 @@ use Symfony\Component\Stopwatch\StopwatchEvent;
*/
class StopwatchEventTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
const DELTA = 37;
public function testGetOrigin()
@@ -103,11 +106,9 @@ class StopwatchEventTest extends TestCase
$this->assertEquals(100, $event->getDuration(), '', self::DELTA);
}
- /**
- * @expectedException \LogicException
- */
public function testStopWithoutStart()
{
+ $this->expectException('LogicException');
$event = new StopwatchEvent(microtime(true) * 1000);
$event->stop();
}
diff --git a/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php b/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php
index d70e803e43..6a7ef1582c 100644
--- a/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php
+++ b/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php
@@ -93,20 +93,16 @@ class StopwatchTest extends TestCase
$this->assertEquals(200, $event->getDuration(), '', self::DELTA);
}
- /**
- * @expectedException \LogicException
- */
public function testUnknownEvent()
{
+ $this->expectException('LogicException');
$stopwatch = new Stopwatch();
$stopwatch->getEvent('foo');
}
- /**
- * @expectedException \LogicException
- */
public function testStopWithoutStart()
{
+ $this->expectException('LogicException');
$stopwatch = new Stopwatch();
$stopwatch->stop('foo');
}
@@ -168,11 +164,9 @@ class StopwatchTest extends TestCase
$this->assertCount(2, $events['__section__']->getPeriods());
}
- /**
- * @expectedException \LogicException
- */
public function testReopenANewSectionShouldThrowAnException()
{
+ $this->expectException('LogicException');
$stopwatch = new Stopwatch();
$stopwatch->openSection('section');
}
diff --git a/src/Symfony/Component/Templating/Tests/DelegatingEngineTest.php b/src/Symfony/Component/Templating/Tests/DelegatingEngineTest.php
index 3d61ec2716..07c3387d46 100644
--- a/src/Symfony/Component/Templating/Tests/DelegatingEngineTest.php
+++ b/src/Symfony/Component/Templating/Tests/DelegatingEngineTest.php
@@ -12,12 +12,15 @@
namespace Symfony\Component\Templating\Tests;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Templating\DelegatingEngine;
use Symfony\Component\Templating\EngineInterface;
use Symfony\Component\Templating\StreamingEngineInterface;
class DelegatingEngineTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testRenderDelegatesToSupportedEngine()
{
$firstEngine = $this->getEngineMock('template.php', false);
@@ -34,12 +37,10 @@ class DelegatingEngineTest extends TestCase
$this->assertSame('', $result);
}
- /**
- * @expectedException \RuntimeException
- * @expectedExceptionMessage No engine is able to work with the template "template.php"
- */
public function testRenderWithNoSupportedEngine()
{
+ $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);
@@ -61,12 +62,10 @@ class DelegatingEngineTest extends TestCase
$this->assertNull($result);
}
- /**
- * @expectedException \LogicException
- * @expectedExceptionMessage Template "template.php" cannot be streamed as the engine supporting it does not implement StreamingEngineInterface
- */
public function testStreamRequiresStreamingEngine()
{
+ $this->expectException('LogicException');
+ $this->expectExceptionMessage('Template "template.php" cannot be streamed as the engine supporting it does not implement StreamingEngineInterface');
$delegatingEngine = new DelegatingEngine([new TestEngine()]);
$delegatingEngine->stream('template.php', ['foo' => 'bar']);
}
@@ -112,12 +111,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);
diff --git a/src/Symfony/Component/Templating/Tests/PhpEngineTest.php b/src/Symfony/Component/Templating/Tests/PhpEngineTest.php
index cfa6c17516..244e8b8f79 100644
--- a/src/Symfony/Component/Templating/Tests/PhpEngineTest.php
+++ b/src/Symfony/Component/Templating/Tests/PhpEngineTest.php
@@ -127,11 +127,11 @@ class PhpEngineTest extends TestCase
}
/**
- * @expectedException \InvalidArgumentException
* @dataProvider forbiddenParameterNames
*/
public function testRenderForbiddenParameter($name)
{
+ $this->expectException('InvalidArgumentException');
$engine = new ProjectTemplateEngine(new TemplateNameParser(), $this->loader);
$this->loader->setTemplate('foo.php', 'bar');
$engine->render('foo.php', [$name => 'foo']);
diff --git a/src/Symfony/Component/Translation/Tests/Command/XliffLintCommandTest.php b/src/Symfony/Component/Translation/Tests/Command/XliffLintCommandTest.php
index abda2135fc..472c510365 100644
--- a/src/Symfony/Component/Translation/Tests/Command/XliffLintCommandTest.php
+++ b/src/Symfony/Component/Translation/Tests/Command/XliffLintCommandTest.php
@@ -105,11 +105,9 @@ class XliffLintCommandTest extends TestCase
$this->assertContains('[OK] All 1 XLIFF files contain valid syntax.', trim($tester->getDisplay()));
}
- /**
- * @expectedException \RuntimeException
- */
public function testLintFileNotReadable()
{
+ $this->expectException('RuntimeException');
$tester = $this->createCommandTester();
$filename = $this->createFile();
unlink($filename);
diff --git a/src/Symfony/Component/Translation/Tests/DependencyInjection/TranslationExtractorPassTest.php b/src/Symfony/Component/Translation/Tests/DependencyInjection/TranslationExtractorPassTest.php
index a638498b6b..b9996c8ed3 100644
--- a/src/Symfony/Component/Translation/Tests/DependencyInjection/TranslationExtractorPassTest.php
+++ b/src/Symfony/Component/Translation/Tests/DependencyInjection/TranslationExtractorPassTest.php
@@ -12,12 +12,15 @@
namespace Symfony\Component\Translation\Tests\DependencyInjection;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\Translation\DependencyInjection\TranslationExtractorPass;
class TranslationExtractorPassTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testProcess()
{
$container = new ContainerBuilder();
@@ -46,12 +49,10 @@ class TranslationExtractorPassTest extends TestCase
$this->assertCount($aliasesBefore, $container->getAliases());
}
- /**
- * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
- * @expectedExceptionMessage The alias for the tag "translation.extractor" of service "foo.id" must be set.
- */
public function testProcessMissingAlias()
{
+ $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
+ $this->expectExceptionMessage('The alias for the tag "translation.extractor" of service "foo.id" must be set.');
$definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->disableOriginalConstructor()->getMock();
$container = new ContainerBuilder();
$container->register('translation.extractor');
diff --git a/src/Symfony/Component/Translation/Tests/Loader/CsvFileLoaderTest.php b/src/Symfony/Component/Translation/Tests/Loader/CsvFileLoaderTest.php
index 4fd5752db2..13b76bf35b 100644
--- a/src/Symfony/Component/Translation/Tests/Loader/CsvFileLoaderTest.php
+++ b/src/Symfony/Component/Translation/Tests/Loader/CsvFileLoaderTest.php
@@ -12,11 +12,14 @@
namespace Symfony\Component\Translation\Tests\Loader;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\Translation\Loader\CsvFileLoader;
class CsvFileLoaderTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testLoad()
{
$loader = new CsvFileLoader();
@@ -39,21 +42,17 @@ class CsvFileLoaderTest extends TestCase
$this->assertEquals([new FileResource($resource)], $catalogue->getResources());
}
- /**
- * @expectedException \Symfony\Component\Translation\Exception\NotFoundResourceException
- */
public function testLoadNonExistingResource()
{
+ $this->expectException('Symfony\Component\Translation\Exception\NotFoundResourceException');
$loader = new CsvFileLoader();
$resource = __DIR__.'/../fixtures/not-exists.csv';
$loader->load($resource, 'en', 'domain1');
}
- /**
- * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
- */
public function testLoadNonLocalResource()
{
+ $this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException');
$loader = new CsvFileLoader();
$resource = 'http://example.com/resources.csv';
$loader->load($resource, 'en', 'domain1');
diff --git a/src/Symfony/Component/Translation/Tests/Loader/IcuDatFileLoaderTest.php b/src/Symfony/Component/Translation/Tests/Loader/IcuDatFileLoaderTest.php
index 601680af8a..db845a8d82 100644
--- a/src/Symfony/Component/Translation/Tests/Loader/IcuDatFileLoaderTest.php
+++ b/src/Symfony/Component/Translation/Tests/Loader/IcuDatFileLoaderTest.php
@@ -11,6 +11,7 @@
namespace Symfony\Component\Translation\Tests\Loader;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\Translation\Loader\IcuDatFileLoader;
@@ -19,11 +20,11 @@ use Symfony\Component\Translation\Loader\IcuDatFileLoader;
*/
class IcuDatFileLoaderTest extends LocalizedTestCase
{
- /**
- * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
- */
+ use ForwardCompatTestTrait;
+
public function testLoadInvalidResource()
{
+ $this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException');
$loader = new IcuDatFileLoader();
$loader->load(__DIR__.'/../fixtures/resourcebundle/corrupted/resources', 'es', 'domain2');
}
@@ -53,11 +54,9 @@ class IcuDatFileLoaderTest extends LocalizedTestCase
$this->assertEquals([new FileResource($resource.'.dat')], $catalogue->getResources());
}
- /**
- * @expectedException \Symfony\Component\Translation\Exception\NotFoundResourceException
- */
public function testLoadNonExistingResource()
{
+ $this->expectException('Symfony\Component\Translation\Exception\NotFoundResourceException');
$loader = new IcuDatFileLoader();
$loader->load(__DIR__.'/../fixtures/non-existing.txt', 'en', 'domain1');
}
diff --git a/src/Symfony/Component/Translation/Tests/Loader/IcuResFileLoaderTest.php b/src/Symfony/Component/Translation/Tests/Loader/IcuResFileLoaderTest.php
index 962c3af2ef..25d5082747 100644
--- a/src/Symfony/Component/Translation/Tests/Loader/IcuResFileLoaderTest.php
+++ b/src/Symfony/Component/Translation/Tests/Loader/IcuResFileLoaderTest.php
@@ -11,6 +11,7 @@
namespace Symfony\Component\Translation\Tests\Loader;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Config\Resource\DirectoryResource;
use Symfony\Component\Translation\Loader\IcuResFileLoader;
@@ -19,6 +20,8 @@ use Symfony\Component\Translation\Loader\IcuResFileLoader;
*/
class IcuResFileLoaderTest extends LocalizedTestCase
{
+ use ForwardCompatTestTrait;
+
public function testLoad()
{
// resource is build using genrb command
@@ -31,20 +34,16 @@ class IcuResFileLoaderTest extends LocalizedTestCase
$this->assertEquals([new DirectoryResource($resource)], $catalogue->getResources());
}
- /**
- * @expectedException \Symfony\Component\Translation\Exception\NotFoundResourceException
- */
public function testLoadNonExistingResource()
{
+ $this->expectException('Symfony\Component\Translation\Exception\NotFoundResourceException');
$loader = new IcuResFileLoader();
$loader->load(__DIR__.'/../fixtures/non-existing.txt', 'en', 'domain1');
}
- /**
- * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
- */
public function testLoadInvalidResource()
{
+ $this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException');
$loader = new IcuResFileLoader();
$loader->load(__DIR__.'/../fixtures/resourcebundle/corrupted', 'en', 'domain1');
}
diff --git a/src/Symfony/Component/Translation/Tests/Loader/IniFileLoaderTest.php b/src/Symfony/Component/Translation/Tests/Loader/IniFileLoaderTest.php
index e0d8b2f4c4..47ffc9b967 100644
--- a/src/Symfony/Component/Translation/Tests/Loader/IniFileLoaderTest.php
+++ b/src/Symfony/Component/Translation/Tests/Loader/IniFileLoaderTest.php
@@ -12,11 +12,14 @@
namespace Symfony\Component\Translation\Tests\Loader;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\Translation\Loader\IniFileLoader;
class IniFileLoaderTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testLoad()
{
$loader = new IniFileLoader();
@@ -39,11 +42,9 @@ class IniFileLoaderTest extends TestCase
$this->assertEquals([new FileResource($resource)], $catalogue->getResources());
}
- /**
- * @expectedException \Symfony\Component\Translation\Exception\NotFoundResourceException
- */
public function testLoadNonExistingResource()
{
+ $this->expectException('Symfony\Component\Translation\Exception\NotFoundResourceException');
$loader = new IniFileLoader();
$resource = __DIR__.'/../fixtures/non-existing.ini';
$loader->load($resource, 'en', 'domain1');
diff --git a/src/Symfony/Component/Translation/Tests/Loader/JsonFileLoaderTest.php b/src/Symfony/Component/Translation/Tests/Loader/JsonFileLoaderTest.php
index 4c507da5ab..0d452e16df 100644
--- a/src/Symfony/Component/Translation/Tests/Loader/JsonFileLoaderTest.php
+++ b/src/Symfony/Component/Translation/Tests/Loader/JsonFileLoaderTest.php
@@ -12,11 +12,14 @@
namespace Symfony\Component\Translation\Tests\Loader;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\Translation\Loader\JsonFileLoader;
class JsonFileLoaderTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testLoad()
{
$loader = new JsonFileLoader();
@@ -39,22 +42,18 @@ class JsonFileLoaderTest extends TestCase
$this->assertEquals([new FileResource($resource)], $catalogue->getResources());
}
- /**
- * @expectedException \Symfony\Component\Translation\Exception\NotFoundResourceException
- */
public function testLoadNonExistingResource()
{
+ $this->expectException('Symfony\Component\Translation\Exception\NotFoundResourceException');
$loader = new JsonFileLoader();
$resource = __DIR__.'/../fixtures/non-existing.json';
$loader->load($resource, 'en', 'domain1');
}
- /**
- * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
- * @expectedExceptionMessage Error parsing JSON - Syntax error, malformed JSON
- */
public function testParseException()
{
+ $this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException');
+ $this->expectExceptionMessage('Error parsing JSON - Syntax error, malformed JSON');
$loader = new JsonFileLoader();
$resource = __DIR__.'/../fixtures/malformed.json';
$loader->load($resource, 'en', 'domain1');
diff --git a/src/Symfony/Component/Translation/Tests/Loader/MoFileLoaderTest.php b/src/Symfony/Component/Translation/Tests/Loader/MoFileLoaderTest.php
index d6adecb173..f89584259f 100644
--- a/src/Symfony/Component/Translation/Tests/Loader/MoFileLoaderTest.php
+++ b/src/Symfony/Component/Translation/Tests/Loader/MoFileLoaderTest.php
@@ -12,11 +12,14 @@
namespace Symfony\Component\Translation\Tests\Loader;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\Translation\Loader\MoFileLoader;
class MoFileLoaderTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testLoad()
{
$loader = new MoFileLoader();
@@ -42,21 +45,17 @@ class MoFileLoaderTest extends TestCase
$this->assertEquals([new FileResource($resource)], $catalogue->getResources());
}
- /**
- * @expectedException \Symfony\Component\Translation\Exception\NotFoundResourceException
- */
public function testLoadNonExistingResource()
{
+ $this->expectException('Symfony\Component\Translation\Exception\NotFoundResourceException');
$loader = new MoFileLoader();
$resource = __DIR__.'/../fixtures/non-existing.mo';
$loader->load($resource, 'en', 'domain1');
}
- /**
- * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
- */
public function testLoadInvalidResource()
{
+ $this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException');
$loader = new MoFileLoader();
$resource = __DIR__.'/../fixtures/empty.mo';
$loader->load($resource, 'en', 'domain1');
diff --git a/src/Symfony/Component/Translation/Tests/Loader/PhpFileLoaderTest.php b/src/Symfony/Component/Translation/Tests/Loader/PhpFileLoaderTest.php
index 68cb2d0b72..d6e9712200 100644
--- a/src/Symfony/Component/Translation/Tests/Loader/PhpFileLoaderTest.php
+++ b/src/Symfony/Component/Translation/Tests/Loader/PhpFileLoaderTest.php
@@ -12,11 +12,14 @@
namespace Symfony\Component\Translation\Tests\Loader;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\Translation\Loader\PhpFileLoader;
class PhpFileLoaderTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testLoad()
{
$loader = new PhpFileLoader();
@@ -28,21 +31,17 @@ class PhpFileLoaderTest extends TestCase
$this->assertEquals([new FileResource($resource)], $catalogue->getResources());
}
- /**
- * @expectedException \Symfony\Component\Translation\Exception\NotFoundResourceException
- */
public function testLoadNonExistingResource()
{
+ $this->expectException('Symfony\Component\Translation\Exception\NotFoundResourceException');
$loader = new PhpFileLoader();
$resource = __DIR__.'/../fixtures/non-existing.php';
$loader->load($resource, 'en', 'domain1');
}
- /**
- * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
- */
public function testLoadThrowsAnExceptionIfFileNotLocal()
{
+ $this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException');
$loader = new PhpFileLoader();
$resource = 'http://example.com/resources.php';
$loader->load($resource, 'en', 'domain1');
diff --git a/src/Symfony/Component/Translation/Tests/Loader/PoFileLoaderTest.php b/src/Symfony/Component/Translation/Tests/Loader/PoFileLoaderTest.php
index cb94e90a94..e55d6db899 100644
--- a/src/Symfony/Component/Translation/Tests/Loader/PoFileLoaderTest.php
+++ b/src/Symfony/Component/Translation/Tests/Loader/PoFileLoaderTest.php
@@ -12,11 +12,14 @@
namespace Symfony\Component\Translation\Tests\Loader;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\Translation\Loader\PoFileLoader;
class PoFileLoaderTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testLoad()
{
$loader = new PoFileLoader();
@@ -53,11 +56,9 @@ class PoFileLoaderTest extends TestCase
$this->assertEquals([new FileResource($resource)], $catalogue->getResources());
}
- /**
- * @expectedException \Symfony\Component\Translation\Exception\NotFoundResourceException
- */
public function testLoadNonExistingResource()
{
+ $this->expectException('Symfony\Component\Translation\Exception\NotFoundResourceException');
$loader = new PoFileLoader();
$resource = __DIR__.'/../fixtures/non-existing.po';
$loader->load($resource, 'en', 'domain1');
diff --git a/src/Symfony/Component/Translation/Tests/Loader/QtFileLoaderTest.php b/src/Symfony/Component/Translation/Tests/Loader/QtFileLoaderTest.php
index e80d7c4b4e..6978c59ec5 100644
--- a/src/Symfony/Component/Translation/Tests/Loader/QtFileLoaderTest.php
+++ b/src/Symfony/Component/Translation/Tests/Loader/QtFileLoaderTest.php
@@ -35,31 +35,25 @@ class QtFileLoaderTest extends TestCase
$this->assertEquals([new FileResource($resource)], $catalogue->getResources());
}
- /**
- * @expectedException \Symfony\Component\Translation\Exception\NotFoundResourceException
- */
public function testLoadNonExistingResource()
{
+ $this->expectException('Symfony\Component\Translation\Exception\NotFoundResourceException');
$loader = new QtFileLoader();
$resource = __DIR__.'/../fixtures/non-existing.ts';
$loader->load($resource, 'en', 'domain1');
}
- /**
- * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
- */
public function testLoadNonLocalResource()
{
+ $this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException');
$loader = new QtFileLoader();
$resource = 'http://domain1.com/resources.ts';
$loader->load($resource, 'en', 'domain1');
}
- /**
- * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
- */
public function testLoadInvalidResource()
{
+ $this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException');
$loader = new QtFileLoader();
$resource = __DIR__.'/../fixtures/invalid-xml-resources.xlf';
$loader->load($resource, 'en', 'domain1');
diff --git a/src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php b/src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php
index 700a7a33e7..1db28d773b 100644
--- a/src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php
+++ b/src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php
@@ -109,50 +109,40 @@ class XliffFileLoaderTest extends TestCase
$this->assertEquals('translated', $metadata['target-attributes']['state']);
}
- /**
- * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
- */
public function testLoadInvalidResource()
{
+ $this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException');
$loader = new XliffFileLoader();
$loader->load(__DIR__.'/../fixtures/resources.php', 'en', 'domain1');
}
- /**
- * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
- */
public function testLoadResourceDoesNotValidate()
{
+ $this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException');
$loader = new XliffFileLoader();
$loader->load(__DIR__.'/../fixtures/non-valid.xlf', 'en', 'domain1');
}
- /**
- * @expectedException \Symfony\Component\Translation\Exception\NotFoundResourceException
- */
public function testLoadNonExistingResource()
{
+ $this->expectException('Symfony\Component\Translation\Exception\NotFoundResourceException');
$loader = new XliffFileLoader();
$resource = __DIR__.'/../fixtures/non-existing.xlf';
$loader->load($resource, 'en', 'domain1');
}
- /**
- * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
- */
public function testLoadThrowsAnExceptionIfFileNotLocal()
{
+ $this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException');
$loader = new XliffFileLoader();
$resource = 'http://example.com/resources.xlf';
$loader->load($resource, 'en', 'domain1');
}
- /**
- * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
- * @expectedExceptionMessage Document types are not allowed.
- */
public function testDocTypeIsNotAllowed()
{
+ $this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException');
+ $this->expectExceptionMessage('Document types are not allowed.');
$loader = new XliffFileLoader();
$loader->load(__DIR__.'/../fixtures/withdoctype.xlf', 'en', 'domain1');
}
diff --git a/src/Symfony/Component/Translation/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/Translation/Tests/Loader/YamlFileLoaderTest.php
index a535db56fc..d05d65d030 100644
--- a/src/Symfony/Component/Translation/Tests/Loader/YamlFileLoaderTest.php
+++ b/src/Symfony/Component/Translation/Tests/Loader/YamlFileLoaderTest.php
@@ -12,11 +12,14 @@
namespace Symfony\Component\Translation\Tests\Loader;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\Translation\Loader\YamlFileLoader;
class YamlFileLoaderTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testLoad()
{
$loader = new YamlFileLoader();
@@ -39,31 +42,25 @@ class YamlFileLoaderTest extends TestCase
$this->assertEquals([new FileResource($resource)], $catalogue->getResources());
}
- /**
- * @expectedException \Symfony\Component\Translation\Exception\NotFoundResourceException
- */
public function testLoadNonExistingResource()
{
+ $this->expectException('Symfony\Component\Translation\Exception\NotFoundResourceException');
$loader = new YamlFileLoader();
$resource = __DIR__.'/../fixtures/non-existing.yml';
$loader->load($resource, 'en', 'domain1');
}
- /**
- * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
- */
public function testLoadThrowsAnExceptionIfFileNotLocal()
{
+ $this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException');
$loader = new YamlFileLoader();
$resource = 'http://example.com/resources.yml';
$loader->load($resource, 'en', 'domain1');
}
- /**
- * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
- */
public function testLoadThrowsAnExceptionIfNotAnArray()
{
+ $this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException');
$loader = new YamlFileLoader();
$resource = __DIR__.'/../fixtures/non-valid.yml';
$loader->load($resource, 'en', 'domain1');
diff --git a/src/Symfony/Component/Translation/Tests/MessageCatalogueTest.php b/src/Symfony/Component/Translation/Tests/MessageCatalogueTest.php
index cf0dd1a24c..fb87d02573 100644
--- a/src/Symfony/Component/Translation/Tests/MessageCatalogueTest.php
+++ b/src/Symfony/Component/Translation/Tests/MessageCatalogueTest.php
@@ -12,10 +12,13 @@
namespace Symfony\Component\Translation\Tests;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Translation\MessageCatalogue;
class MessageCatalogueTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testGetLocale()
{
$catalogue = new MessageCatalogue('en');
@@ -153,11 +156,9 @@ class MessageCatalogueTest extends TestCase
$this->assertEquals([$r, $r1, $r2], $catalogue->getResources());
}
- /**
- * @expectedException \Symfony\Component\Translation\Exception\LogicException
- */
public function testAddFallbackCatalogueWithParentCircularReference()
{
+ $this->expectException('Symfony\Component\Translation\Exception\LogicException');
$main = new MessageCatalogue('en_US');
$fallback = new MessageCatalogue('fr_FR');
@@ -165,11 +166,9 @@ class MessageCatalogueTest extends TestCase
$main->addFallbackCatalogue($fallback);
}
- /**
- * @expectedException \Symfony\Component\Translation\Exception\LogicException
- */
public function testAddFallbackCatalogueWithFallbackCircularReference()
{
+ $this->expectException('Symfony\Component\Translation\Exception\LogicException');
$fr = new MessageCatalogue('fr');
$en = new MessageCatalogue('en');
$es = new MessageCatalogue('es');
@@ -179,11 +178,9 @@ class MessageCatalogueTest extends TestCase
$en->addFallbackCatalogue($fr);
}
- /**
- * @expectedException \Symfony\Component\Translation\Exception\LogicException
- */
public function testAddCatalogueWhenLocaleIsNotTheSameAsTheCurrentOne()
{
+ $this->expectException('Symfony\Component\Translation\Exception\LogicException');
$catalogue = new MessageCatalogue('en');
$catalogue->addCatalogue(new MessageCatalogue('fr', []));
}
diff --git a/src/Symfony/Component/Translation/Tests/TranslatorTest.php b/src/Symfony/Component/Translation/Tests/TranslatorTest.php
index 7076f58213..efd8ac18c0 100644
--- a/src/Symfony/Component/Translation/Tests/TranslatorTest.php
+++ b/src/Symfony/Component/Translation/Tests/TranslatorTest.php
@@ -12,18 +12,21 @@
namespace Symfony\Component\Translation\Tests;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Translation\Loader\ArrayLoader;
use Symfony\Component\Translation\MessageCatalogue;
use Symfony\Component\Translation\Translator;
class TranslatorTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
/**
- * @dataProvider getInvalidLocalesTests
- * @expectedException \Symfony\Component\Translation\Exception\InvalidArgumentException
+ * @dataProvider getInvalidLocalesTests
*/
public function testConstructorInvalidLocale($locale)
{
+ $this->expectException('Symfony\Component\Translation\Exception\InvalidArgumentException');
new Translator($locale);
}
@@ -55,11 +58,11 @@ class TranslatorTest extends TestCase
}
/**
- * @dataProvider getInvalidLocalesTests
- * @expectedException \Symfony\Component\Translation\Exception\InvalidArgumentException
+ * @dataProvider getInvalidLocalesTests
*/
public function testSetInvalidLocale($locale)
{
+ $this->expectException('Symfony\Component\Translation\Exception\InvalidArgumentException');
$translator = new Translator('fr');
$translator->setLocale($locale);
}
@@ -138,11 +141,11 @@ class TranslatorTest extends TestCase
}
/**
- * @dataProvider getInvalidLocalesTests
- * @expectedException \Symfony\Component\Translation\Exception\InvalidArgumentException
+ * @dataProvider getInvalidLocalesTests
*/
public function testSetFallbackInvalidLocales($locale)
{
+ $this->expectException('Symfony\Component\Translation\Exception\InvalidArgumentException');
$translator = new Translator('fr');
$translator->setFallbackLocales(['fr', $locale]);
}
@@ -170,11 +173,11 @@ class TranslatorTest extends TestCase
}
/**
- * @dataProvider getInvalidLocalesTests
- * @expectedException \Symfony\Component\Translation\Exception\InvalidArgumentException
+ * @dataProvider getInvalidLocalesTests
*/
public function testAddResourceInvalidLocales($locale)
{
+ $this->expectException('Symfony\Component\Translation\Exception\InvalidArgumentException');
$translator = new Translator('fr');
$translator->addResource('array', ['foo' => 'foofoo'], $locale);
}
@@ -208,11 +211,11 @@ class TranslatorTest extends TestCase
}
/**
- * @dataProvider getTransFileTests
- * @expectedException \Symfony\Component\Translation\Exception\NotFoundResourceException
+ * @dataProvider getTransFileTests
*/
public function testTransWithoutFallbackLocaleFile($format, $loader)
{
+ $this->expectException('Symfony\Component\Translation\Exception\NotFoundResourceException');
$loaderClass = 'Symfony\\Component\\Translation\\Loader\\'.$loader;
$translator = new Translator('en');
$translator->addLoader($format, new $loaderClass());
@@ -303,11 +306,9 @@ class TranslatorTest extends TestCase
$this->assertEquals('non-existent', $translator->trans('non-existent'));
}
- /**
- * @expectedException \Symfony\Component\Translation\Exception\RuntimeException
- */
public function testWhenAResourceHasNoRegisteredLoader()
{
+ $this->expectException('Symfony\Component\Translation\Exception\RuntimeException');
$translator = new Translator('en');
$translator->addResource('array', ['foo' => 'foofoo'], 'en');
@@ -357,11 +358,11 @@ class TranslatorTest extends TestCase
}
/**
- * @dataProvider getInvalidLocalesTests
- * @expectedException \Symfony\Component\Translation\Exception\InvalidArgumentException
+ * @dataProvider getInvalidLocalesTests
*/
public function testTransInvalidLocale($locale)
{
+ $this->expectException('Symfony\Component\Translation\Exception\InvalidArgumentException');
$translator = new Translator('en');
$translator->addLoader('array', new ArrayLoader());
$translator->addResource('array', ['foo' => 'foofoo'], 'en');
diff --git a/src/Symfony/Component/Validator/Tests/ConstraintTest.php b/src/Symfony/Component/Validator/Tests/ConstraintTest.php
index cc36eaac8c..9ebcd4e84c 100644
--- a/src/Symfony/Component/Validator/Tests/ConstraintTest.php
+++ b/src/Symfony/Component/Validator/Tests/ConstraintTest.php
@@ -207,11 +207,9 @@ class ConstraintTest extends TestCase
$this->assertSame(['MyGroup'], $constraint->groups);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\InvalidArgumentException
- */
public function testGetErrorNameForUnknownCode()
{
+ $this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException');
Constraint::getErrorName(1);
}
@@ -226,12 +224,10 @@ class ConstraintTest extends TestCase
$this->assertEquals($options, $constraint->property2);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\InvalidOptionsException
- * @expectedExceptionMessage The options "0", "5" do not exist in constraint "Symfony\Component\Validator\Tests\Fixtures\ConstraintA".
- */
public function testInvalidOptions()
{
+ $this->expectException('Symfony\Component\Validator\Exception\InvalidOptionsException');
+ $this->expectExceptionMessage('The options "0", "5" do not exist in constraint "Symfony\Component\Validator\Tests\Fixtures\ConstraintA".');
new ConstraintA(['property2' => 'foo', 'bar', 5 => 'baz']);
}
@@ -246,12 +242,10 @@ class ConstraintTest extends TestCase
$this->assertEquals('foo', $constraint->property1);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- * @expectedExceptionMessage No default option is configured for constraint "Symfony\Component\Validator\Tests\Fixtures\ConstraintB".
- */
public function testAnnotationSetUndefinedDefaultOption()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
+ $this->expectExceptionMessage('No default option is configured for constraint "Symfony\Component\Validator\Tests\Fixtures\ConstraintB".');
new ConstraintB(['value' => 1]);
}
}
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php b/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php
index c70a2309a7..f4d3e5d3d0 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php
@@ -84,20 +84,18 @@ abstract class AbstractComparisonValidatorTestCase extends ConstraintValidatorTe
/**
* @dataProvider provideInvalidConstraintOptions
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- * @expectedExceptionMessage requires either the "value" or "propertyPath" option to be set.
*/
public function testThrowsConstraintExceptionIfNoValueOrPropertyPath($options)
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
+ $this->expectExceptionMessage('requires either the "value" or "propertyPath" option to be set.');
$this->createConstraint($options);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- * @expectedExceptionMessage requires only one of the "value" or "propertyPath" options to be set, not both.
- */
public function testThrowsConstraintExceptionIfBothValueAndPropertyPath()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
+ $this->expectExceptionMessage('requires only one of the "value" or "propertyPath" options to be set, not both.');
$this->createConstraint(([
'value' => 'value',
'propertyPath' => 'propertyPath',
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/AllTest.php b/src/Symfony/Component/Validator/Tests/Constraints/AllTest.php
index cdd72a22eb..450248a6b3 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/AllTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/AllTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\Validator\Tests\Constraints;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Validator\Constraints\All;
use Symfony\Component\Validator\Constraints\Valid;
@@ -20,21 +21,19 @@ use Symfony\Component\Validator\Constraints\Valid;
*/
class AllTest extends TestCase
{
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- */
+ use ForwardCompatTestTrait;
+
public function testRejectNonConstraints()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
new All([
'foo',
]);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- */
public function testRejectValidConstraint()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
new All([
new Valid(),
]);
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/AllValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/AllValidatorTest.php
index a0c64b5082..db7032fe14 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/AllValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/AllValidatorTest.php
@@ -11,6 +11,7 @@
namespace Symfony\Component\Validator\Tests\Constraints;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Validator\Constraints\All;
use Symfony\Component\Validator\Constraints\AllValidator;
use Symfony\Component\Validator\Constraints\NotNull;
@@ -19,6 +20,8 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
class AllValidatorTest extends ConstraintValidatorTestCase
{
+ use ForwardCompatTestTrait;
+
protected function createValidator()
{
return new AllValidator();
@@ -31,11 +34,9 @@ class AllValidatorTest extends ConstraintValidatorTestCase
$this->assertNoViolation();
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\UnexpectedValueException
- */
public function testThrowsExceptionIfNotTraversable()
{
+ $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException');
$this->validator->validate('foo.barbar', new All(new Range(['min' => 4])));
}
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/BicValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/BicValidatorTest.php
index b13fd874ff..80c00423e7 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/BicValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/BicValidatorTest.php
@@ -103,12 +103,10 @@ class BicValidatorTest extends ConstraintValidatorTestCase
$this->assertNoViolation();
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- * @expectedExceptionMessage The "iban" and "ibanPropertyPath" options of the Iban constraint cannot be used at the same time
- */
public function testThrowsConstraintExceptionIfBothValueAndPropertyPath()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
+ $this->expectExceptionMessage('The "iban" and "ibanPropertyPath" options of the Iban constraint cannot be used at the same time');
new Bic([
'iban' => 'value',
'ibanPropertyPath' => 'propertyPath',
@@ -129,11 +127,9 @@ class BicValidatorTest extends ConstraintValidatorTestCase
$this->validator->validate('UNCRIT2B912', $constraint);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\UnexpectedValueException
- */
public function testExpectsStringCompatibleType()
{
+ $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException');
$this->validator->validate(new \stdClass(), new Bic());
}
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CallbackValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CallbackValidatorTest.php
index 1c771c2c13..61b72e03aa 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/CallbackValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/CallbackValidatorTest.php
@@ -11,6 +11,7 @@
namespace Symfony\Component\Validator\Tests\Constraints;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Constraints\Callback;
use Symfony\Component\Validator\Constraints\CallbackValidator;
@@ -46,6 +47,8 @@ class CallbackValidatorTest_Object
class CallbackValidatorTest extends ConstraintValidatorTestCase
{
+ use ForwardCompatTestTrait;
+
protected function createValidator()
{
return new CallbackValidator();
@@ -180,21 +183,17 @@ class CallbackValidatorTest extends ConstraintValidatorTestCase
->assertRaised();
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- */
public function testExpectValidMethods()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
$object = new CallbackValidatorTest_Object();
$this->validator->validate($object, new Callback(['callback' => ['foobar']]));
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- */
public function testExpectValidCallbacks()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
$object = new CallbackValidatorTest_Object();
$this->validator->validate($object, new Callback(['callback' => ['foo', 'bar']]));
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php
index e55d19aa82..218d403af8 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php
@@ -11,6 +11,7 @@
namespace Symfony\Component\Validator\Tests\Constraints;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Validator\Constraints\Choice;
use Symfony\Component\Validator\Constraints\ChoiceValidator;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
@@ -22,6 +23,8 @@ function choice_callback()
class ChoiceValidatorTest extends ConstraintValidatorTestCase
{
+ use ForwardCompatTestTrait;
+
protected function createValidator()
{
return new ChoiceValidator();
@@ -37,11 +40,9 @@ class ChoiceValidatorTest extends ConstraintValidatorTestCase
return ['foo', 'bar'];
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\UnexpectedValueException
- */
public function testExpectArrayIfMultipleIsTrue()
{
+ $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException');
$constraint = new Choice([
'choices' => ['foo', 'bar'],
'multiple' => true,
@@ -62,19 +63,15 @@ class ChoiceValidatorTest extends ConstraintValidatorTestCase
$this->assertNoViolation();
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- */
public function testChoicesOrCallbackExpected()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
$this->validator->validate('foobar', new Choice());
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- */
public function testValidCallbackExpected()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
$this->validator->validate('foobar', new Choice(['callback' => 'abcd']));
}
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CollectionTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CollectionTest.php
index fec935082a..477e8b3844 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/CollectionTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/CollectionTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\Validator\Tests\Constraints;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Validator\Constraints\Collection;
use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Constraints\Optional;
@@ -23,51 +24,43 @@ use Symfony\Component\Validator\Constraints\Valid;
*/
class CollectionTest extends TestCase
{
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- */
+ use ForwardCompatTestTrait;
+
public function testRejectInvalidFieldsOption()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
new Collection([
'fields' => 'foo',
]);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- */
public function testRejectNonConstraints()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
new Collection([
'foo' => 'bar',
]);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- */
public function testRejectValidConstraint()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
new Collection([
'foo' => new Valid(),
]);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- */
public function testRejectValidConstraintWithinOptional()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
new Collection([
'foo' => new Optional(new Valid()),
]);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- */
public function testRejectValidConstraintWithinRequired()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
new Collection([
'foo' => new Required(new Valid()),
]);
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php
index 747be2499a..bf80c9bdd4 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php
@@ -11,6 +11,7 @@
namespace Symfony\Component\Validator\Tests\Constraints;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Validator\Constraints\Collection;
use Symfony\Component\Validator\Constraints\CollectionValidator;
use Symfony\Component\Validator\Constraints\NotNull;
@@ -21,6 +22,8 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
abstract class CollectionValidatorTest extends ConstraintValidatorTestCase
{
+ use ForwardCompatTestTrait;
+
protected function createValidator()
{
return new CollectionValidator();
@@ -52,11 +55,9 @@ abstract class CollectionValidatorTest extends ConstraintValidatorTestCase
$this->assertNoViolation();
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\UnexpectedValueException
- */
public function testThrowsExceptionIfNotTraversable()
{
+ $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException');
$this->validator->validate('foobar', new Collection(['fields' => [
'foo' => new Range(['min' => 4]),
]]));
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CompositeTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CompositeTest.php
index 3070e6a22f..4e6c891700 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/CompositeTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/CompositeTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\Validator\Tests\Constraints;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Validator\Constraints\Composite;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\NotNull;
@@ -37,6 +38,8 @@ class ConcreteComposite extends Composite
*/
class CompositeTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testMergeNestedGroupsIfNoExplicitParentGroup()
{
$constraint = new ConcreteComposite([
@@ -79,11 +82,9 @@ class CompositeTest extends TestCase
$this->assertEquals(['Strict'], $constraint->constraints[1]->groups);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- */
public function testFailIfExplicitNestedGroupsNotSubsetOfExplicitParentGroups()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
new ConcreteComposite([
'constraints' => [
new NotNull(['groups' => ['Default', 'Foobar']]),
@@ -114,33 +115,27 @@ class CompositeTest extends TestCase
$this->assertEquals([$nestedConstraint], $constraint->constraints);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- */
public function testFailIfNoConstraint()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
new ConcreteComposite([
new NotNull(['groups' => 'Default']),
'NotBlank',
]);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- */
public function testFailIfNoConstraintObject()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
new ConcreteComposite([
new NotNull(['groups' => 'Default']),
new \ArrayObject(),
]);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- */
public function testValidCantBeNested()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
new ConcreteComposite([
new Valid(),
]);
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorTest.php
index 7f019c78fb..e2a624e859 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorTest.php
@@ -11,6 +11,7 @@
namespace Symfony\Component\Validator\Tests\Constraints;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Validator\Constraints\Count;
use Symfony\Component\Validator\Constraints\CountValidator;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
@@ -20,6 +21,8 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
*/
abstract class CountValidatorTest extends ConstraintValidatorTestCase
{
+ use ForwardCompatTestTrait;
+
protected function createValidator()
{
return new CountValidator();
@@ -34,11 +37,9 @@ abstract class CountValidatorTest extends ConstraintValidatorTestCase
$this->assertNoViolation();
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\UnexpectedValueException
- */
public function testExpectsCountableType()
{
+ $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException');
$this->validator->validate(new \stdClass(), new Count(5));
}
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php
index 51352183e3..48edf6db3d 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php
@@ -11,6 +11,7 @@
namespace Symfony\Component\Validator\Tests\Constraints;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Intl\Util\IntlTestHelper;
use Symfony\Component\Validator\Constraints\Country;
use Symfony\Component\Validator\Constraints\CountryValidator;
@@ -18,6 +19,8 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
class CountryValidatorTest extends ConstraintValidatorTestCase
{
+ use ForwardCompatTestTrait;
+
protected function createValidator()
{
return new CountryValidator();
@@ -37,11 +40,9 @@ class CountryValidatorTest extends ConstraintValidatorTestCase
$this->assertNoViolation();
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\UnexpectedValueException
- */
public function testExpectsStringCompatibleType()
{
+ $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException');
$this->validator->validate(new \stdClass(), new Country());
}
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php
index 0e41a97561..0bb6fe2e28 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php
@@ -11,6 +11,7 @@
namespace Symfony\Component\Validator\Tests\Constraints;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Intl\Util\IntlTestHelper;
use Symfony\Component\Validator\Constraints\Currency;
use Symfony\Component\Validator\Constraints\CurrencyValidator;
@@ -18,6 +19,8 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
class CurrencyValidatorTest extends ConstraintValidatorTestCase
{
+ use ForwardCompatTestTrait;
+
protected function createValidator()
{
return new CurrencyValidator();
@@ -37,11 +40,9 @@ class CurrencyValidatorTest extends ConstraintValidatorTestCase
$this->assertNoViolation();
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\UnexpectedValueException
- */
public function testExpectsStringCompatibleType()
{
+ $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException');
$this->validator->validate(new \stdClass(), new Currency());
}
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php
index 968ce10178..5d22b6b163 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php
@@ -11,12 +11,15 @@
namespace Symfony\Component\Validator\Tests\Constraints;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Validator\Constraints\DateTime;
use Symfony\Component\Validator\Constraints\DateTimeValidator;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
class DateTimeValidatorTest extends ConstraintValidatorTestCase
{
+ use ForwardCompatTestTrait;
+
protected function createValidator()
{
return new DateTimeValidator();
@@ -36,11 +39,9 @@ class DateTimeValidatorTest extends ConstraintValidatorTestCase
$this->assertNoViolation();
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\UnexpectedValueException
- */
public function testExpectsStringCompatibleType()
{
+ $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException');
$this->validator->validate(new \stdClass(), new DateTime());
}
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php
index fa3bdd49ee..e3891152e4 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php
@@ -11,12 +11,15 @@
namespace Symfony\Component\Validator\Tests\Constraints;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Validator\Constraints\Date;
use Symfony\Component\Validator\Constraints\DateValidator;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
class DateValidatorTest extends ConstraintValidatorTestCase
{
+ use ForwardCompatTestTrait;
+
protected function createValidator()
{
return new DateValidator();
@@ -36,11 +39,9 @@ class DateValidatorTest extends ConstraintValidatorTestCase
$this->assertNoViolation();
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\UnexpectedValueException
- */
public function testExpectsStringCompatibleType()
{
+ $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException');
$this->validator->validate(new \stdClass(), new Date());
}
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/EmailTest.php b/src/Symfony/Component/Validator/Tests/Constraints/EmailTest.php
index 1472aaba12..57c71780df 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/EmailTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/EmailTest.php
@@ -23,12 +23,10 @@ class EmailTest extends TestCase
$this->assertEquals(Email::VALIDATION_MODE_STRICT, $subject->mode);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\InvalidArgumentException
- * @expectedExceptionMessage The "mode" parameter value is not valid.
- */
public function testUnknownModesTriggerException()
{
+ $this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('The "mode" parameter value is not valid.');
new Email(['mode' => 'Unknown Mode']);
}
@@ -39,21 +37,17 @@ class EmailTest extends TestCase
$this->assertEquals('trim', $email->normalizer);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\InvalidArgumentException
- * @expectedExceptionMessage The "normalizer" option must be a valid callable ("string" given).
- */
public function testInvalidNormalizerThrowsException()
{
+ $this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('The "normalizer" option must be a valid callable ("string" given).');
new Email(['normalizer' => 'Unknown Callable']);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\InvalidArgumentException
- * @expectedExceptionMessage The "normalizer" option must be a valid callable ("stdClass" given).
- */
public function testInvalidNormalizerObjectThrowsException()
{
+ $this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('The "normalizer" option must be a valid callable ("stdClass" given).');
new Email(['normalizer' => new \stdClass()]);
}
}
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php
index 2f3b1728d3..a84f8c00bc 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php
@@ -25,12 +25,10 @@ class EmailValidatorTest extends ConstraintValidatorTestCase
return new EmailValidator(Email::VALIDATION_MODE_LOOSE);
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage The "defaultMode" parameter value is not valid.
- */
public function testUnknownDefaultModeTriggerException()
{
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('The "defaultMode" parameter value is not valid.');
new EmailValidator('Unknown Mode');
}
@@ -48,11 +46,9 @@ class EmailValidatorTest extends ConstraintValidatorTestCase
$this->assertNoViolation();
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\UnexpectedValueException
- */
public function testExpectsStringCompatibleType()
{
+ $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException');
$this->validator->validate(new \stdClass(), new Email());
}
@@ -219,12 +215,10 @@ class EmailValidatorTest extends ConstraintValidatorTestCase
$this->assertNoViolation();
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage The Symfony\Component\Validator\Constraints\Email::$mode parameter value is not valid.
- */
public function testUnknownModesOnValidateTriggerException()
{
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('The Symfony\Component\Validator\Constraints\Email::$mode parameter value is not valid.');
$constraint = new Email();
$constraint->mode = 'Unknown Mode';
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/FileTest.php b/src/Symfony/Component/Validator/Tests/Constraints/FileTest.php
index e0b6ec8f41..39e375b5e5 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/FileTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/FileTest.php
@@ -12,11 +12,14 @@
namespace Symfony\Component\Validator\Tests\Constraints;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Validator\Constraints\File;
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
class FileTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
/**
* @dataProvider provideValidSizes
*/
@@ -52,10 +55,10 @@ class FileTest extends TestCase
/**
* @dataProvider provideInvalidSizes
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
*/
public function testInvalidValueForMaxSizeThrowsExceptionAfterInitialization($maxSize)
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
$file = new File(['maxSize' => 1000]);
$file->maxSize = $maxSize;
}
@@ -77,10 +80,10 @@ class FileTest extends TestCase
/**
* @dataProvider provideInValidSizes
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
*/
public function testInvalidMaxSize($maxSize)
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
new File(['maxSize' => $maxSize]);
}
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php
index cdcbe4e24b..336cf3893c 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php
@@ -69,11 +69,9 @@ abstract class FileValidatorTest extends ConstraintValidatorTestCase
$this->assertNoViolation();
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\UnexpectedValueException
- */
public function testExpectsStringCompatibleTypeOrFile()
{
+ $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException');
$this->validator->validate(new \stdClass(), new File());
}
@@ -227,11 +225,9 @@ abstract class FileValidatorTest extends ConstraintValidatorTestCase
$this->assertNoViolation();
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- */
public function testInvalidMaxSize()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
$constraint = new File([
'maxSize' => '1abc',
]);
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTest.php b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTest.php
index 6a81129ef9..8b7a2f45af 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTest.php
@@ -51,40 +51,34 @@ class GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTest extends Greate
];
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- * @expectedExceptionMessage The "propertyPath" option of the "Symfony\Component\Validator\Constraints\PositiveOrZero" constraint cannot be set.
- */
public function testThrowsConstraintExceptionIfPropertyPath()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
+ $this->expectExceptionMessage('The "propertyPath" option of the "Symfony\Component\Validator\Constraints\PositiveOrZero" constraint cannot be set.');
return new PositiveOrZero(['propertyPath' => 'field']);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- * @expectedExceptionMessage The "value" option of the "Symfony\Component\Validator\Constraints\PositiveOrZero" constraint cannot be set.
- */
public function testThrowsConstraintExceptionIfValue()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
+ $this->expectExceptionMessage('The "value" option of the "Symfony\Component\Validator\Constraints\PositiveOrZero" constraint cannot be set.');
return new PositiveOrZero(['value' => 0]);
}
/**
* @dataProvider provideInvalidConstraintOptions
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- * @expectedExceptionMessage requires either the "value" or "propertyPath" option to be set.
*/
public function testThrowsConstraintExceptionIfNoValueOrPropertyPath($options)
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
+ $this->expectExceptionMessage('requires either the "value" or "propertyPath" option to be set.');
$this->markTestSkipped('Value option always set for PositiveOrZero constraint');
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- * @expectedExceptionMessage requires only one of the "value" or "propertyPath" options to be set, not both.
- */
public function testThrowsConstraintExceptionIfBothValueAndPropertyPath()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
+ $this->expectExceptionMessage('requires only one of the "value" or "propertyPath" options to be set, not both.');
$this->markTestSkipped('Value option is set for PositiveOrZero constraint automatically');
}
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorWithPositiveConstraintTest.php b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorWithPositiveConstraintTest.php
index ca75286dc7..7aa647df45 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorWithPositiveConstraintTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorWithPositiveConstraintTest.php
@@ -49,40 +49,34 @@ class GreaterThanValidatorWithPositiveConstraintTest extends GreaterThanValidato
];
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- * @expectedExceptionMessage The "propertyPath" option of the "Symfony\Component\Validator\Constraints\Positive" constraint cannot be set.
- */
public function testThrowsConstraintExceptionIfPropertyPath()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
+ $this->expectExceptionMessage('The "propertyPath" option of the "Symfony\Component\Validator\Constraints\Positive" constraint cannot be set.');
return new Positive(['propertyPath' => 'field']);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- * @expectedExceptionMessage The "value" option of the "Symfony\Component\Validator\Constraints\Positive" constraint cannot be set.
- */
public function testThrowsConstraintExceptionIfValue()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
+ $this->expectExceptionMessage('The "value" option of the "Symfony\Component\Validator\Constraints\Positive" constraint cannot be set.');
return new Positive(['value' => 0]);
}
/**
* @dataProvider provideInvalidConstraintOptions
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- * @expectedExceptionMessage requires either the "value" or "propertyPath" option to be set.
*/
public function testThrowsConstraintExceptionIfNoValueOrPropertyPath($options)
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
+ $this->expectExceptionMessage('requires either the "value" or "propertyPath" option to be set.');
$this->markTestSkipped('Value option always set for Positive constraint.');
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- * @expectedExceptionMessage requires only one of the "value" or "propertyPath" options to be set, not both.
- */
public function testThrowsConstraintExceptionIfBothValueAndPropertyPath()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
+ $this->expectExceptionMessage('requires only one of the "value" or "propertyPath" options to be set, not both.');
$this->markTestSkipped('Value option is set for Positive constraint automatically');
}
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php
index 22bb93bd09..461ef5e628 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php
@@ -203,11 +203,9 @@ class ImageValidatorTest extends ConstraintValidatorTestCase
->assertRaised();
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- */
public function testInvalidMinWidth()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
$constraint = new Image([
'minWidth' => '1abc',
]);
@@ -215,11 +213,9 @@ class ImageValidatorTest extends ConstraintValidatorTestCase
$this->validator->validate($this->image, $constraint);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- */
public function testInvalidMaxWidth()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
$constraint = new Image([
'maxWidth' => '1abc',
]);
@@ -227,11 +223,9 @@ class ImageValidatorTest extends ConstraintValidatorTestCase
$this->validator->validate($this->image, $constraint);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- */
public function testInvalidMinHeight()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
$constraint = new Image([
'minHeight' => '1abc',
]);
@@ -239,11 +233,9 @@ class ImageValidatorTest extends ConstraintValidatorTestCase
$this->validator->validate($this->image, $constraint);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- */
public function testInvalidMaxHeight()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
$constraint = new Image([
'maxHeight' => '1abc',
]);
@@ -251,11 +243,9 @@ class ImageValidatorTest extends ConstraintValidatorTestCase
$this->validator->validate($this->image, $constraint);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- */
public function testInvalidMinPixels()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
$constraint = new Image([
'minPixels' => '1abc',
]);
@@ -263,11 +253,9 @@ class ImageValidatorTest extends ConstraintValidatorTestCase
$this->validator->validate($this->image, $constraint);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- */
public function testInvalidMaxPixels()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
$constraint = new Image([
'maxPixels' => '1abc',
]);
@@ -318,11 +306,9 @@ class ImageValidatorTest extends ConstraintValidatorTestCase
$this->assertNoViolation();
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- */
public function testInvalidMinRatio()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
$constraint = new Image([
'minRatio' => '1abc',
]);
@@ -330,11 +316,9 @@ class ImageValidatorTest extends ConstraintValidatorTestCase
$this->validator->validate($this->image, $constraint);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- */
public function testInvalidMaxRatio()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
$constraint = new Image([
'maxRatio' => '1abc',
]);
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IpTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IpTest.php
index 9aa851604b..f8147ac27f 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/IpTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/IpTest.php
@@ -26,21 +26,17 @@ class IpTest extends TestCase
$this->assertEquals('trim', $ip->normalizer);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\InvalidArgumentException
- * @expectedExceptionMessage The "normalizer" option must be a valid callable ("string" given).
- */
public function testInvalidNormalizerThrowsException()
{
+ $this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('The "normalizer" option must be a valid callable ("string" given).');
new Ip(['normalizer' => 'Unknown Callable']);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\InvalidArgumentException
- * @expectedExceptionMessage The "normalizer" option must be a valid callable ("stdClass" given).
- */
public function testInvalidNormalizerObjectThrowsException()
{
+ $this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('The "normalizer" option must be a valid callable ("stdClass" given).');
new Ip(['normalizer' => new \stdClass()]);
}
}
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php
index e589053083..8644888ed3 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php
@@ -11,12 +11,15 @@
namespace Symfony\Component\Validator\Tests\Constraints;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Validator\Constraints\Ip;
use Symfony\Component\Validator\Constraints\IpValidator;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
class IpValidatorTest extends ConstraintValidatorTestCase
{
+ use ForwardCompatTestTrait;
+
protected function createValidator()
{
return new IpValidator();
@@ -36,19 +39,15 @@ class IpValidatorTest extends ConstraintValidatorTestCase
$this->assertNoViolation();
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\UnexpectedValueException
- */
public function testExpectsStringCompatibleType()
{
+ $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException');
$this->validator->validate(new \stdClass(), new Ip());
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- */
public function testInvalidValidatorVersion()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
new Ip([
'version' => 666,
]);
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php
index 74aaf91272..2cd38e9afe 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php
@@ -11,6 +11,7 @@
namespace Symfony\Component\Validator\Tests\Constraints;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Validator\Constraints\Isbn;
use Symfony\Component\Validator\Constraints\IsbnValidator;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
@@ -20,6 +21,8 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
*/
class IsbnValidatorTest extends ConstraintValidatorTestCase
{
+ use ForwardCompatTestTrait;
+
protected function createValidator()
{
return new IsbnValidator();
@@ -136,11 +139,9 @@ class IsbnValidatorTest extends ConstraintValidatorTestCase
$this->assertNoViolation();
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\UnexpectedValueException
- */
public function testExpectsStringCompatibleType()
{
+ $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException');
$constraint = new Isbn(true);
$this->validator->validate(new \stdClass(), $constraint);
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IssnValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IssnValidatorTest.php
index ac82d69ba6..f26380d411 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/IssnValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/IssnValidatorTest.php
@@ -11,6 +11,7 @@
namespace Symfony\Component\Validator\Tests\Constraints;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Validator\Constraints\Issn;
use Symfony\Component\Validator\Constraints\IssnValidator;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
@@ -20,6 +21,8 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
*/
class IssnValidatorTest extends ConstraintValidatorTestCase
{
+ use ForwardCompatTestTrait;
+
protected function createValidator()
{
return new IssnValidator();
@@ -106,11 +109,9 @@ class IssnValidatorTest extends ConstraintValidatorTestCase
$this->assertNoViolation();
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\UnexpectedValueException
- */
public function testExpectsStringCompatibleType()
{
+ $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException');
$constraint = new Issn();
$this->validator->validate(new \stdClass(), $constraint);
}
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php
index 7d61dd4702..09c155b1e4 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php
@@ -11,6 +11,7 @@
namespace Symfony\Component\Validator\Tests\Constraints;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Intl\Util\IntlTestHelper;
use Symfony\Component\Validator\Constraints\Language;
use Symfony\Component\Validator\Constraints\LanguageValidator;
@@ -18,6 +19,8 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
class LanguageValidatorTest extends ConstraintValidatorTestCase
{
+ use ForwardCompatTestTrait;
+
protected function createValidator()
{
return new LanguageValidator();
@@ -37,11 +40,9 @@ class LanguageValidatorTest extends ConstraintValidatorTestCase
$this->assertNoViolation();
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\UnexpectedValueException
- */
public function testExpectsStringCompatibleType()
{
+ $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException');
$this->validator->validate(new \stdClass(), new Language());
}
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LengthTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LengthTest.php
index 6a20ff541f..b0caef17c9 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/LengthTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/LengthTest.php
@@ -26,21 +26,17 @@ class LengthTest extends TestCase
$this->assertEquals('trim', $length->normalizer);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\InvalidArgumentException
- * @expectedExceptionMessage The "normalizer" option must be a valid callable ("string" given).
- */
public function testInvalidNormalizerThrowsException()
{
+ $this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('The "normalizer" option must be a valid callable ("string" given).');
new Length(['min' => 0, 'max' => 10, 'normalizer' => 'Unknown Callable']);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\InvalidArgumentException
- * @expectedExceptionMessage The "normalizer" option must be a valid callable ("stdClass" given).
- */
public function testInvalidNormalizerObjectThrowsException()
{
+ $this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('The "normalizer" option must be a valid callable ("stdClass" given).');
new Length(['min' => 0, 'max' => 10, 'normalizer' => new \stdClass()]);
}
}
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LengthValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LengthValidatorTest.php
index 240552c428..04571cb5fb 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/LengthValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/LengthValidatorTest.php
@@ -11,12 +11,15 @@
namespace Symfony\Component\Validator\Tests\Constraints;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\LengthValidator;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
class LengthValidatorTest extends ConstraintValidatorTestCase
{
+ use ForwardCompatTestTrait;
+
protected function createValidator()
{
return new LengthValidator();
@@ -52,11 +55,9 @@ class LengthValidatorTest extends ConstraintValidatorTestCase
->assertRaised();
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\UnexpectedValueException
- */
public function testExpectsStringCompatibleType()
{
+ $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException');
$this->validator->validate(new \stdClass(), new Length(['value' => 5]));
}
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorWithNegativeOrZeroConstraintTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorWithNegativeOrZeroConstraintTest.php
index 45ebad541b..2967d82d44 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorWithNegativeOrZeroConstraintTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorWithNegativeOrZeroConstraintTest.php
@@ -49,40 +49,34 @@ class LessThanOrEqualValidatorWithNegativeOrZeroConstraintTest extends LessThanO
];
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- * @expectedExceptionMessage The "propertyPath" option of the "Symfony\Component\Validator\Constraints\NegativeOrZero" constraint cannot be set.
- */
public function testThrowsConstraintExceptionIfPropertyPath()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
+ $this->expectExceptionMessage('The "propertyPath" option of the "Symfony\Component\Validator\Constraints\NegativeOrZero" constraint cannot be set.');
return new NegativeOrZero(['propertyPath' => 'field']);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- * @expectedExceptionMessage The "value" option of the "Symfony\Component\Validator\Constraints\NegativeOrZero" constraint cannot be set.
- */
public function testThrowsConstraintExceptionIfValue()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
+ $this->expectExceptionMessage('The "value" option of the "Symfony\Component\Validator\Constraints\NegativeOrZero" constraint cannot be set.');
return new NegativeOrZero(['value' => 0]);
}
/**
* @dataProvider provideInvalidConstraintOptions
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- * @expectedExceptionMessage requires either the "value" or "propertyPath" option to be set.
*/
public function testThrowsConstraintExceptionIfNoValueOrPropertyPath($options)
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
+ $this->expectExceptionMessage('requires either the "value" or "propertyPath" option to be set.');
$this->markTestSkipped('Value option always set for NegativeOrZero constraint');
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- * @expectedExceptionMessage requires only one of the "value" or "propertyPath" options to be set, not both.
- */
public function testThrowsConstraintExceptionIfBothValueAndPropertyPath()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
+ $this->expectExceptionMessage('requires only one of the "value" or "propertyPath" options to be set, not both.');
$this->markTestSkipped('Value option is set for NegativeOrZero constraint automatically');
}
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorWithNegativeConstraintTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorWithNegativeConstraintTest.php
index 1a8fff7989..e38bdc4b5e 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorWithNegativeConstraintTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorWithNegativeConstraintTest.php
@@ -49,40 +49,34 @@ class LessThanValidatorWithNegativeConstraintTest extends LessThanValidatorTest
];
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- * @expectedExceptionMessage The "propertyPath" option of the "Symfony\Component\Validator\Constraints\Negative" constraint cannot be set.
- */
public function testThrowsConstraintExceptionIfPropertyPath()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
+ $this->expectExceptionMessage('The "propertyPath" option of the "Symfony\Component\Validator\Constraints\Negative" constraint cannot be set.');
return new Negative(['propertyPath' => 'field']);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- * @expectedExceptionMessage The "value" option of the "Symfony\Component\Validator\Constraints\Negative" constraint cannot be set.
- */
public function testThrowsConstraintExceptionIfValue()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
+ $this->expectExceptionMessage('The "value" option of the "Symfony\Component\Validator\Constraints\Negative" constraint cannot be set.');
return new Negative(['value' => 0]);
}
/**
* @dataProvider provideInvalidConstraintOptions
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- * @expectedExceptionMessage requires either the "value" or "propertyPath" option to be set.
*/
public function testThrowsConstraintExceptionIfNoValueOrPropertyPath($options)
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
+ $this->expectExceptionMessage('requires either the "value" or "propertyPath" option to be set.');
$this->markTestSkipped('Value option always set for Negative constraint');
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- * @expectedExceptionMessage requires only one of the "value" or "propertyPath" options to be set, not both.
- */
public function testThrowsConstraintExceptionIfBothValueAndPropertyPath()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
+ $this->expectExceptionMessage('requires only one of the "value" or "propertyPath" options to be set, not both.');
$this->markTestSkipped('Value option is set for Negative constraint automatically');
}
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php
index b3ff86ab6f..4f54f2cbdb 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php
@@ -11,12 +11,15 @@
namespace Symfony\Component\Validator\Tests\Constraints;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Validator\Constraints\Locale;
use Symfony\Component\Validator\Constraints\LocaleValidator;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
class LocaleValidatorTest extends ConstraintValidatorTestCase
{
+ use ForwardCompatTestTrait;
+
protected function createValidator()
{
return new LocaleValidator();
@@ -36,11 +39,9 @@ class LocaleValidatorTest extends ConstraintValidatorTestCase
$this->assertNoViolation();
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\UnexpectedValueException
- */
public function testExpectsStringCompatibleType()
{
+ $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException');
$this->validator->validate(new \stdClass(), new Locale());
}
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LuhnValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LuhnValidatorTest.php
index bc69dd78da..997cb7dfe2 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/LuhnValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/LuhnValidatorTest.php
@@ -11,12 +11,15 @@
namespace Symfony\Component\Validator\Tests\Constraints;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Validator\Constraints\Luhn;
use Symfony\Component\Validator\Constraints\LuhnValidator;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
class LuhnValidatorTest extends ConstraintValidatorTestCase
{
+ use ForwardCompatTestTrait;
+
protected function createValidator()
{
return new LuhnValidator();
@@ -99,11 +102,11 @@ class LuhnValidatorTest extends ConstraintValidatorTestCase
}
/**
- * @expectedException \Symfony\Component\Validator\Exception\UnexpectedValueException
* @dataProvider getInvalidTypes
*/
public function testInvalidTypes($number)
{
+ $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException');
$constraint = new Luhn();
$this->validator->validate($number, $constraint);
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/NotBlankTest.php b/src/Symfony/Component/Validator/Tests/Constraints/NotBlankTest.php
index af3b047fd8..285132a1f1 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/NotBlankTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/NotBlankTest.php
@@ -26,21 +26,17 @@ class NotBlankTest extends TestCase
$this->assertEquals('trim', $notBlank->normalizer);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\InvalidArgumentException
- * @expectedExceptionMessage The "normalizer" option must be a valid callable ("string" given).
- */
public function testInvalidNormalizerThrowsException()
{
+ $this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('The "normalizer" option must be a valid callable ("string" given).');
new NotBlank(['normalizer' => 'Unknown Callable']);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\InvalidArgumentException
- * @expectedExceptionMessage The "normalizer" option must be a valid callable ("stdClass" given).
- */
public function testInvalidNormalizerObjectThrowsException()
{
+ $this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('The "normalizer" option must be a valid callable ("stdClass" given).');
new NotBlank(['normalizer' => new \stdClass()]);
}
}
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/NotCompromisedPasswordValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/NotCompromisedPasswordValidatorTest.php
index f2330b52c7..a0277d45a6 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/NotCompromisedPasswordValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/NotCompromisedPasswordValidatorTest.php
@@ -151,28 +151,22 @@ class NotCompromisedPasswordValidatorTest extends ConstraintValidatorTestCase
->assertRaised();
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
- */
public function testInvalidConstraint()
{
+ $this->expectException('Symfony\Component\Validator\Exception\UnexpectedTypeException');
$this->validator->validate(null, new Luhn());
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
- */
public function testInvalidValue()
{
+ $this->expectException('Symfony\Component\Validator\Exception\UnexpectedTypeException');
$this->validator->validate([], new NotCompromisedPassword());
}
- /**
- * @expectedException \Symfony\Contracts\HttpClient\Exception\ExceptionInterface
- * @expectedExceptionMessage Problem contacting the Have I been Pwned API.
- */
public function testApiError()
{
+ $this->expectException('Symfony\Contracts\HttpClient\Exception\ExceptionInterface');
+ $this->expectExceptionMessage('Problem contacting the Have I been Pwned API.');
$this->validator->validate(self::PASSWORD_TRIGGERING_AN_ERROR, new NotCompromisedPassword());
}
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/RangeTest.php b/src/Symfony/Component/Validator/Tests/Constraints/RangeTest.php
index b860cb5778..333edada00 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/RangeTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/RangeTest.php
@@ -7,45 +7,37 @@ use Symfony\Component\Validator\Constraints\Range;
class RangeTest extends TestCase
{
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- * @expectedExceptionMessage requires only one of the "min" or "minPropertyPath" options to be set, not both.
- */
public function testThrowsConstraintExceptionIfBothMinLimitAndPropertyPath()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
+ $this->expectExceptionMessage('requires only one of the "min" or "minPropertyPath" options to be set, not both.');
new Range([
'min' => 'min',
'minPropertyPath' => 'minPropertyPath',
]);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- * @expectedExceptionMessage requires only one of the "max" or "maxPropertyPath" options to be set, not both.
- */
public function testThrowsConstraintExceptionIfBothMaxLimitAndPropertyPath()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
+ $this->expectExceptionMessage('requires only one of the "max" or "maxPropertyPath" options to be set, not both.');
new Range([
'max' => 'min',
'maxPropertyPath' => 'maxPropertyPath',
]);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\MissingOptionsException
- * @expectedExceptionMessage Either option "min", "minPropertyPath", "max" or "maxPropertyPath" must be given
- */
public function testThrowsConstraintExceptionIfNoLimitNorPropertyPath()
{
+ $this->expectException('Symfony\Component\Validator\Exception\MissingOptionsException');
+ $this->expectExceptionMessage('Either option "min", "minPropertyPath", "max" or "maxPropertyPath" must be given');
new Range([]);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- * @expectedExceptionMessage No default option is configured
- */
public function testThrowsNoDefaultOptionConfiguredException()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
+ $this->expectExceptionMessage('No default option is configured');
new Range('value');
}
}
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/RegexTest.php b/src/Symfony/Component/Validator/Tests/Constraints/RegexTest.php
index 53bb257d17..f49f2c0bb4 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/RegexTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/RegexTest.php
@@ -93,21 +93,17 @@ class RegexTest extends TestCase
$this->assertEquals('trim', $regex->normalizer);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\InvalidArgumentException
- * @expectedExceptionMessage The "normalizer" option must be a valid callable ("string" given).
- */
public function testInvalidNormalizerThrowsException()
{
+ $this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('The "normalizer" option must be a valid callable ("string" given).');
new Regex(['pattern' => '/^[0-9]+$/', 'normalizer' => 'Unknown Callable']);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\InvalidArgumentException
- * @expectedExceptionMessage The "normalizer" option must be a valid callable ("stdClass" given).
- */
public function testInvalidNormalizerObjectThrowsException()
{
+ $this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('The "normalizer" option must be a valid callable ("stdClass" given).');
new Regex(['pattern' => '/^[0-9]+$/', 'normalizer' => new \stdClass()]);
}
}
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php
index 9a54af88a8..63ce21b69f 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php
@@ -11,12 +11,15 @@
namespace Symfony\Component\Validator\Tests\Constraints;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Validator\Constraints\Regex;
use Symfony\Component\Validator\Constraints\RegexValidator;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
class RegexValidatorTest extends ConstraintValidatorTestCase
{
+ use ForwardCompatTestTrait;
+
protected function createValidator()
{
return new RegexValidator();
@@ -36,11 +39,9 @@ class RegexValidatorTest extends ConstraintValidatorTestCase
$this->assertNoViolation();
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\UnexpectedValueException
- */
public function testExpectsStringCompatibleType()
{
+ $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException');
$this->validator->validate(new \stdClass(), new Regex(['pattern' => '/^[0-9]+$/']));
}
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php
index da5b4eb9df..f67fdc77b3 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php
@@ -11,12 +11,15 @@
namespace Symfony\Component\Validator\Tests\Constraints;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Validator\Constraints\Time;
use Symfony\Component\Validator\Constraints\TimeValidator;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
class TimeValidatorTest extends ConstraintValidatorTestCase
{
+ use ForwardCompatTestTrait;
+
protected function createValidator()
{
return new TimeValidator();
@@ -36,11 +39,9 @@ class TimeValidatorTest extends ConstraintValidatorTestCase
$this->assertNoViolation();
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\UnexpectedValueException
- */
public function testExpectsStringCompatibleType()
{
+ $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException');
$this->validator->validate(new \stdClass(), new Time());
}
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/TimezoneTest.php b/src/Symfony/Component/Validator/Tests/Constraints/TimezoneTest.php
index 450c82ffeb..47566ea6de 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/TimezoneTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/TimezoneTest.php
@@ -32,31 +32,27 @@ class TimezoneTest extends TestCase
$this->addToAssertionCount(1);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- */
public function testExceptionForGroupedTimezonesByCountryWithWrongZone()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
new Timezone([
'zone' => \DateTimeZone::ALL,
'countryCode' => 'AR',
]);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- */
public function testExceptionForGroupedTimezonesByCountryWithoutZone()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
new Timezone(['countryCode' => 'AR']);
}
/**
* @dataProvider provideInvalidZones
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
*/
public function testExceptionForInvalidGroupedTimezones(int $zone)
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
new Timezone(['zone' => $zone]);
}
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/TimezoneValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/TimezoneValidatorTest.php
index 352e45c5d3..1f43224641 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/TimezoneValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/TimezoneValidatorTest.php
@@ -40,11 +40,9 @@ class TimezoneValidatorTest extends ConstraintValidatorTestCase
$this->assertNoViolation();
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\UnexpectedValueException
- */
public function testExpectsStringCompatibleType()
{
+ $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException');
$this->validator->validate(new \stdClass(), new Timezone());
}
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/UniqueValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/UniqueValidatorTest.php
index 65564abf9c..da46323db3 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/UniqueValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/UniqueValidatorTest.php
@@ -22,11 +22,9 @@ class UniqueValidatorTest extends ConstraintValidatorTestCase
return new UniqueValidator();
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\UnexpectedValueException
- */
public function testExpectsUniqueConstraintCompatibleType()
{
+ $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException');
$this->validator->validate('', new Unique());
}
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/UrlTest.php b/src/Symfony/Component/Validator/Tests/Constraints/UrlTest.php
index 6a9c45d417..c1799ed551 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/UrlTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/UrlTest.php
@@ -26,21 +26,17 @@ class UrlTest extends TestCase
$this->assertEquals('trim', $url->normalizer);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\InvalidArgumentException
- * @expectedExceptionMessage The "normalizer" option must be a valid callable ("string" given).
- */
public function testInvalidNormalizerThrowsException()
{
+ $this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('The "normalizer" option must be a valid callable ("string" given).');
new Url(['normalizer' => 'Unknown Callable']);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\InvalidArgumentException
- * @expectedExceptionMessage The "normalizer" option must be a valid callable ("stdClass" given).
- */
public function testInvalidNormalizerObjectThrowsException()
{
+ $this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('The "normalizer" option must be a valid callable ("stdClass" given).');
new Url(['normalizer' => new \stdClass()]);
}
}
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php
index 4f9daeba5c..5c67c6377b 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php
@@ -43,11 +43,9 @@ class UrlValidatorTest extends ConstraintValidatorTestCase
$this->assertNoViolation();
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\UnexpectedValueException
- */
public function testExpectsStringCompatibleType()
{
+ $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException');
$this->validator->validate(new \stdClass(), new Url());
}
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/UuidTest.php b/src/Symfony/Component/Validator/Tests/Constraints/UuidTest.php
index bfe3d5ed80..e048ecb211 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/UuidTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/UuidTest.php
@@ -26,21 +26,17 @@ class UuidTest extends TestCase
$this->assertEquals('trim', $uuid->normalizer);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\InvalidArgumentException
- * @expectedExceptionMessage The "normalizer" option must be a valid callable ("string" given).
- */
public function testInvalidNormalizerThrowsException()
{
+ $this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('The "normalizer" option must be a valid callable ("string" given).');
new Uuid(['normalizer' => 'Unknown Callable']);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\InvalidArgumentException
- * @expectedExceptionMessage The "normalizer" option must be a valid callable ("stdClass" given).
- */
public function testInvalidNormalizerObjectThrowsException()
{
+ $this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('The "normalizer" option must be a valid callable ("stdClass" given).');
new Uuid(['normalizer' => new \stdClass()]);
}
}
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/UuidValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/UuidValidatorTest.php
index 878e5d4234..b50321de1b 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/UuidValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/UuidValidatorTest.php
@@ -11,6 +11,7 @@
namespace Symfony\Component\Validator\Tests\Constraints;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Validator\Constraints\Uuid;
use Symfony\Component\Validator\Constraints\UuidValidator;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
@@ -20,6 +21,8 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
*/
class UuidValidatorTest extends ConstraintValidatorTestCase
{
+ use ForwardCompatTestTrait;
+
protected function createValidator()
{
return new UuidValidator();
@@ -39,21 +42,17 @@ class UuidValidatorTest extends ConstraintValidatorTestCase
$this->assertNoViolation();
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
- */
public function testExpectsUuidConstraintCompatibleType()
{
+ $this->expectException('Symfony\Component\Validator\Exception\UnexpectedTypeException');
$constraint = $this->getMockForAbstractClass('Symfony\\Component\\Validator\\Constraint');
$this->validator->validate('216fff40-98d9-11e3-a5e2-0800200c9a66', $constraint);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\UnexpectedValueException
- */
public function testExpectsStringCompatibleType()
{
+ $this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException');
$this->validator->validate(new \stdClass(), new Uuid());
}
diff --git a/src/Symfony/Component/Validator/Tests/ContainerConstraintValidatorFactoryTest.php b/src/Symfony/Component/Validator/Tests/ContainerConstraintValidatorFactoryTest.php
index 5178bc3b30..41b0fa8eaa 100644
--- a/src/Symfony/Component/Validator/Tests/ContainerConstraintValidatorFactoryTest.php
+++ b/src/Symfony/Component/Validator/Tests/ContainerConstraintValidatorFactoryTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\Validator\Tests;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Constraints\Blank as BlankConstraint;
@@ -20,6 +21,8 @@ use Symfony\Component\Validator\ContainerConstraintValidatorFactory;
class ContainerConstraintValidatorFactoryTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testGetInstanceCreatesValidator()
{
$factory = new ContainerConstraintValidatorFactory(new Container());
@@ -45,11 +48,9 @@ class ContainerConstraintValidatorFactoryTest extends TestCase
$this->assertSame($validator, $factory->getInstance(new DummyConstraint()));
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ValidatorException
- */
public function testGetInstanceInvalidValidatorClass()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ValidatorException');
$constraint = $this->getMockBuilder(Constraint::class)->getMock();
$constraint
->expects($this->once())
diff --git a/src/Symfony/Component/Validator/Tests/DependencyInjection/AddConstraintValidatorsPassTest.php b/src/Symfony/Component/Validator/Tests/DependencyInjection/AddConstraintValidatorsPassTest.php
index c3224840bb..48943a3fb2 100644
--- a/src/Symfony/Component/Validator/Tests/DependencyInjection/AddConstraintValidatorsPassTest.php
+++ b/src/Symfony/Component/Validator/Tests/DependencyInjection/AddConstraintValidatorsPassTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\Validator\Tests\DependencyInjection;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
@@ -21,6 +22,8 @@ use Symfony\Component\Validator\DependencyInjection\AddConstraintValidatorsPass;
class AddConstraintValidatorsPassTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testThatConstraintValidatorServicesAreProcessed()
{
$container = new ContainerBuilder();
@@ -43,12 +46,10 @@ 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();
$container->register('validator.validator_factory')
->addArgument([]);
diff --git a/src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php b/src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php
index bb1c2fed0c..e8929d9f81 100644
--- a/src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php
+++ b/src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php
@@ -253,47 +253,37 @@ class ClassMetadataTest extends TestCase
$this->assertInstanceOf('Symfony\Component\Validator\Constraints\GroupSequence', $this->metadata->getGroupSequence());
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\GroupDefinitionException
- */
public function testGroupSequencesFailIfNotContainingDefaultGroup()
{
+ $this->expectException('Symfony\Component\Validator\Exception\GroupDefinitionException');
$this->metadata->setGroupSequence(['Foo', 'Bar']);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\GroupDefinitionException
- */
public function testGroupSequencesFailIfContainingDefault()
{
+ $this->expectException('Symfony\Component\Validator\Exception\GroupDefinitionException');
$this->metadata->setGroupSequence(['Foo', $this->metadata->getDefaultGroup(), Constraint::DEFAULT_GROUP]);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\GroupDefinitionException
- */
public function testGroupSequenceFailsIfGroupSequenceProviderIsSet()
{
+ $this->expectException('Symfony\Component\Validator\Exception\GroupDefinitionException');
$metadata = new ClassMetadata(self::PROVIDERCLASS);
$metadata->setGroupSequenceProvider(true);
$metadata->setGroupSequence(['GroupSequenceProviderEntity', 'Foo']);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\GroupDefinitionException
- */
public function testGroupSequenceProviderFailsIfGroupSequenceIsSet()
{
+ $this->expectException('Symfony\Component\Validator\Exception\GroupDefinitionException');
$metadata = new ClassMetadata(self::PROVIDERCLASS);
$metadata->setGroupSequence(['GroupSequenceProviderEntity', 'Foo']);
$metadata->setGroupSequenceProvider(true);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\GroupDefinitionException
- */
public function testGroupSequenceProviderFailsIfDomainClassIsInvalid()
{
+ $this->expectException('Symfony\Component\Validator\Exception\GroupDefinitionException');
$metadata = new ClassMetadata('stdClass');
$metadata->setGroupSequenceProvider(true);
}
diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Factory/BlackHoleMetadataFactoryTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Factory/BlackHoleMetadataFactoryTest.php
index 880f6b70d1..87913e8e19 100644
--- a/src/Symfony/Component/Validator/Tests/Mapping/Factory/BlackHoleMetadataFactoryTest.php
+++ b/src/Symfony/Component/Validator/Tests/Mapping/Factory/BlackHoleMetadataFactoryTest.php
@@ -12,15 +12,16 @@
namespace Symfony\Component\Validator\Tests\Mapping\Factory;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Validator\Mapping\Factory\BlackHoleMetadataFactory;
class BlackHoleMetadataFactoryTest extends TestCase
{
- /**
- * @expectedException \Symfony\Component\Validator\Exception\LogicException
- */
+ use ForwardCompatTestTrait;
+
public function testGetMetadataForThrowsALogicException()
{
+ $this->expectException('Symfony\Component\Validator\Exception\LogicException');
$metadataFactory = new BlackHoleMetadataFactory();
$metadataFactory->getMetadataFor('foo');
}
diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php
index 9ad85e3f90..a1f66ce4ce 100644
--- a/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php
+++ b/src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\Validator\Tests\Mapping\Factory;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Validator\Constraints\Callback;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory;
@@ -20,6 +21,8 @@ use Symfony\Component\Validator\Tests\Fixtures\ConstraintA;
class LazyLoadingMetadataFactoryTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
const CLASS_NAME = 'Symfony\Component\Validator\Tests\Fixtures\Entity';
const PARENT_CLASS = 'Symfony\Component\Validator\Tests\Fixtures\EntityParent';
const INTERFACE_A_CLASS = 'Symfony\Component\Validator\Tests\Fixtures\EntityInterfaceA';
@@ -149,11 +152,9 @@ class LazyLoadingMetadataFactoryTest extends TestCase
$this->assertEquals($metadata, $factory->getMetadataFor(self::PARENT_CLASS));
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\NoSuchMetadataException
- */
public function testNonClassNameStringValues()
{
+ $this->expectException('Symfony\Component\Validator\Exception\NoSuchMetadataException');
$testedValue = 'error@example.com';
$loader = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock();
$cache = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Cache\CacheInterface')->getMock();
diff --git a/src/Symfony/Component/Validator/Tests/Mapping/GetterMetadataTest.php b/src/Symfony/Component/Validator/Tests/Mapping/GetterMetadataTest.php
index fd62ea80f2..7c78a0bb72 100644
--- a/src/Symfony/Component/Validator/Tests/Mapping/GetterMetadataTest.php
+++ b/src/Symfony/Component/Validator/Tests/Mapping/GetterMetadataTest.php
@@ -64,12 +64,10 @@ class GetterMetadataTest extends TestCase
$this->assertEquals('permissions', $metadata->getPropertyValue($entity));
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ValidatorException
- * @expectedExceptionMessage The hasLastName() method does not exist in class Symfony\Component\Validator\Tests\Fixtures\Entity.
- */
public function testUndefinedMethodNameThrowsException()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ValidatorException');
+ $this->expectExceptionMessage('The hasLastName() method does not exist in class Symfony\Component\Validator\Tests\Fixtures\Entity.');
new GetterMetadata(self::CLASSNAME, 'lastName', 'hasLastName');
}
}
diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Loader/YamlFileLoaderTest.php
index 158bebdbc7..d30a83d8b8 100644
--- a/src/Symfony/Component/Validator/Tests/Mapping/Loader/YamlFileLoaderTest.php
+++ b/src/Symfony/Component/Validator/Tests/Mapping/Loader/YamlFileLoaderTest.php
@@ -43,10 +43,10 @@ class YamlFileLoaderTest extends TestCase
/**
* @dataProvider provideInvalidYamlFiles
- * @expectedException \InvalidArgumentException
*/
public function testInvalidYamlFiles($path)
{
+ $this->expectException('InvalidArgumentException');
$loader = new YamlFileLoader(__DIR__.'/'.$path);
$metadata = new ClassMetadata('Symfony\Component\Validator\Tests\Fixtures\Entity');
diff --git a/src/Symfony/Component/Validator/Tests/Validator/AbstractTest.php b/src/Symfony/Component/Validator/Tests/Validator/AbstractTest.php
index a2525311c5..85b81ebe52 100644
--- a/src/Symfony/Component/Validator/Tests/Validator/AbstractTest.php
+++ b/src/Symfony/Component/Validator/Tests/Validator/AbstractTest.php
@@ -414,11 +414,9 @@ abstract class AbstractTest extends AbstractValidatorTest
$this->assertCount(0, $violations);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
- */
public function testExpectTraversableIfTraversalEnabledOnClass()
{
+ $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
$entity = new Entity();
$this->metadata->addConstraint(new Traverse(true));
@@ -572,11 +570,9 @@ abstract class AbstractTest extends AbstractValidatorTest
$this->assertCount(1, $violations);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\RuntimeException
- */
public function testValidateFailsIfNoConstraintsAndNoObjectOrArray()
{
+ $this->expectException('Symfony\Component\Validator\Exception\RuntimeException');
$this->validate('Foobar');
}
diff --git a/src/Symfony/Component/Validator/Tests/Validator/AbstractValidatorTest.php b/src/Symfony/Component/Validator/Tests/Validator/AbstractValidatorTest.php
index e07a158fa2..9d345b763a 100644
--- a/src/Symfony/Component/Validator/Tests/Validator/AbstractValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Validator/AbstractValidatorTest.php
@@ -502,11 +502,9 @@ abstract class AbstractValidatorTest extends TestCase
$this->assertCount(0, $violations);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\NoSuchMetadataException
- */
public function testFailOnScalarReferences()
{
+ $this->expectException('Symfony\Component\Validator\Exception\NoSuchMetadataException');
$entity = new Entity();
$entity->reference = 'string';
@@ -741,11 +739,9 @@ abstract class AbstractValidatorTest extends TestCase
$this->assertCount(0, $violations);
}
- /**
- * @expectedException \Symfony\Component\Validator\Exception\NoSuchMetadataException
- */
public function testMetadataMustExistIfTraversalIsDisabled()
{
+ $this->expectException('Symfony\Component\Validator\Exception\NoSuchMetadataException');
$entity = new Entity();
$entity->reference = new \ArrayIterator();
diff --git a/src/Symfony/Component/VarExporter/Tests/InstantiatorTest.php b/src/Symfony/Component/VarExporter/Tests/InstantiatorTest.php
index cae10e3b44..3da602383f 100644
--- a/src/Symfony/Component/VarExporter/Tests/InstantiatorTest.php
+++ b/src/Symfony/Component/VarExporter/Tests/InstantiatorTest.php
@@ -16,22 +16,20 @@ use Symfony\Component\VarExporter\Instantiator;
class InstantiatorTest extends TestCase
{
- /**
- * @expectedException \Symfony\Component\VarExporter\Exception\ClassNotFoundException
- * @expectedExceptionMessage Class "SomeNotExistingClass" not found.
- */
public function testNotFoundClass()
{
+ $this->expectException('Symfony\Component\VarExporter\Exception\ClassNotFoundException');
+ $this->expectExceptionMessage('Class "SomeNotExistingClass" not found.');
Instantiator::instantiate('SomeNotExistingClass');
}
/**
* @dataProvider provideFailingInstantiation
- * @expectedException \Symfony\Component\VarExporter\Exception\NotInstantiableTypeException
- * @expectedExceptionMessageRegexp Type ".*" is not instantiable.
*/
public function testFailingInstantiation(string $class)
{
+ $this->expectException('Symfony\Component\VarExporter\Exception\NotInstantiableTypeException');
+ $this->expectExceptionMessageRegExp('/Type ".*" is not instantiable\./');
Instantiator::instantiate($class);
}
diff --git a/src/Symfony/Component/VarExporter/Tests/VarExporterTest.php b/src/Symfony/Component/VarExporter/Tests/VarExporterTest.php
index 78ef7ed80a..d929b6ebdd 100644
--- a/src/Symfony/Component/VarExporter/Tests/VarExporterTest.php
+++ b/src/Symfony/Component/VarExporter/Tests/VarExporterTest.php
@@ -20,12 +20,10 @@ class VarExporterTest extends TestCase
{
use VarDumperTestTrait;
- /**
- * @expectedException \Symfony\Component\VarExporter\Exception\ClassNotFoundException
- * @expectedExceptionMessage Class "SomeNotExistingClass" not found.
- */
public function testPhpIncompleteClassesAreForbidden()
{
+ $this->expectException('Symfony\Component\VarExporter\Exception\ClassNotFoundException');
+ $this->expectExceptionMessage('Class "SomeNotExistingClass" not found.');
$unserializeCallback = ini_set('unserialize_callback_func', 'var_dump');
try {
Registry::unserialize([], ['O:20:"SomeNotExistingClass":0:{}']);
@@ -36,11 +34,11 @@ class VarExporterTest extends TestCase
/**
* @dataProvider provideFailingSerialization
- * @expectedException \Symfony\Component\VarExporter\Exception\NotInstantiableTypeException
- * @expectedExceptionMessageRegexp Type ".*" is not instantiable.
*/
public function testFailingSerialization($value)
{
+ $this->expectException('Symfony\Component\VarExporter\Exception\NotInstantiableTypeException');
+ $this->expectExceptionMessageRegExp('/Type ".*" is not instantiable\./');
$expectedDump = $this->getDump($value);
try {
VarExporter::export($value);
diff --git a/src/Symfony/Component/Workflow/Tests/DefinitionTest.php b/src/Symfony/Component/Workflow/Tests/DefinitionTest.php
index 8bbac4a8c7..42abfed487 100644
--- a/src/Symfony/Component/Workflow/Tests/DefinitionTest.php
+++ b/src/Symfony/Component/Workflow/Tests/DefinitionTest.php
@@ -3,11 +3,14 @@
namespace Symfony\Component\Workflow\Tests;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Workflow\Definition;
use Symfony\Component\Workflow\Transition;
class DefinitionTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testAddPlaces()
{
$places = range('a', 'e');
@@ -34,12 +37,10 @@ class DefinitionTest extends TestCase
$this->assertEquals(['a', 'e'], $definition->getInitialPlaces());
}
- /**
- * @expectedException \Symfony\Component\Workflow\Exception\LogicException
- * @expectedExceptionMessage Place "d" cannot be the initial place as it does not exist.
- */
public function testSetInitialPlaceAndPlaceIsNotDefined()
{
+ $this->expectException('Symfony\Component\Workflow\Exception\LogicException');
+ $this->expectExceptionMessage('Place "d" cannot be the initial place as it does not exist.');
$definition = new Definition([], [], 'd');
}
@@ -54,23 +55,19 @@ class DefinitionTest extends TestCase
$this->assertSame($transition, $definition->getTransitions()[0]);
}
- /**
- * @expectedException \Symfony\Component\Workflow\Exception\LogicException
- * @expectedExceptionMessage Place "c" referenced in transition "name" does not exist.
- */
public function testAddTransitionAndFromPlaceIsNotDefined()
{
+ $this->expectException('Symfony\Component\Workflow\Exception\LogicException');
+ $this->expectExceptionMessage('Place "c" referenced in transition "name" does not exist.');
$places = range('a', 'b');
new Definition($places, [new Transition('name', 'c', $places[1])]);
}
- /**
- * @expectedException \Symfony\Component\Workflow\Exception\LogicException
- * @expectedExceptionMessage Place "c" referenced in transition "name" does not exist.
- */
public function testAddTransitionAndToPlaceIsNotDefined()
{
+ $this->expectException('Symfony\Component\Workflow\Exception\LogicException');
+ $this->expectExceptionMessage('Place "c" referenced in transition "name" does not exist.');
$places = range('a', 'b');
new Definition($places, [new Transition('name', $places[0], 'c')]);
diff --git a/src/Symfony/Component/Workflow/Tests/Metadata/InMemoryMetadataStoreTest.php b/src/Symfony/Component/Workflow/Tests/Metadata/InMemoryMetadataStoreTest.php
index 16d2d6f20c..5e5c8fec6f 100644
--- a/src/Symfony/Component/Workflow/Tests/Metadata/InMemoryMetadataStoreTest.php
+++ b/src/Symfony/Component/Workflow/Tests/Metadata/InMemoryMetadataStoreTest.php
@@ -75,12 +75,10 @@ class InMemoryMetadataStoreTest extends TestCase
$this->assertNull($this->store->getMetadata('description', new Transition('transition_2', [], [])));
}
- /**
- * @expectedException \Symfony\Component\Workflow\Exception\InvalidArgumentException
- * @expectedExceptionMessage Could not find a MetadataBag for the subject of type "boolean".
- */
public function testGetMetadataWithUnknownType()
{
+ $this->expectException('Symfony\Component\Workflow\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Could not find a MetadataBag for the subject of type "boolean".');
$this->store->getMetadata('title', true);
}
}
diff --git a/src/Symfony/Component/Workflow/Tests/RegistryTest.php b/src/Symfony/Component/Workflow/Tests/RegistryTest.php
index 9c5d98d0c3..a04db9af82 100644
--- a/src/Symfony/Component/Workflow/Tests/RegistryTest.php
+++ b/src/Symfony/Component/Workflow/Tests/RegistryTest.php
@@ -46,23 +46,19 @@ class RegistryTest extends TestCase
$this->assertSame('workflow2', $workflow->getName());
}
- /**
- * @expectedException \Symfony\Component\Workflow\Exception\InvalidArgumentException
- * @expectedExceptionMessage At least two workflows match this subject. Set a different name on each and use the second (name) argument of this method.
- */
public function testGetWithMultipleMatch()
{
+ $this->expectException('Symfony\Component\Workflow\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('At least two workflows match this subject. Set a different name on each and use the second (name) argument of this method.');
$w1 = $this->registry->get(new Subject2());
$this->assertInstanceOf(Workflow::class, $w1);
$this->assertSame('workflow1', $w1->getName());
}
- /**
- * @expectedException \Symfony\Component\Workflow\Exception\InvalidArgumentException
- * @expectedExceptionMessage Unable to find a workflow for class "stdClass".
- */
public function testGetWithNoMatch()
{
+ $this->expectException('Symfony\Component\Workflow\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Unable to find a workflow for class "stdClass".');
$w1 = $this->registry->get(new \stdClass());
$this->assertInstanceOf(Workflow::class, $w1);
$this->assertSame('workflow1', $w1->getName());
diff --git a/src/Symfony/Component/Workflow/Tests/TransitionTest.php b/src/Symfony/Component/Workflow/Tests/TransitionTest.php
index 14a646d509..2b70ae0758 100644
--- a/src/Symfony/Component/Workflow/Tests/TransitionTest.php
+++ b/src/Symfony/Component/Workflow/Tests/TransitionTest.php
@@ -3,10 +3,13 @@
namespace Symfony\Component\Workflow\Tests;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Workflow\Transition;
class TransitionTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testConstructor()
{
$transition = new Transition('name', 'a', 'b');
diff --git a/src/Symfony/Component/Workflow/Tests/Validator/StateMachineValidatorTest.php b/src/Symfony/Component/Workflow/Tests/Validator/StateMachineValidatorTest.php
index 35da1f2ec8..3469e91fdf 100644
--- a/src/Symfony/Component/Workflow/Tests/Validator/StateMachineValidatorTest.php
+++ b/src/Symfony/Component/Workflow/Tests/Validator/StateMachineValidatorTest.php
@@ -3,18 +3,19 @@
namespace Symfony\Component\Workflow\Tests\Validator;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Workflow\Definition;
use Symfony\Component\Workflow\Transition;
use Symfony\Component\Workflow\Validator\StateMachineValidator;
class StateMachineValidatorTest extends TestCase
{
- /**
- * @expectedException \Symfony\Component\Workflow\Exception\InvalidDefinitionException
- * @expectedExceptionMessage A transition from a place/state must have an unique name.
- */
+ use ForwardCompatTestTrait;
+
public function testWithMultipleTransitionWithSameNameShareInput()
{
+ $this->expectException('Symfony\Component\Workflow\Exception\InvalidDefinitionException');
+ $this->expectExceptionMessage('A transition from a place/state must have an unique name.');
$places = ['a', 'b', 'c'];
$transitions[] = new Transition('t1', 'a', 'b');
$transitions[] = new Transition('t1', 'a', 'c');
@@ -35,12 +36,10 @@ class StateMachineValidatorTest extends TestCase
// +----+ +----+
}
- /**
- * @expectedException \Symfony\Component\Workflow\Exception\InvalidDefinitionException
- * @expectedExceptionMessage A transition in StateMachine can only have one output.
- */
public function testWithMultipleTos()
{
+ $this->expectException('Symfony\Component\Workflow\Exception\InvalidDefinitionException');
+ $this->expectExceptionMessage('A transition in StateMachine can only have one output.');
$places = ['a', 'b', 'c'];
$transitions[] = new Transition('t1', 'a', ['b', 'c']);
$definition = new Definition($places, $transitions);
@@ -60,12 +59,10 @@ class StateMachineValidatorTest extends TestCase
// +----+
}
- /**
- * @expectedException \Symfony\Component\Workflow\Exception\InvalidDefinitionException
- * @expectedExceptionMessage A transition in StateMachine can only have one input.
- */
public function testWithMultipleFroms()
{
+ $this->expectException('Symfony\Component\Workflow\Exception\InvalidDefinitionException');
+ $this->expectExceptionMessage('A transition in StateMachine can only have one input.');
$places = ['a', 'b', 'c'];
$transitions[] = new Transition('t1', ['a', 'b'], 'c');
$definition = new Definition($places, $transitions);
@@ -110,12 +107,10 @@ class StateMachineValidatorTest extends TestCase
// +----+ +----+
}
- /**
- * @expectedException \Symfony\Component\Workflow\Exception\InvalidDefinitionException
- * @expectedExceptionMessage The state machine "foo" can not store many places. But the definition has 2 initial places. Only one is supported.
- */
public function testWithTooManyInitialPlaces()
{
+ $this->expectException('Symfony\Component\Workflow\Exception\InvalidDefinitionException');
+ $this->expectExceptionMessage('The state machine "foo" can not store many places. But the definition has 2 initial places. Only one is supported.');
$places = range('a', 'c');
$transitions = [];
$definition = new Definition($places, $transitions, ['a', 'b']);
diff --git a/src/Symfony/Component/Workflow/Tests/Validator/WorkflowValidatorTest.php b/src/Symfony/Component/Workflow/Tests/Validator/WorkflowValidatorTest.php
index 2877947a91..487768193b 100644
--- a/src/Symfony/Component/Workflow/Tests/Validator/WorkflowValidatorTest.php
+++ b/src/Symfony/Component/Workflow/Tests/Validator/WorkflowValidatorTest.php
@@ -3,6 +3,7 @@
namespace Symfony\Component\Workflow\Tests\Validator;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Workflow\Definition;
use Symfony\Component\Workflow\Tests\WorkflowBuilderTrait;
use Symfony\Component\Workflow\Transition;
@@ -10,14 +11,13 @@ use Symfony\Component\Workflow\Validator\WorkflowValidator;
class WorkflowValidatorTest extends TestCase
{
+ use ForwardCompatTestTrait;
use WorkflowBuilderTrait;
- /**
- * @expectedException \Symfony\Component\Workflow\Exception\InvalidDefinitionException
- * @expectedExceptionMessage All transitions for a place must have an unique name. Multiple transitions named "t1" where found for place "a" in workflow "foo".
- */
public function testWorkflowWithInvalidNames()
{
+ $this->expectException('Symfony\Component\Workflow\Exception\InvalidDefinitionException');
+ $this->expectExceptionMessage('All transitions for a place must have an unique name. Multiple transitions named "t1" where found for place "a" in workflow "foo".');
$places = range('a', 'c');
$transitions = [];
diff --git a/src/Symfony/Component/Workflow/Tests/WorkflowTest.php b/src/Symfony/Component/Workflow/Tests/WorkflowTest.php
index 9a8f97d94a..07e17f5781 100644
--- a/src/Symfony/Component/Workflow/Tests/WorkflowTest.php
+++ b/src/Symfony/Component/Workflow/Tests/WorkflowTest.php
@@ -3,6 +3,7 @@
namespace Symfony\Component\Workflow\Tests;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\Workflow\Definition;
use Symfony\Component\Workflow\Event\Event;
@@ -18,38 +19,33 @@ use Symfony\Component\Workflow\Workflow;
class WorkflowTest extends TestCase
{
+ use ForwardCompatTestTrait;
use WorkflowBuilderTrait;
- /**
- * @expectedException \Symfony\Component\Workflow\Exception\LogicException
- * @expectedExceptionMessage The value returned by the MarkingStore is not an instance of "Symfony\Component\Workflow\Marking" for workflow "unnamed".
- */
public function testGetMarkingWithInvalidStoreReturn()
{
+ $this->expectException('Symfony\Component\Workflow\Exception\LogicException');
+ $this->expectExceptionMessage('The value returned by the MarkingStore is not an instance of "Symfony\Component\Workflow\Marking" for workflow "unnamed".');
$subject = new Subject();
$workflow = new Workflow(new Definition([], []), $this->getMockBuilder(MarkingStoreInterface::class)->getMock());
$workflow->getMarking($subject);
}
- /**
- * @expectedException \Symfony\Component\Workflow\Exception\LogicException
- * @expectedExceptionMessage The Marking is empty and there is no initial place for workflow "unnamed".
- */
public function testGetMarkingWithEmptyDefinition()
{
+ $this->expectException('Symfony\Component\Workflow\Exception\LogicException');
+ $this->expectExceptionMessage('The Marking is empty and there is no initial place for workflow "unnamed".');
$subject = new Subject();
$workflow = new Workflow(new Definition([], []), new MethodMarkingStore());
$workflow->getMarking($subject);
}
- /**
- * @expectedException \Symfony\Component\Workflow\Exception\LogicException
- * @expectedExceptionMessage Place "nope" is not valid for workflow "unnamed".
- */
public function testGetMarkingWithImpossiblePlace()
{
+ $this->expectException('Symfony\Component\Workflow\Exception\LogicException');
+ $this->expectExceptionMessage('Place "nope" is not valid for workflow "unnamed".');
$subject = new Subject();
$subject->setMarking(['nope' => 1]);
$workflow = new Workflow(new Definition([], []), new MethodMarkingStore());
@@ -173,12 +169,10 @@ class WorkflowTest extends TestCase
$this->assertTrue($workflow->can($subject, 'to_a'));
}
- /**
- * @expectedException \Symfony\Component\Workflow\Exception\UndefinedTransitionException
- * @expectedExceptionMessage Transition "404 Not Found" is not defined for workflow "unnamed".
- */
public function testBuildTransitionBlockerListReturnsUndefinedTransition()
{
+ $this->expectException('Symfony\Component\Workflow\Exception\UndefinedTransitionException');
+ $this->expectExceptionMessage('Transition "404 Not Found" is not defined for workflow "unnamed".');
$definition = $this->createSimpleWorkflowDefinition();
$subject = new Subject();
$workflow = new Workflow($definition, new MethodMarkingStore());
@@ -255,12 +249,10 @@ class WorkflowTest extends TestCase
$this->assertSame('e8b5bbb9-5913-4b98-bfa6-65dbd228a82a', $blockers[3]->getCode());
}
- /**
- * @expectedException \Symfony\Component\Workflow\Exception\UndefinedTransitionException
- * @expectedExceptionMessage Transition "404 Not Found" is not defined for workflow "unnamed".
- */
public function testApplyWithNotExisingTransition()
{
+ $this->expectException('Symfony\Component\Workflow\Exception\UndefinedTransitionException');
+ $this->expectExceptionMessage('Transition "404 Not Found" is not defined for workflow "unnamed".');
$definition = $this->createComplexWorkflowDefinition();
$subject = new Subject();
$workflow = new Workflow($definition, new MethodMarkingStore());
diff --git a/src/Symfony/Component/Yaml/Tests/Command/LintCommandTest.php b/src/Symfony/Component/Yaml/Tests/Command/LintCommandTest.php
index 2087fb8946..0e0ff7e94d 100644
--- a/src/Symfony/Component/Yaml/Tests/Command/LintCommandTest.php
+++ b/src/Symfony/Component/Yaml/Tests/Command/LintCommandTest.php
@@ -93,11 +93,9 @@ YAML;
$this->assertSame(1, $ret, 'lint:yaml exits with code 1 in case of error');
}
- /**
- * @expectedException \RuntimeException
- */
public function testLintFileNotReadable()
{
+ $this->expectException('RuntimeException');
$tester = $this->createCommandTester();
$filename = $this->createFile('');
unlink($filename);
diff --git a/src/Symfony/Component/Yaml/Tests/DumperTest.php b/src/Symfony/Component/Yaml/Tests/DumperTest.php
index 24d956b09b..c761c68dc7 100644
--- a/src/Symfony/Component/Yaml/Tests/DumperTest.php
+++ b/src/Symfony/Component/Yaml/Tests/DumperTest.php
@@ -195,11 +195,9 @@ EOF;
$this->assertEquals('{ foo: null, bar: 1 }', $dump, '->dump() does not dump objects when disabled');
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\DumpException
- */
public function testObjectSupportDisabledWithExceptions()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\DumpException');
$this->dumper->dump(['foo' => new A(), 'bar' => 1], 0, 0, Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE);
}
@@ -496,21 +494,17 @@ YAML;
$this->assertSame("- \"a\\r\\nb\\nc\"\n", $this->dumper->dump(["a\r\nb\nc"], 2, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK));
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage The indentation must be greater than zero
- */
public function testZeroIndentationThrowsException()
{
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('The indentation must be greater than zero');
new Dumper(0);
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage The indentation must be greater than zero
- */
public function testNegativeIndentationThrowsException()
{
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('The indentation must be greater than zero');
new Dumper(-4);
}
}
diff --git a/src/Symfony/Component/Yaml/Tests/InlineTest.php b/src/Symfony/Component/Yaml/Tests/InlineTest.php
index 5a6cfda851..2dcf9ddbab 100644
--- a/src/Symfony/Component/Yaml/Tests/InlineTest.php
+++ b/src/Symfony/Component/Yaml/Tests/InlineTest.php
@@ -66,21 +66,17 @@ class InlineTest extends TestCase
];
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- * @expectedExceptionMessage The constant "WRONG_CONSTANT" is not defined
- */
public function testParsePhpConstantThrowsExceptionWhenUndefined()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
+ $this->expectExceptionMessage('The constant "WRONG_CONSTANT" is not defined');
Inline::parse('!php/const WRONG_CONSTANT', Yaml::PARSE_CONSTANT);
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- * @expectedExceptionMessageRegExp #The string "!php/const PHP_INT_MAX" could not be parsed as a constant.*#
- */
public function testParsePhpConstantThrowsExceptionOnInvalidType()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
+ $this->expectExceptionMessageRegExp('#The string "!php/const PHP_INT_MAX" could not be parsed as a constant.*#');
Inline::parse('!php/const PHP_INT_MAX', Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE);
}
@@ -121,72 +117,56 @@ class InlineTest extends TestCase
$this->assertSame($value, Inline::parse(Inline::dump($value)));
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- * @expectedExceptionMessage Found unknown escape character "\V".
- */
public function testParseScalarWithNonEscapedBlackslashShouldThrowException()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
+ $this->expectExceptionMessage('Found unknown escape character "\V".');
Inline::parse('"Foo\Var"');
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- */
public function testParseScalarWithNonEscapedBlackslashAtTheEndShouldThrowException()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
Inline::parse('"Foo\\"');
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- */
public function testParseScalarWithIncorrectlyQuotedStringShouldThrowException()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
$value = "'don't do somthin' like that'";
Inline::parse($value);
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- */
public function testParseScalarWithIncorrectlyDoubleQuotedStringShouldThrowException()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
$value = '"don"t do somthin" like that"';
Inline::parse($value);
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- */
public function testParseInvalidMappingKeyShouldThrowException()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
$value = '{ "foo " bar": "bar" }';
Inline::parse($value);
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- * @expectedExceptionMessage Colons must be followed by a space or an indication character (i.e. " ", ",", "[", "]", "{", "}")
- */
public function testParseMappingKeyWithColonNotFollowedBySpace()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
+ $this->expectExceptionMessage('Colons must be followed by a space or an indication character (i.e. " ", ",", "[", "]", "{", "}")');
Inline::parse('{foo:""}');
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- */
public function testParseInvalidMappingShouldThrowException()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
Inline::parse('[foo] bar');
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- */
public function testParseInvalidSequenceShouldThrowException()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
Inline::parse('{ foo: bar } bar');
}
@@ -230,21 +210,17 @@ class InlineTest extends TestCase
$this->assertSame([$foo], Inline::parse('[*foo]', 0, ['foo' => $foo]));
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- * @expectedExceptionMessage A reference must contain at least one character at line 1.
- */
public function testParseUnquotedAsterisk()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
+ $this->expectExceptionMessage('A reference must contain at least one character at line 1.');
Inline::parse('{ foo: * }');
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- * @expectedExceptionMessage A reference must contain at least one character at line 1.
- */
public function testParseUnquotedAsteriskFollowedByAComment()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
+ $this->expectExceptionMessage('A reference must contain at least one character at line 1.');
Inline::parse('{ foo: * #foo }');
}
@@ -615,10 +591,10 @@ class InlineTest extends TestCase
/**
* @dataProvider getInvalidBinaryData
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
*/
public function testParseInvalidBinaryData($data, $expectedMessage)
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
$this->expectExceptionMessageRegExp($expectedMessage);
Inline::parse($data);
@@ -634,12 +610,10 @@ class InlineTest extends TestCase
];
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- * @expectedExceptionMessage Malformed inline YAML string: {this, is not, supported} at line 1.
- */
public function testNotSupportedMissingValue()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
+ $this->expectExceptionMessage('Malformed inline YAML string: {this, is not, supported} at line 1.');
Inline::parse('{this, is not, supported}');
}
@@ -653,12 +627,10 @@ class InlineTest extends TestCase
$this->assertEquals($longStringWithQuotes, $arrayFromYaml['longStringWithQuotes']);
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- * @expectedExceptionMessage Missing mapping key
- */
public function testMappingKeysCannotBeOmitted()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
+ $this->expectExceptionMessage('Missing mapping key');
Inline::parse('{: foo}');
}
@@ -684,13 +656,13 @@ class InlineTest extends TestCase
}
/**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- * @expectedExceptionMessage Implicit casting of incompatible mapping keys to strings is not supported. Quote your evaluable mapping keys instead
*
* @dataProvider getNotPhpCompatibleMappingKeyData
*/
public function testImplicitStringCastingOfMappingKeysIsDeprecated($yaml, $expected)
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
+ $this->expectExceptionMessage('Implicit casting of incompatible mapping keys to strings is not supported. Quote your evaluable mapping keys instead');
$this->assertSame($expected, Inline::parse($yaml));
}
@@ -740,12 +712,10 @@ class InlineTest extends TestCase
$this->assertSame('', $value['foo']->getValue());
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- * @expectedExceptionMessage Unexpected end of line, expected one of ",}" at line 1 (near "{abc: 'def'").
- */
public function testUnfinishedInlineMap()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
+ $this->expectExceptionMessage('Unexpected end of line, expected one of ",}" at line 1 (near "{abc: \'def\'").');
Inline::parse("{abc: 'def'");
}
}
diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php
index b1db699759..5565af126d 100644
--- a/src/Symfony/Component/Yaml/Tests/ParserTest.php
+++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php
@@ -515,11 +515,9 @@ YAML;
return $tests;
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- */
public function testObjectsSupportDisabledWithExceptions()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
$yaml = <<<'EOF'
foo: !php/object:O:30:"Symfony\Tests\Component\Yaml\B":1:{s:1:"b";s:3:"foo";}
bar: 1
@@ -528,12 +526,11 @@ EOF;
$this->parser->parse($yaml, Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE);
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- * @expectedExceptionMessage Mapping values are not allowed in multi-line blocks at line 2 (near "dbal:wrong").
- */
public function testMappingKeyInMultiLineStringTriggersDeprecationNotice()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
+ $this->expectExceptionMessage('Mapping values are not allowed in multi-line blocks at line 2 (near "dbal:wrong").');
+
$yaml = <<<'EOF'
data:
dbal:wrong
@@ -575,11 +572,9 @@ EOF;
}
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- */
public function testUnindentedCollectionException()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
$yaml = <<<'EOF'
collection:
@@ -592,11 +587,9 @@ EOF;
$this->parser->parse($yaml);
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- */
public function testShortcutKeyUnindentedCollectionException()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
$yaml = <<<'EOF'
collection:
@@ -608,12 +601,10 @@ EOF;
$this->parser->parse($yaml);
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- * @expectedExceptionMessageRegExp /^Multiple documents are not supported.+/
- */
public function testMultipleDocumentsNotSupportedException()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
+ $this->expectExceptionMessageRegExp('/^Multiple documents are not supported.+/');
Yaml::parse(<<<'EOL'
# Ranking of 1998 home runs
---
@@ -629,11 +620,9 @@ EOL
);
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- */
public function testSequenceInAMapping()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
Yaml::parse(<<<'EOF'
yaml:
hash: me
@@ -738,10 +727,10 @@ EOT;
/**
* @dataProvider getParseExceptionNotAffectedMultiLineStringLastResortParsing
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
*/
public function testParseExceptionNotAffectedByMultiLineStringLastResortParsing($yaml)
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
$this->parser->parse($yaml);
}
@@ -771,11 +760,9 @@ EOT;
$this->assertSame($expected, $this->parser->parse($yaml));
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- */
public function testMappingInASequence()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
Yaml::parse(<<<'EOF'
yaml:
- array stuff
@@ -784,12 +771,10 @@ EOF
);
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- * @expectedExceptionMessage missing colon
- */
public function testScalarInSequence()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
+ $this->expectExceptionMessage('missing colon');
Yaml::parse(<<<'EOF'
foo:
- bar
@@ -800,8 +785,6 @@ EOF
}
/**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- * @expectedExceptionMessage Duplicate key "child" detected
*
* > It is an error for two equal keys to appear in the same mapping node.
* > In such a case the YAML processor may continue, ignoring the second
@@ -814,6 +797,8 @@ EOF
*/
public function testMappingDuplicateKeyBlock()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
+ $this->expectExceptionMessage('Duplicate key "child" detected');
$input = <<<'EOD'
parent:
child: first
@@ -830,12 +815,10 @@ EOD;
$this->assertSame($expected, Yaml::parse($input));
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- * @expectedExceptionMessage Duplicate key "child" detected
- */
public function testMappingDuplicateKeyFlow()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
+ $this->expectExceptionMessage('Duplicate key "child" detected');
$input = <<<'EOD'
parent: { child: first, child: duplicate }
parent: { child: duplicate, child: duplicate }
@@ -849,11 +832,11 @@ EOD;
}
/**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
* @dataProvider getParseExceptionOnDuplicateData
*/
public function testParseExceptionOnDuplicate($input, $duplicateKey, $lineNumber)
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
$this->expectExceptionMessage(sprintf('Duplicate key "%s" detected at line %d', $duplicateKey, $lineNumber));
Yaml::parse($input);
@@ -1077,12 +1060,10 @@ EOF;
$this->assertEquals(['foo' => 1, 'bar' => 2], $this->parser->parse($yaml));
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- * @expectedExceptionMessage Numeric keys are not supported. Quote your evaluable mapping keys instead
- */
public function testFloatKeys()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
+ $this->expectExceptionMessage('Numeric keys are not supported. Quote your evaluable mapping keys instead');
$yaml = <<<'EOF'
foo:
1.2: "bar"
@@ -1092,12 +1073,10 @@ EOF;
$this->parser->parse($yaml);
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- * @expectedExceptionMessage Non-string keys are not supported. Quote your evaluable mapping keys instead
- */
public function testBooleanKeys()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
+ $this->expectExceptionMessage('Non-string keys are not supported. Quote your evaluable mapping keys instead');
$yaml = <<<'EOF'
true: foo
false: bar
@@ -1131,12 +1110,10 @@ EOF;
$this->assertEquals($expected, $this->parser->parse($yaml));
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- * @expectedExceptionMessage A colon cannot be used in an unquoted mapping value
- */
public function testColonInMappingValueException()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
+ $this->expectExceptionMessage('A colon cannot be used in an unquoted mapping value');
$yaml = <<<'EOF'
foo: bar: baz
EOF;
@@ -1370,10 +1347,10 @@ EOT
/**
* @dataProvider getInvalidBinaryData
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
*/
public function testParseInvalidBinaryData($data, $expectedMessage)
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
$this->expectExceptionMessageRegExp($expectedMessage);
$this->parser->parse($data);
@@ -1705,48 +1682,38 @@ YAML
$this->assertSame('12', $this->parser->parse('! 12'));
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- * @expectedExceptionMessage Tags support is not enabled. Enable the "Yaml::PARSE_CUSTOM_TAGS" flag to use "!iterator" at line 1 (near "!iterator [foo]").
- */
public function testCustomTagsDisabled()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
+ $this->expectExceptionMessage('Tags support is not enabled. Enable the "Yaml::PARSE_CUSTOM_TAGS" flag to use "!iterator" at line 1 (near "!iterator [foo]").');
$this->parser->parse('!iterator [foo]');
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- * @expectedExceptionMessage Tags support is not enabled. Enable the "Yaml::PARSE_CUSTOM_TAGS" flag to use "!iterator" at line 1 (near "!iterator foo").
- */
public function testUnsupportedTagWithScalar()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
+ $this->expectExceptionMessage('Tags support is not enabled. Enable the "Yaml::PARSE_CUSTOM_TAGS" flag to use "!iterator" at line 1 (near "!iterator foo").');
$this->parser->parse('!iterator foo');
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- * @expectedExceptionMessage The string "!!iterator foo" could not be parsed as it uses an unsupported built-in tag at line 1 (near "!!iterator foo").
- */
public function testUnsupportedBuiltInTagWithScalar()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
+ $this->expectExceptionMessage('The string "!!iterator foo" could not be parsed as it uses an unsupported built-in tag at line 1 (near "!!iterator foo").');
$this->parser->parse('!!iterator foo');
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- * @expectedExceptionMessage The built-in tag "!!foo" is not implemented at line 1 (near "!!foo").
- */
public function testExceptionWhenUsingUnsuportedBuiltInTags()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
+ $this->expectExceptionMessage('The built-in tag "!!foo" is not implemented at line 1 (near "!!foo").');
$this->parser->parse('!!foo');
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- * @expectedExceptionMessage Complex mappings are not supported at line 1 (near "? "1"").
- */
public function testComplexMappingThrowsParseException()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
+ $this->expectExceptionMessage('Complex mappings are not supported at line 1 (near "? "1"").');
$yaml = <<parser->parse($yaml);
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- * @expectedExceptionMessage Complex mappings are not supported at line 2 (near "? "1"").
- */
public function testComplexMappingNestedInMappingThrowsParseException()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
+ $this->expectExceptionMessage('Complex mappings are not supported at line 2 (near "? "1"").');
$yaml = <<parser->parse($yaml);
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- * @expectedExceptionMessage Complex mappings are not supported at line 1 (near "- ? "1"").
- */
public function testComplexMappingNestedInSequenceThrowsParseException()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
+ $this->expectExceptionMessage('Complex mappings are not supported at line 1 (near "- ? "1"").');
$yaml = <<parser->parse($yaml);
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- * @expectedExceptionMessage Unable to parse at line 1 (near "[parameters]").
- */
public function testParsingIniThrowsException()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
+ $this->expectExceptionMessage('Unable to parse at line 1 (near "[parameters]").');
$ini = <<assertEquals($trickyVal, $arrayFromYaml);
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- * @expectedExceptionMessage Reference "foo" does not exist at line 2
- */
public function testParserCleansUpReferencesBetweenRuns()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
+ $this->expectExceptionMessage('Reference "foo" does not exist at line 2');
$yaml = <<assertIsArray($this->parser->parseFile(__DIR__.'/Fixtures/index.yml'));
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- * @expectedExceptionMessageRegExp #^File ".+/Fixtures/nonexistent.yml" does not exist\.$#
- */
public function testParsingNonExistentFilesThrowsException()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
+ $this->expectExceptionMessageRegExp('#^File ".+/Fixtures/nonexistent.yml" does not exist\.$#');
$this->parser->parseFile(__DIR__.'/Fixtures/nonexistent.yml');
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- * @expectedExceptionMessageRegExp #^File ".+/Fixtures/not_readable.yml" cannot be read\.$#
- */
public function testParsingNotReadableFilesThrowsException()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
+ $this->expectExceptionMessageRegExp('#^File ".+/Fixtures/not_readable.yml" cannot be read\.$#');
if ('\\' === \DIRECTORY_SEPARATOR) {
$this->markTestSkipped('chmod is not supported on Windows');
}
@@ -2020,12 +1975,10 @@ YAML;
$this->assertEquals($expected, $this->parser->parse($yaml, Yaml::PARSE_OBJECT_FOR_MAP));
}
- /**
- * @expectedException \Symfony\Component\Yaml\Exception\ParseException
- * @expectedExceptionMessage Reference "foo" does not exist
- */
public function testEvalRefException()
{
+ $this->expectException('Symfony\Component\Yaml\Exception\ParseException');
+ $this->expectExceptionMessage('Reference "foo" does not exist');
$yaml = <<expectException('Symfony\Component\Yaml\Exception\ParseException');
+ $this->expectExceptionMessage('Circular reference [foo, bar, foo] detected');
$this->parser->parse($yaml, Yaml::PARSE_CUSTOM_TAGS);
}
diff --git a/src/Symfony/Component/Yaml/Tests/YamlTest.php b/src/Symfony/Component/Yaml/Tests/YamlTest.php
index 5a792c5116..158d581d66 100644
--- a/src/Symfony/Component/Yaml/Tests/YamlTest.php
+++ b/src/Symfony/Component/Yaml/Tests/YamlTest.php
@@ -12,10 +12,13 @@
namespace Symfony\Component\Yaml\Tests;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Yaml\Yaml;
class YamlTest extends TestCase
{
+ use ForwardCompatTestTrait;
+
public function testParseAndDump()
{
$data = ['lorem' => 'ipsum', 'dolor' => 'sit'];
@@ -24,21 +27,17 @@ class YamlTest extends TestCase
$this->assertEquals($data, $parsed);
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage The indentation must be greater than zero
- */
public function testZeroIndentationThrowsException()
{
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('The indentation must be greater than zero');
Yaml::dump(['lorem' => 'ipsum', 'dolor' => 'sit'], 2, 0);
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage The indentation must be greater than zero
- */
public function testNegativeIndentationThrowsException()
{
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('The indentation must be greater than zero');
Yaml::dump(['lorem' => 'ipsum', 'dolor' => 'sit'], 2, -4);
}
}
diff --git a/src/Symfony/Contracts/Service/Test/ServiceLocatorTest.php b/src/Symfony/Contracts/Service/Test/ServiceLocatorTest.php
index 69594583f5..408c017c3e 100644
--- a/src/Symfony/Contracts/Service/Test/ServiceLocatorTest.php
+++ b/src/Symfony/Contracts/Service/Test/ServiceLocatorTest.php
@@ -64,12 +64,12 @@ class ServiceLocatorTest extends TestCase
$this->assertSame(2, $i);
}
- /**
- * @expectedException \Psr\Container\NotFoundExceptionInterface
- * @expectedExceptionMessage The service "foo" has a dependency on a non-existent service "bar". This locator only knows about the "foo" service.
- */
public function testThrowsOnUndefinedInternalService()
{
+ if (!$this->getExpectedException()) {
+ $this->expectException('Psr\Container\NotFoundExceptionInterface');
+ $this->expectExceptionMessage('The service "foo" has a dependency on a non-existent service "bar". This locator only knows about the "foo" service.');
+ }
$locator = $this->getServiceLocator([
'foo' => function () use (&$locator) { return $locator->get('bar'); },
]);
@@ -77,12 +77,10 @@ class ServiceLocatorTest extends TestCase
$locator->get('foo');
}
- /**
- * @expectedException \Psr\Container\ContainerExceptionInterface
- * @expectedExceptionMessage Circular reference detected for service "bar", path: "bar -> baz -> bar".
- */
public function testThrowsOnCircularReference()
{
+ $this->expectException('Psr\Container\ContainerExceptionInterface');
+ $this->expectExceptionMessage('Circular reference detected for service "bar", path: "bar -> baz -> bar".');
$locator = $this->getServiceLocator([
'foo' => function () use (&$locator) { return $locator->get('bar'); },
'bar' => function () use (&$locator) { return $locator->get('baz'); },
diff --git a/src/Symfony/Contracts/Translation/Test/TranslatorTest.php b/src/Symfony/Contracts/Translation/Test/TranslatorTest.php
index 48466300b5..5bfb0f8df6 100644
--- a/src/Symfony/Contracts/Translation/Test/TranslatorTest.php
+++ b/src/Symfony/Contracts/Translation/Test/TranslatorTest.php
@@ -158,10 +158,10 @@ class TranslatorTest extends TestCase
/**
* @dataProvider getNonMatchingMessages
- * @expectedException \InvalidArgumentException
*/
public function testThrowExceptionIfMatchingMessageCannotBeFound($id, $number)
{
+ $this->expectException('InvalidArgumentException');
$translator = $this->getTranslator();
$translator->trans($id, ['%count%' => $number]);