Merge branch '3.4' into 4.3
* 3.4: cs fix Replace calls to setExpectedException by Pollyfill
This commit is contained in:
commit
e6e68e83cc
@ -16,9 +16,12 @@ use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\Doctrine\Security\User\EntityUserProvider;
|
||||
use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper;
|
||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\User;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
|
||||
class EntityUserProviderTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
public function testRefreshUserGetsUserByPrimaryKey()
|
||||
{
|
||||
$em = DoctrineTestHelper::createTestEntityManager();
|
||||
@ -105,10 +108,8 @@ class EntityUserProviderTest extends TestCase
|
||||
$user1 = new User(null, null, 'user1');
|
||||
$provider = new EntityUserProvider($this->getManager($em), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User', 'name');
|
||||
|
||||
$this->expectException(
|
||||
'InvalidArgumentException',
|
||||
'You cannot refresh a user from the EntityUserProvider that does not contain an identifier. The user object has to be serialized with its own identifier mapped by Doctrine'
|
||||
);
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectExceptionMessage('You cannot refresh a user from the EntityUserProvider that does not contain an identifier. The user object has to be serialized with its own identifier mapped by Doctrine');
|
||||
$provider->refreshUser($user1);
|
||||
}
|
||||
|
||||
@ -125,10 +126,9 @@ class EntityUserProviderTest extends TestCase
|
||||
$provider = new EntityUserProvider($this->getManager($em), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User', 'name');
|
||||
|
||||
$user2 = new User(1, 2, 'user2');
|
||||
$this->expectException(
|
||||
'Symfony\Component\Security\Core\Exception\UsernameNotFoundException',
|
||||
'User with id {"id1":1,"id2":2} not found'
|
||||
);
|
||||
$this->expectException('Symfony\Component\Security\Core\Exception\UsernameNotFoundException');
|
||||
$this->expectExceptionMessage('User with id {"id1":1,"id2":2} not found');
|
||||
|
||||
$provider->refreshUser($user2);
|
||||
}
|
||||
|
||||
|
@ -12,12 +12,16 @@
|
||||
namespace Symfony\Bridge\PhpUnit\Legacy;
|
||||
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
trait ForwardCompatTestTraitForV5
|
||||
{
|
||||
private $forwardCompatExpectedExceptionMessage = '';
|
||||
private $forwardCompatExpectedExceptionCode = null;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
@ -210,4 +214,93 @@ trait ForwardCompatTestTraitForV5
|
||||
{
|
||||
static::assertInternalType('iterable', $actual, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function expectException($exception)
|
||||
{
|
||||
if (method_exists(TestCase::class, 'expectException')) {
|
||||
parent::expectException($exception);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
parent::setExpectedException($exception, $this->forwardCompatExpectedExceptionMessage, $this->forwardCompatExpectedExceptionCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function expectExceptionCode($code)
|
||||
{
|
||||
if (method_exists(TestCase::class, 'expectExceptionCode')) {
|
||||
parent::expectExceptionCode($code);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->forwardCompatExpectedExceptionCode = $code;
|
||||
parent::setExpectedException(parent::getExpectedException(), $this->forwardCompatExpectedExceptionMessage, $this->forwardCompatExpectedExceptionCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function expectExceptionMessage($message)
|
||||
{
|
||||
if (method_exists(TestCase::class, 'expectExceptionMessage')) {
|
||||
parent::expectExceptionMessage($message);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->forwardCompatExpectedExceptionMessage = $message;
|
||||
parent::setExpectedException(parent::getExpectedException(), $this->forwardCompatExpectedExceptionMessage, $this->forwardCompatExpectedExceptionCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $messageRegExp
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function expectExceptionMessageRegExp($messageRegExp)
|
||||
{
|
||||
if (method_exists(TestCase::class, 'expectExceptionMessageRegExp')) {
|
||||
parent::expectExceptionMessageRegExp($messageRegExp);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
parent::setExpectedExceptionRegExp(parent::getExpectedException(), $messageRegExp, $this->forwardCompatExpectedExceptionCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $exceptionMessage
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setExpectedException($exceptionName, $exceptionMessage = '', $exceptionCode = null)
|
||||
{
|
||||
$this->forwardCompatExpectedExceptionMessage = $exceptionMessage;
|
||||
$this->forwardCompatExpectedExceptionCode = $exceptionCode;
|
||||
|
||||
parent::setExpectedException($exceptionName, $exceptionMessage, $exceptionCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $exceptionMessageRegExp
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setExpectedExceptionRegExp($exceptionName, $exceptionMessageRegExp = '', $exceptionCode = null)
|
||||
{
|
||||
$this->forwardCompatExpectedExceptionCode = $exceptionCode;
|
||||
|
||||
parent::setExpectedExceptionRegExp($exceptionName, $exceptionMessageRegExp, $exceptionCode);
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,6 @@ trait ForwardCompatTestTraitForV7
|
||||
->disableOriginalClone()
|
||||
->disableArgumentCloning()
|
||||
->disallowMockingUnknownTypes()
|
||||
->getMock();
|
||||
->getMock();
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace Symfony\Bridge\PhpUnit\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
|
||||
/**
|
||||
* Don't remove this test case, it tests the legacy group.
|
||||
@ -13,6 +14,8 @@ use PHPUnit\Framework\TestCase;
|
||||
*/
|
||||
class ProcessIsolationTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
/**
|
||||
* @expectedDeprecation Test abc
|
||||
*/
|
||||
@ -25,12 +28,8 @@ class ProcessIsolationTest extends TestCase
|
||||
public function testCallingOtherErrorHandler()
|
||||
{
|
||||
$class = class_exists('PHPUnit\Framework\Exception') ? 'PHPUnit\Framework\Exception' : 'PHPUnit_Framework_Exception';
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException($class);
|
||||
$this->expectExceptionMessage('Test that PHPUnit\'s error handler fires.');
|
||||
} else {
|
||||
$this->setExpectedException($class, 'Test that PHPUnit\'s error handler fires.');
|
||||
}
|
||||
$this->expectException($class);
|
||||
$this->expectExceptionMessage('Test that PHPUnit\'s error handler fires.');
|
||||
|
||||
trigger_error('Test that PHPUnit\'s error handler fires.', E_USER_WARNING);
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Bridge\Twig\Tests\Extension;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Bridge\Twig\Extension\HttpKernelExtension;
|
||||
use Symfony\Bridge\Twig\Extension\HttpKernelRuntime;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@ -22,6 +23,8 @@ use Twig\Loader\ArrayLoader;
|
||||
|
||||
class HttpKernelExtensionTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
/**
|
||||
* @expectedException \Twig\Error\RuntimeError
|
||||
*/
|
||||
@ -49,12 +52,8 @@ class HttpKernelExtensionTest extends TestCase
|
||||
;
|
||||
$renderer = new FragmentHandler($context);
|
||||
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectExceptionMessage('The "inline" renderer does not exist.');
|
||||
} else {
|
||||
$this->setExpectedException('InvalidArgumentException', 'The "inline" renderer does not exist.');
|
||||
}
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectExceptionMessage('The "inline" renderer does not exist.');
|
||||
|
||||
$renderer->render('/foo');
|
||||
}
|
||||
|
@ -76,11 +76,7 @@ class CachePoolDeleteCommandTest extends TestCase
|
||||
->with('bar')
|
||||
->willReturn(false);
|
||||
|
||||
if (method_exists($this, 'expectExceptionMessage')) {
|
||||
$this->expectExceptionMessage('Cache item "bar" could not be deleted.');
|
||||
} else {
|
||||
$this->setExpectedException('Exception', 'Cache item "bar" could not be deleted.');
|
||||
}
|
||||
$this->expectExceptionMessage('Cache item "bar" could not be deleted.');
|
||||
|
||||
$tester = $this->getCommandTester($this->getKernel());
|
||||
$tester->execute(['pool' => 'foo', 'key' => 'bar']);
|
||||
|
@ -13,6 +13,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection;
|
||||
|
||||
use Doctrine\DBAL\Connection;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Configuration;
|
||||
use Symfony\Bundle\FullStack;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||
@ -24,6 +25,8 @@ use Symfony\Component\Messenger\MessageBusInterface;
|
||||
|
||||
class ConfigurationTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
public function testDefaultConfig()
|
||||
{
|
||||
$processor = new Processor();
|
||||
@ -140,12 +143,8 @@ class ConfigurationTest extends TestCase
|
||||
*/
|
||||
public function testInvalidAssetsConfiguration(array $assetConfig, $expectedMessage)
|
||||
{
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException(InvalidConfigurationException::class);
|
||||
$this->expectExceptionMessage($expectedMessage);
|
||||
} else {
|
||||
$this->setExpectedException(InvalidConfigurationException::class, $expectedMessage);
|
||||
}
|
||||
$this->expectException(InvalidConfigurationException::class);
|
||||
$this->expectExceptionMessage($expectedMessage);
|
||||
|
||||
$processor = new Processor();
|
||||
$configuration = new Configuration(true);
|
||||
@ -194,12 +193,8 @@ class ConfigurationTest extends TestCase
|
||||
public function testItShowANiceMessageIfTwoMessengerBusesAreConfiguredButNoDefaultBus()
|
||||
{
|
||||
$expectedMessage = 'You must specify the "default_bus" if you define more than one bus.';
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException(InvalidConfigurationException::class);
|
||||
$this->expectExceptionMessage($expectedMessage);
|
||||
} else {
|
||||
$this->setExpectedException(InvalidConfigurationException::class, $expectedMessage);
|
||||
}
|
||||
$this->expectException(InvalidConfigurationException::class);
|
||||
$this->expectExceptionMessage($expectedMessage);
|
||||
$processor = new Processor();
|
||||
$configuration = new Configuration(true);
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Compiler;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Bundle\SecurityBundle\DependencyInjection\Compiler\AddSecurityVotersPass;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
@ -21,6 +22,8 @@ use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
||||
|
||||
class AddSecurityVotersPassTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\DependencyInjection\Exception\LogicException
|
||||
* @expectedExceptionMessage No security voters found. You need to tag at least one with "security.voter".
|
||||
@ -128,12 +131,14 @@ class AddSecurityVotersPassTest extends TestCase
|
||||
$this->assertFalse($container->has('debug.security.voter.voter2'), 'voter2 should not be traced');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\DependencyInjection\Exception\LogicException
|
||||
* @expectedExceptionMessage stdClass must implement the Symfony\Component\Security\Core\Authorization\Voter\VoterInterface when used as a voter.
|
||||
*/
|
||||
public function testVoterMissingInterface()
|
||||
{
|
||||
$exception = LogicException::class;
|
||||
$message = 'stdClass must implement the Symfony\Component\Security\Core\Authorization\Voter\VoterInterface when used as a voter.';
|
||||
|
||||
$this->expectException($exception);
|
||||
$this->expectExceptionMessage($message);
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
$container->setParameter('kernel.debug', false);
|
||||
$container
|
||||
|
@ -235,12 +235,8 @@ class UserPasswordEncoderCommandTest extends AbstractWebTestCase
|
||||
|
||||
public function testEncodePasswordNoConfigForGivenUserClass()
|
||||
{
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException('\RuntimeException');
|
||||
$this->expectExceptionMessage('No encoder has been configured for account "Foo\Bar\User".');
|
||||
} else {
|
||||
$this->setExpectedException('\RuntimeException', 'No encoder has been configured for account "Foo\Bar\User".');
|
||||
}
|
||||
$this->expectException('\RuntimeException');
|
||||
$this->expectExceptionMessage('No encoder has been configured for account "Foo\Bar\User".');
|
||||
|
||||
$this->passwordEncoderCommandTester->execute([
|
||||
'command' => 'security:encode-password',
|
||||
|
@ -12,10 +12,13 @@
|
||||
namespace Symfony\Component\BrowserKit\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\BrowserKit\Cookie;
|
||||
|
||||
class CookieTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
public function testToString()
|
||||
{
|
||||
$cookie = new Cookie('foo', 'bar', strtotime('Fri, 20-May-2011 15:25:52 GMT'), '/', '.myfoodomain.com', true);
|
||||
|
@ -12,12 +12,15 @@
|
||||
namespace Symfony\Component\Config\Tests\Definition;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\Config\Definition\ArrayNode;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||
use Symfony\Component\Config\Definition\ScalarNode;
|
||||
|
||||
class ArrayNodeTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidTypeException
|
||||
*/
|
||||
@ -80,12 +83,8 @@ class ArrayNodeTest extends TestCase
|
||||
public function testIgnoreAndRemoveBehaviors($ignore, $remove, $expected, $message = '')
|
||||
{
|
||||
if ($expected instanceof \Exception) {
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException(\get_class($expected));
|
||||
$this->expectExceptionMessage($expected->getMessage());
|
||||
} else {
|
||||
$this->setExpectedException(\get_class($expected), $expected->getMessage());
|
||||
}
|
||||
$this->expectException(\get_class($expected));
|
||||
$this->expectExceptionMessage($expected->getMessage());
|
||||
}
|
||||
$node = new ArrayNode('root');
|
||||
$node->setIgnoreExtraKeys($ignore, $remove);
|
||||
|
@ -12,11 +12,14 @@
|
||||
namespace Symfony\Component\Config\Tests\Definition;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\Config\Definition\ArrayNode;
|
||||
use Symfony\Component\Config\Definition\ScalarNode;
|
||||
|
||||
class ScalarNodeTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
/**
|
||||
* @dataProvider getValidValues
|
||||
*/
|
||||
@ -95,12 +98,8 @@ class ScalarNodeTest extends TestCase
|
||||
{
|
||||
$node = new ScalarNode('test');
|
||||
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException');
|
||||
$this->expectExceptionMessage('Invalid type for path "test". Expected scalar, but got array.');
|
||||
} else {
|
||||
$this->setExpectedException('Symfony\Component\Config\Definition\Exception\InvalidTypeException', 'Invalid type for path "test". Expected scalar, but got array.');
|
||||
}
|
||||
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException');
|
||||
$this->expectExceptionMessage('Invalid type for path "test". Expected scalar, but got array.');
|
||||
|
||||
$node->normalize([]);
|
||||
}
|
||||
@ -110,12 +109,8 @@ class ScalarNodeTest extends TestCase
|
||||
$node = new ScalarNode('test');
|
||||
$node->setInfo('"the test value"');
|
||||
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException');
|
||||
$this->expectExceptionMessage("Invalid type for path \"test\". Expected scalar, but got array.\nHint: \"the test value\"");
|
||||
} else {
|
||||
$this->setExpectedException('Symfony\Component\Config\Definition\Exception\InvalidTypeException', "Invalid type for path \"test\". Expected scalar, but got array.\nHint: \"the test value\"");
|
||||
}
|
||||
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException');
|
||||
$this->expectExceptionMessage("Invalid type for path \"test\". Expected scalar, but got array.\nHint: \"the test value\"");
|
||||
|
||||
$node->normalize([]);
|
||||
}
|
||||
|
@ -12,10 +12,13 @@
|
||||
namespace Symfony\Component\Config\Tests\Util;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\Config\Util\XmlUtils;
|
||||
|
||||
class XmlUtilsTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
public function testLoadFile()
|
||||
{
|
||||
$fixtures = __DIR__.'/../Fixtures/Util/';
|
||||
@ -166,12 +169,8 @@ class XmlUtilsTest extends TestCase
|
||||
{
|
||||
$file = __DIR__.'/../Fixtures/foo.xml';
|
||||
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectExceptionMessage(sprintf('File %s does not contain valid XML, it is empty.', $file));
|
||||
} else {
|
||||
$this->setExpectedException('InvalidArgumentException', sprintf('File %s does not contain valid XML, it is empty.', $file));
|
||||
}
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectExceptionMessage(sprintf('File %s does not contain valid XML, it is empty.', $file));
|
||||
|
||||
XmlUtils::loadFile($file);
|
||||
}
|
||||
|
@ -316,12 +316,8 @@ class ApplicationTest extends TestCase
|
||||
|
||||
$expectedMsg = "The namespace \"f\" is ambiguous.\nDid you mean one of these?\n foo\n foo1";
|
||||
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException(NamespaceNotFoundException::class);
|
||||
$this->expectExceptionMessage($expectedMsg);
|
||||
} else {
|
||||
$this->setExpectedException(NamespaceNotFoundException::class, $expectedMsg);
|
||||
}
|
||||
$this->expectException(NamespaceNotFoundException::class);
|
||||
$this->expectExceptionMessage($expectedMsg);
|
||||
|
||||
$application->findNamespace('f');
|
||||
}
|
||||
@ -425,12 +421,8 @@ class ApplicationTest extends TestCase
|
||||
public function testFindWithAmbiguousAbbreviations($abbreviation, $expectedExceptionMessage)
|
||||
{
|
||||
putenv('COLUMNS=120');
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException('Symfony\Component\Console\Exception\CommandNotFoundException');
|
||||
$this->expectExceptionMessage($expectedExceptionMessage);
|
||||
} else {
|
||||
$this->setExpectedException('Symfony\Component\Console\Exception\CommandNotFoundException', $expectedExceptionMessage);
|
||||
}
|
||||
$this->expectException('Symfony\Component\Console\Exception\CommandNotFoundException');
|
||||
$this->expectExceptionMessage($expectedExceptionMessage);
|
||||
|
||||
$application = new Application();
|
||||
$application->add(new \FooCommand());
|
||||
|
@ -120,12 +120,8 @@ class CommandTest extends TestCase
|
||||
*/
|
||||
public function testInvalidCommandNames($name)
|
||||
{
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectExceptionMessage(sprintf('Command name "%s" is invalid.', $name));
|
||||
} else {
|
||||
$this->setExpectedException('InvalidArgumentException', sprintf('Command name "%s" is invalid.', $name));
|
||||
}
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectExceptionMessage(sprintf('Command name "%s" is invalid.', $name));
|
||||
|
||||
$command = new \TestCommand();
|
||||
$command->setName($name);
|
||||
|
@ -12,10 +12,13 @@
|
||||
namespace Symfony\Component\Console\Tests\Formatter;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
|
||||
|
||||
class OutputFormatterStyleTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
public function testConstructor()
|
||||
{
|
||||
$style = new OutputFormatterStyle('green', 'black', ['bold', 'underscore']);
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Console\Tests\Input;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\Console\Input\ArgvInput;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputDefinition;
|
||||
@ -19,6 +20,8 @@ use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class ArgvInputTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
public function testConstructor()
|
||||
{
|
||||
$_SERVER['argv'] = ['cli.php', 'foo'];
|
||||
@ -182,12 +185,8 @@ class ArgvInputTest extends TestCase
|
||||
*/
|
||||
public function testInvalidInput($argv, $definition, $expectedExceptionMessage)
|
||||
{
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException('RuntimeException');
|
||||
$this->expectExceptionMessage($expectedExceptionMessage);
|
||||
} else {
|
||||
$this->setExpectedException('RuntimeException', $expectedExceptionMessage);
|
||||
}
|
||||
$this->expectException('RuntimeException');
|
||||
$this->expectExceptionMessage($expectedExceptionMessage);
|
||||
|
||||
$input = new ArgvInput($argv);
|
||||
$input->bind($definition);
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Console\Tests\Input;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputDefinition;
|
||||
@ -19,6 +20,8 @@ use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class ArrayInputTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
public function testGetFirstArgument()
|
||||
{
|
||||
$input = new ArrayInput([]);
|
||||
@ -127,12 +130,8 @@ class ArrayInputTest extends TestCase
|
||||
*/
|
||||
public function testParseInvalidInput($parameters, $definition, $expectedExceptionMessage)
|
||||
{
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectExceptionMessage($expectedExceptionMessage);
|
||||
} else {
|
||||
$this->setExpectedException('InvalidArgumentException', $expectedExceptionMessage);
|
||||
}
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectExceptionMessage($expectedExceptionMessage);
|
||||
|
||||
new ArrayInput($parameters, $definition);
|
||||
}
|
||||
|
@ -12,10 +12,13 @@
|
||||
namespace Symfony\Component\Console\Tests\Input;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
class InputArgumentTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
public function testConstructor()
|
||||
{
|
||||
$argument = new InputArgument('foo');
|
||||
@ -37,12 +40,11 @@ class InputArgumentTest extends TestCase
|
||||
$this->assertTrue($argument->isRequired(), '__construct() can take "InputArgument::REQUIRED" as its mode');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage Argument mode "-1" is not valid.
|
||||
*/
|
||||
public function testInvalidModes()
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectExceptionMessage('Argument mode "-1" is not valid.');
|
||||
|
||||
new InputArgument('foo', '-1');
|
||||
}
|
||||
|
||||
|
@ -12,10 +12,13 @@
|
||||
namespace Symfony\Component\Console\Tests\Input;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class InputOptionTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
public function testConstructor()
|
||||
{
|
||||
$option = new InputOption('foo');
|
||||
@ -73,12 +76,11 @@ class InputOptionTest extends TestCase
|
||||
$this->assertTrue($option->isValueOptional(), '__construct() can take "InputOption::VALUE_OPTIONAL" as its mode');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage Option mode "-1" is not valid.
|
||||
*/
|
||||
public function testInvalidModes()
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectExceptionMessage('Option mode "-1" is not valid.');
|
||||
|
||||
new InputOption('foo', 'f', '-1');
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\CssSelector\Tests\Parser;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\CssSelector\Exception\SyntaxErrorException;
|
||||
use Symfony\Component\CssSelector\Node\FunctionNode;
|
||||
use Symfony\Component\CssSelector\Node\SelectorNode;
|
||||
@ -20,6 +21,8 @@ use Symfony\Component\CssSelector\Parser\Token;
|
||||
|
||||
class ParserTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
/** @dataProvider getParserTestData */
|
||||
public function testParser($source, $representation)
|
||||
{
|
||||
|
@ -12,11 +12,14 @@
|
||||
namespace Symfony\Component\CssSelector\Tests\Parser;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\CssSelector\Parser\Token;
|
||||
use Symfony\Component\CssSelector\Parser\TokenStream;
|
||||
|
||||
class TokenStreamTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
public function testGetNext()
|
||||
{
|
||||
$stream = new TokenStream();
|
||||
|
@ -15,6 +15,7 @@ use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\Warning;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Psr\Log\NullLogger;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\DependencyInjection\Compiler\AutowirePass;
|
||||
use Symfony\Component\DependencyInjection\Compiler\AutowireRequiredMethodsPass;
|
||||
@ -36,6 +37,8 @@ require_once __DIR__.'/../Fixtures/includes/autowiring_classes.php';
|
||||
*/
|
||||
class AutowirePassTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
public function testProcess()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
@ -750,12 +753,8 @@ class AutowirePassTest extends TestCase
|
||||
$foo->addMethodCall($method, []);
|
||||
}
|
||||
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException(RuntimeException::class);
|
||||
$this->expectExceptionMessage($expectedMsg);
|
||||
} else {
|
||||
$this->setExpectedException(RuntimeException::class, $expectedMsg);
|
||||
}
|
||||
$this->expectException(RuntimeException::class);
|
||||
$this->expectExceptionMessage($expectedMsg);
|
||||
|
||||
(new ResolveClassPass())->process($container);
|
||||
(new AutowireRequiredMethodsPass())->process($container);
|
||||
|
@ -12,11 +12,14 @@
|
||||
namespace Symfony\Component\DependencyInjection\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
class DefinitionTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
public function testConstructor()
|
||||
{
|
||||
$def = new Definition('stdClass');
|
||||
@ -73,12 +76,8 @@ class DefinitionTest extends TestCase
|
||||
|
||||
$def = new Definition('stdClass');
|
||||
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectExceptionMessage('The decorated service inner name for "foo" must be different than the service name itself.');
|
||||
} else {
|
||||
$this->setExpectedException('InvalidArgumentException', 'The decorated service inner name for "foo" must be different than the service name itself.');
|
||||
}
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectExceptionMessage('The decorated service inner name for "foo" must be different than the service name itself.');
|
||||
|
||||
$def->setDecoratedService('foo', 'foo');
|
||||
}
|
||||
|
@ -704,12 +704,8 @@ class PhpDumperTest extends TestCase
|
||||
$dumper = new PhpDumper($container);
|
||||
|
||||
$message = 'Circular reference detected for service "foo", path: "foo -> bar -> foo". Try running "composer require symfony/proxy-manager-bridge".';
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException(ServiceCircularReferenceException::class);
|
||||
$this->expectExceptionMessage($message);
|
||||
} else {
|
||||
$this->setExpectedException(ServiceCircularReferenceException::class, $message);
|
||||
}
|
||||
$this->expectException(ServiceCircularReferenceException::class);
|
||||
$this->expectExceptionMessage($message);
|
||||
|
||||
$dumper->dump();
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\DependencyInjection\Tests\ParameterBag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\DependencyInjection\Exception\ParameterCircularReferenceException;
|
||||
use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
|
||||
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
||||
@ -19,6 +20,8 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||
|
||||
class ParameterBagTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
public function testConstructor()
|
||||
{
|
||||
$bag = new ParameterBag($parameters = [
|
||||
@ -78,12 +81,8 @@ class ParameterBagTest extends TestCase
|
||||
'fiz' => ['bar' => ['boo' => 12]],
|
||||
]);
|
||||
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException(ParameterNotFoundException::class);
|
||||
$this->expectExceptionMessage($exceptionMessage);
|
||||
} else {
|
||||
$this->setExpectedException(ParameterNotFoundException::class, $exceptionMessage);
|
||||
}
|
||||
$this->expectException(ParameterNotFoundException::class);
|
||||
$this->expectExceptionMessage($exceptionMessage);
|
||||
|
||||
$bag->get($parameterKey);
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Form\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\Form\ButtonBuilder;
|
||||
use Symfony\Component\Form\Exception\InvalidArgumentException;
|
||||
|
||||
@ -20,6 +21,8 @@ use Symfony\Component\Form\Exception\InvalidArgumentException;
|
||||
*/
|
||||
class ButtonBuilderTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
public function getValidNames()
|
||||
{
|
||||
return [
|
||||
@ -61,12 +64,8 @@ class ButtonBuilderTest extends TestCase
|
||||
*/
|
||||
public function testInvalidNames($name)
|
||||
{
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Buttons cannot have empty names.');
|
||||
} else {
|
||||
$this->setExpectedException(InvalidArgumentException::class, 'Buttons cannot have empty names.');
|
||||
}
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Buttons cannot have empty names.');
|
||||
new ButtonBuilder($name);
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Form\Tests\Command;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
@ -25,6 +26,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class DebugCommandTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
public function testDebugDefaults()
|
||||
{
|
||||
$tester = $this->createCommandTester();
|
||||
@ -104,12 +107,8 @@ Did you mean one of these?
|
||||
Symfony\Component\Form\Tests\Fixtures\Debug\B\AmbiguousType
|
||||
TXT;
|
||||
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage($expectedMessage);
|
||||
} else {
|
||||
$this->setExpectedException(InvalidArgumentException::class, $expectedMessage);
|
||||
}
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage($expectedMessage);
|
||||
|
||||
$tester = $this->createCommandTester([
|
||||
'Symfony\Component\Form\Tests\Fixtures\Debug\A',
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
|
||||
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||
use Symfony\Component\Form\Extension\Core\DataTransformer\DateIntervalToArrayTransformer;
|
||||
@ -20,6 +21,8 @@ use Symfony\Component\Form\Extension\Core\DataTransformer\DateIntervalToArrayTra
|
||||
*/
|
||||
class DateIntervalToArrayTransformerTest extends DateIntervalTestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
public function testTransform()
|
||||
{
|
||||
$transformer = new DateIntervalToArrayTransformer();
|
||||
@ -196,12 +199,8 @@ class DateIntervalToArrayTransformerTest extends DateIntervalTestCase
|
||||
'minutes' => '',
|
||||
'seconds' => '6',
|
||||
];
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException(TransformationFailedException::class);
|
||||
$this->expectExceptionMessage('This amount of "minutes" is invalid');
|
||||
} else {
|
||||
$this->setExpectedException(TransformationFailedException::class, 'This amount of "minutes" is invalid');
|
||||
}
|
||||
$this->expectException(TransformationFailedException::class);
|
||||
$this->expectExceptionMessage('This amount of "minutes" is invalid');
|
||||
$transformer->reverseTransform($input);
|
||||
}
|
||||
|
||||
@ -211,12 +210,8 @@ class DateIntervalToArrayTransformerTest extends DateIntervalTestCase
|
||||
$input = [
|
||||
'invert' => '1',
|
||||
];
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException(TransformationFailedException::class);
|
||||
$this->expectExceptionMessage('The value of "invert" must be boolean');
|
||||
} else {
|
||||
$this->setExpectedException(TransformationFailedException::class, 'The value of "invert" must be boolean');
|
||||
}
|
||||
$this->expectException(TransformationFailedException::class);
|
||||
$this->expectExceptionMessage('The value of "invert" must be boolean');
|
||||
$transformer->reverseTransform($input);
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
|
||||
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||
use Symfony\Component\Form\Extension\Core\DataTransformer\DateIntervalToStringTransformer;
|
||||
@ -20,6 +21,8 @@ use Symfony\Component\Form\Extension\Core\DataTransformer\DateIntervalToStringTr
|
||||
*/
|
||||
class DateIntervalToStringTransformerTest extends DateIntervalTestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
public function dataProviderISO()
|
||||
{
|
||||
$data = [
|
||||
|
@ -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\DateTimeToStringTransformer;
|
||||
|
||||
class DateTimeToStringTransformerTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
public function dataProvider()
|
||||
{
|
||||
$data = [
|
||||
|
@ -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\DateTimeToTimestampTransformer;
|
||||
|
||||
class DateTimeToTimestampTransformerTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
public function testTransform()
|
||||
{
|
||||
$transformer = new DateTimeToTimestampTransformer('UTC', 'UTC');
|
||||
|
@ -11,11 +11,14 @@
|
||||
|
||||
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
|
||||
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\Form\Tests\Fixtures\Author;
|
||||
use Symfony\Component\Form\Tests\Fixtures\AuthorType;
|
||||
|
||||
class CollectionTypeTest extends BaseTypeTest
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\CollectionType';
|
||||
|
||||
public function testContainsNoChildByDefault()
|
||||
|
@ -172,12 +172,8 @@ class FormBuilderTest extends TestCase
|
||||
|
||||
public function testGetUnknown()
|
||||
{
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException('Symfony\Component\Form\Exception\InvalidArgumentException');
|
||||
$this->expectExceptionMessage('The child with the name "foo" does not exist.');
|
||||
} else {
|
||||
$this->setExpectedException('Symfony\Component\Form\Exception\InvalidArgumentException', 'The child with the name "foo" does not exist.');
|
||||
}
|
||||
$this->expectException('Symfony\Component\Form\Exception\InvalidArgumentException');
|
||||
$this->expectExceptionMessage('The child with the name "foo" does not exist.');
|
||||
|
||||
$this->builder->get('foo');
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Form\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\Form\FormConfigBuilder;
|
||||
|
||||
/**
|
||||
@ -19,6 +20,8 @@ use Symfony\Component\Form\FormConfigBuilder;
|
||||
*/
|
||||
class FormConfigTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
public function getHtml4Ids()
|
||||
{
|
||||
return [
|
||||
@ -72,10 +75,8 @@ class FormConfigTest extends TestCase
|
||||
{
|
||||
$dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
|
||||
|
||||
if (null !== $expectedException && method_exists($this, 'expectException')) {
|
||||
if (null !== $expectedException) {
|
||||
$this->expectException($expectedException);
|
||||
} elseif (null !== $expectedException) {
|
||||
$this->setExpectedException($expectedException);
|
||||
}
|
||||
|
||||
$formConfigBuilder = new FormConfigBuilder($name, null, $dispatcher);
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\HttpFoundation\Tests\File;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\HttpFoundation\File\File;
|
||||
|
||||
/**
|
||||
@ -19,6 +20,8 @@ use Symfony\Component\HttpFoundation\File\File;
|
||||
*/
|
||||
class FileTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
protected $file;
|
||||
|
||||
public function testGetMimeTypeUsesMimeTypeGuessers()
|
||||
@ -42,6 +45,7 @@ class FileTest extends TestCase
|
||||
public function testConstructWhenFileNotExists()
|
||||
{
|
||||
$this->expectException('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException');
|
||||
|
||||
new File(__DIR__.'/Fixtures/not_here');
|
||||
}
|
||||
|
||||
|
@ -2053,12 +2053,8 @@ class RequestTest extends TestCase
|
||||
$this->assertSame($expectedPort, $request->getPort());
|
||||
}
|
||||
} else {
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException(SuspiciousOperationException::class);
|
||||
$this->expectExceptionMessage('Invalid Host');
|
||||
} else {
|
||||
$this->setExpectedException(SuspiciousOperationException::class, 'Invalid Host');
|
||||
}
|
||||
$this->expectException(SuspiciousOperationException::class);
|
||||
$this->expectExceptionMessage('Invalid Host');
|
||||
|
||||
$request->getHost();
|
||||
}
|
||||
|
@ -12,10 +12,13 @@
|
||||
namespace Symfony\Component\HttpKernel\Tests\Config;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\HttpKernel\Config\FileLocator;
|
||||
|
||||
class FileLocatorTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
public function testLocate()
|
||||
{
|
||||
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
|
||||
|
@ -13,12 +13,15 @@ namespace Symfony\Component\HttpKernel\Tests\Controller;
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Controller\ContainerControllerResolver;
|
||||
|
||||
class ContainerControllerResolverTest extends ControllerResolverTest
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
public function testGetControllerServiceWithSingleColon()
|
||||
{
|
||||
$service = new ControllerTestService('foo');
|
||||
|
@ -13,11 +13,14 @@ namespace Symfony\Component\HttpKernel\Tests\Controller;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Controller\ControllerResolver;
|
||||
|
||||
class ControllerResolverTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
public function testGetControllerWithoutControllerParameter()
|
||||
{
|
||||
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
|
||||
@ -159,12 +162,8 @@ class ControllerResolverTest extends TestCase
|
||||
public function testGetControllerWithUndefinedController($controller, $exceptionName = null, $exceptionMessage = null)
|
||||
{
|
||||
$resolver = $this->createControllerResolver();
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException($exceptionName);
|
||||
$this->expectExceptionMessage($exceptionMessage);
|
||||
} else {
|
||||
$this->setExpectedException($exceptionName, $exceptionMessage);
|
||||
}
|
||||
$this->expectException($exceptionName);
|
||||
$this->expectExceptionMessage($exceptionMessage);
|
||||
|
||||
$request = Request::create('/');
|
||||
$request->attributes->set('_controller', $controller);
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Intl\Tests\Util;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Symfony\Component\Intl\Exception\RuntimeException;
|
||||
use Symfony\Component\Intl\Util\GitRepository;
|
||||
@ -21,6 +22,8 @@ use Symfony\Component\Intl\Util\GitRepository;
|
||||
*/
|
||||
class GitRepositoryTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
private $targetDir;
|
||||
|
||||
const REPO_URL = 'https://github.com/symfony/intl.git';
|
||||
@ -39,11 +42,7 @@ class GitRepositoryTest extends TestCase
|
||||
|
||||
public function testItThrowsAnExceptionIfInitialisedWithNonGitDirectory()
|
||||
{
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException(RuntimeException::class);
|
||||
} else {
|
||||
$this->setExpectedException(RuntimeException::class);
|
||||
}
|
||||
$this->expectException(RuntimeException::class);
|
||||
|
||||
@mkdir($this->targetDir, 0777, true);
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Ldap\Tests;
|
||||
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\Ldap\Adapter\ExtLdap\Adapter;
|
||||
use Symfony\Component\Ldap\Adapter\ExtLdap\Collection;
|
||||
use Symfony\Component\Ldap\Adapter\ExtLdap\Query;
|
||||
@ -24,6 +25,8 @@ use Symfony\Component\Ldap\LdapInterface;
|
||||
*/
|
||||
class AdapterTest extends LdapTestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
const PAGINATION_REQUIRED_CONFIG = [
|
||||
'options' => [
|
||||
'protocol_version' => 3,
|
||||
|
@ -869,12 +869,8 @@ class OptionsResolverTest extends TestCase
|
||||
$this->resolver->setDefined('option');
|
||||
$this->resolver->setAllowedTypes('option', $allowedType);
|
||||
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
|
||||
$this->expectExceptionMessage($exceptionMessage);
|
||||
} else {
|
||||
$this->setExpectedException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException', $exceptionMessage);
|
||||
}
|
||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
|
||||
$this->expectExceptionMessage($exceptionMessage);
|
||||
|
||||
$this->resolver->resolve(['option' => $actualType]);
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Process\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\Process\Exception\ProcessFailedException;
|
||||
|
||||
/**
|
||||
@ -19,6 +20,8 @@ use Symfony\Component\Process\Exception\ProcessFailedException;
|
||||
*/
|
||||
class ProcessFailedExceptionTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
/**
|
||||
* tests ProcessFailedException throws exception if the process was successful.
|
||||
*/
|
||||
@ -29,12 +32,8 @@ class ProcessFailedExceptionTest extends TestCase
|
||||
->method('isSuccessful')
|
||||
->willReturn(true);
|
||||
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Expected a failed process, but the given process was successful.');
|
||||
} else {
|
||||
$this->setExpectedException(\InvalidArgumentException::class, 'Expected a failed process, but the given process was successful.');
|
||||
}
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Expected a failed process, but the given process was successful.');
|
||||
|
||||
new ProcessFailedException($process);
|
||||
}
|
||||
|
@ -967,12 +967,8 @@ class ProcessTest extends TestCase
|
||||
{
|
||||
$process = $this->getProcess('foo');
|
||||
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException('Symfony\Component\Process\Exception\LogicException');
|
||||
$this->expectExceptionMessage(sprintf('Process must be started before calling %s.', $method));
|
||||
} else {
|
||||
$this->setExpectedException('Symfony\Component\Process\Exception\LogicException', sprintf('Process must be started before calling %s.', $method));
|
||||
}
|
||||
$this->expectException('Symfony\Component\Process\Exception\LogicException');
|
||||
$this->expectExceptionMessage(sprintf('Process must be started before calling %s.', $method));
|
||||
|
||||
$process->{$method}();
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Routing\Tests\Generator;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\Routing\Generator\UrlGenerator;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
@ -20,6 +21,8 @@ use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
class UrlGeneratorTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
public function testAbsoluteUrlWithPort80()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing'));
|
||||
|
@ -12,11 +12,14 @@
|
||||
namespace Symfony\Component\Security\Core\Tests\Authorization;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\Security\Core\Authorization\AccessDecisionManager;
|
||||
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
|
||||
|
||||
class AccessDecisionManagerTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
|
@ -697,12 +697,8 @@ XML;
|
||||
|
||||
public function testDecodeEmptyXml()
|
||||
{
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException');
|
||||
$this->expectExceptionMessage('Invalid XML data, it can not be empty.');
|
||||
} else {
|
||||
$this->setExpectedException('Symfony\Component\Serializer\Exception\UnexpectedValueException', 'Invalid XML data, it can not be empty.');
|
||||
}
|
||||
$this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException');
|
||||
$this->expectExceptionMessage('Invalid XML data, it can not be empty.');
|
||||
$this->encoder->decode(' ', 'xml');
|
||||
}
|
||||
|
||||
|
@ -12,11 +12,14 @@
|
||||
namespace Symfony\Component\Translation\Tests\Catalogue;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\Translation\MessageCatalogue;
|
||||
use Symfony\Component\Translation\MessageCatalogueInterface;
|
||||
|
||||
abstract class AbstractOperationTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
public function testGetEmptyDomains()
|
||||
{
|
||||
$this->assertEquals(
|
||||
|
@ -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\QtFileLoader;
|
||||
|
||||
class QtFileLoaderTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
public function testLoad()
|
||||
{
|
||||
$loader = new QtFileLoader();
|
||||
@ -67,12 +70,8 @@ class QtFileLoaderTest extends TestCase
|
||||
$loader = new QtFileLoader();
|
||||
$resource = __DIR__.'/../fixtures/empty.xlf';
|
||||
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException');
|
||||
$this->expectExceptionMessage(sprintf('Unable to load "%s".', $resource));
|
||||
} else {
|
||||
$this->setExpectedException('Symfony\Component\Translation\Exception\InvalidResourceException', sprintf('Unable to load "%s".', $resource));
|
||||
}
|
||||
$this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException');
|
||||
$this->expectExceptionMessage(sprintf('Unable to load "%s".', $resource));
|
||||
|
||||
$loader->load($resource, 'en', 'domain1');
|
||||
}
|
||||
|
@ -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\XliffFileLoader;
|
||||
|
||||
class XliffFileLoaderTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
public function testLoad()
|
||||
{
|
||||
$loader = new XliffFileLoader();
|
||||
@ -159,12 +162,8 @@ class XliffFileLoaderTest extends TestCase
|
||||
$loader = new XliffFileLoader();
|
||||
$resource = __DIR__.'/../fixtures/empty.xlf';
|
||||
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException');
|
||||
$this->expectExceptionMessage(sprintf('Unable to load "%s":', $resource));
|
||||
} else {
|
||||
$this->setExpectedException('Symfony\Component\Translation\Exception\InvalidResourceException', sprintf('Unable to load "%s":', $resource));
|
||||
}
|
||||
$this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException');
|
||||
$this->expectExceptionMessage(sprintf('Unable to load "%s":', $resource));
|
||||
|
||||
$loader->load($resource, 'en', 'domain1');
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Validator\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\Validator\Constraint;
|
||||
use Symfony\Component\Validator\Tests\Fixtures\ClassConstraint;
|
||||
use Symfony\Component\Validator\Tests\Fixtures\ConstraintA;
|
||||
@ -22,6 +23,8 @@ use Symfony\Component\Validator\Tests\Fixtures\ConstraintWithValueAsDefault;
|
||||
|
||||
class ConstraintTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
public function testSetProperties()
|
||||
{
|
||||
$constraint = new ConstraintA([
|
||||
|
@ -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\Constraint;
|
||||
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
|
||||
@ -41,6 +42,8 @@ class ComparisonTest_Class
|
||||
*/
|
||||
abstract class AbstractComparisonValidatorTestCase extends ConstraintValidatorTestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
protected static function addPhp5Dot5Comparisons(array $comparisons)
|
||||
{
|
||||
$result = $comparisons;
|
||||
@ -163,12 +166,8 @@ abstract class AbstractComparisonValidatorTestCase extends ConstraintValidatorTe
|
||||
{
|
||||
$constraint = $this->createConstraint(['propertyPath' => 'foo']);
|
||||
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException(ConstraintDefinitionException::class);
|
||||
$this->expectExceptionMessage(sprintf('Invalid property path "foo" provided to "%s" constraint', \get_class($constraint)));
|
||||
} else {
|
||||
$this->setExpectedException(ConstraintDefinitionException::class, sprintf('Invalid property path "foo" provided to "%s" constraint', \get_class($constraint)));
|
||||
}
|
||||
$this->expectException(ConstraintDefinitionException::class);
|
||||
$this->expectExceptionMessage(sprintf('Invalid property path "foo" provided to "%s" constraint', \get_class($constraint)));
|
||||
|
||||
$object = new ComparisonTest_Class(5);
|
||||
|
||||
|
@ -119,12 +119,8 @@ class BicValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
$constraint = new Bic(['ibanPropertyPath' => 'foo']);
|
||||
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException(ConstraintDefinitionException::class);
|
||||
$this->expectExceptionMessage(sprintf('Invalid property path "foo" provided to "%s" constraint', \get_class($constraint)));
|
||||
} else {
|
||||
$this->setExpectedException(ConstraintDefinitionException::class, sprintf('Invalid property path "foo" provided to "%s" constraint', \get_class($constraint)));
|
||||
}
|
||||
$this->expectException(ConstraintDefinitionException::class);
|
||||
$this->expectExceptionMessage(sprintf('Invalid property path "foo" provided to "%s" constraint', \get_class($constraint)));
|
||||
|
||||
$object = new BicComparisonTestClass(5);
|
||||
|
||||
|
@ -12,11 +12,14 @@
|
||||
namespace Symfony\Component\Validator\Tests\Mapping;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\Validator\Mapping\GetterMetadata;
|
||||
use Symfony\Component\Validator\Tests\Fixtures\Entity;
|
||||
|
||||
class GetterMetadataTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
const CLASSNAME = 'Symfony\Component\Validator\Tests\Fixtures\Entity';
|
||||
|
||||
public function testInvalidPropertyName()
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Validator\Tests\Mapping\Loader;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\Validator\Constraints\All;
|
||||
use Symfony\Component\Validator\Constraints\Callback;
|
||||
use Symfony\Component\Validator\Constraints\Choice;
|
||||
@ -29,6 +30,8 @@ use Symfony\Component\Validator\Tests\Fixtures\ConstraintB;
|
||||
|
||||
class XmlFileLoaderTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
public function testLoadClassMetadataReturnsTrueIfSuccessful()
|
||||
{
|
||||
$loader = new XmlFileLoader(__DIR__.'/constraint-mapping.xml');
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Validator\Tests\Mapping\Loader;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\Validator\Constraints\All;
|
||||
use Symfony\Component\Validator\Constraints\Callback;
|
||||
use Symfony\Component\Validator\Constraints\Choice;
|
||||
@ -26,6 +27,8 @@ use Symfony\Component\Validator\Tests\Fixtures\ConstraintB;
|
||||
|
||||
class YamlFileLoaderTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
public function testLoadClassMetadataReturnsFalseIfEmpty()
|
||||
{
|
||||
$loader = new YamlFileLoader(__DIR__.'/empty-mapping.yml');
|
||||
|
@ -12,11 +12,14 @@
|
||||
namespace Symfony\Component\Validator\Tests\Mapping;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||
use Symfony\Component\Validator\Mapping\PropertyMetadata;
|
||||
use Symfony\Component\Validator\Tests\Fixtures\Entity;
|
||||
|
||||
class PropertyMetadataTest extends TestCase
|
||||
{
|
||||
use ForwardCompatTestTrait;
|
||||
|
||||
const CLASSNAME = 'Symfony\Component\Validator\Tests\Fixtures\Entity';
|
||||
const PARENTCLASS = 'Symfony\Component\Validator\Tests\Fixtures\EntityParent';
|
||||
|
||||
|
@ -253,12 +253,8 @@ class InlineTest extends TestCase
|
||||
*/
|
||||
public function testParseUnquotedScalarStartingWithReservedIndicator($indicator)
|
||||
{
|
||||
if (method_exists($this, 'expectExceptionMessage')) {
|
||||
$this->expectException(ParseException::class);
|
||||
$this->expectExceptionMessage(sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo").', $indicator));
|
||||
} else {
|
||||
$this->setExpectedException(ParseException::class, sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo").', $indicator));
|
||||
}
|
||||
$this->expectException(ParseException::class);
|
||||
$this->expectExceptionMessage(sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo").', $indicator));
|
||||
|
||||
Inline::parse(sprintf('{ foo: %sfoo }', $indicator));
|
||||
}
|
||||
@ -273,12 +269,8 @@ class InlineTest extends TestCase
|
||||
*/
|
||||
public function testParseUnquotedScalarStartingWithScalarIndicator($indicator)
|
||||
{
|
||||
if (method_exists($this, 'expectExceptionMessage')) {
|
||||
$this->expectException(ParseException::class);
|
||||
$this->expectExceptionMessage(sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo").', $indicator));
|
||||
} else {
|
||||
$this->setExpectedException(ParseException::class, sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo").', $indicator));
|
||||
}
|
||||
$this->expectException(ParseException::class);
|
||||
$this->expectExceptionMessage(sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo").', $indicator));
|
||||
|
||||
Inline::parse(sprintf('{ foo: %sfoo }', $indicator));
|
||||
}
|
||||
@ -627,11 +619,7 @@ class InlineTest extends TestCase
|
||||
*/
|
||||
public function testParseInvalidBinaryData($data, $expectedMessage)
|
||||
{
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectExceptionMessageRegExp($expectedMessage);
|
||||
} else {
|
||||
$this->setExpectedExceptionRegExp(ParseException::class, $expectedMessage);
|
||||
}
|
||||
$this->expectExceptionMessageRegExp($expectedMessage);
|
||||
|
||||
Inline::parse($data);
|
||||
}
|
||||
|
@ -1374,11 +1374,7 @@ EOT
|
||||
*/
|
||||
public function testParseInvalidBinaryData($data, $expectedMessage)
|
||||
{
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectExceptionMessageRegExp($expectedMessage);
|
||||
} else {
|
||||
$this->setExpectedExceptionRegExp(ParseException::class, $expectedMessage);
|
||||
}
|
||||
$this->expectExceptionMessageRegExp($expectedMessage);
|
||||
|
||||
$this->parser->parse($data);
|
||||
}
|
||||
@ -1445,12 +1441,8 @@ EOT;
|
||||
*/
|
||||
public function testParserThrowsExceptionWithCorrectLineNumber($lineNumber, $yaml)
|
||||
{
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException('\Symfony\Component\Yaml\Exception\ParseException');
|
||||
$this->expectExceptionMessage(sprintf('Unexpected characters near "," at line %d (near "bar: "123",").', $lineNumber));
|
||||
} else {
|
||||
$this->setExpectedException('\Symfony\Component\Yaml\Exception\ParseException', sprintf('Unexpected characters near "," at line %d (near "bar: "123",").', $lineNumber));
|
||||
}
|
||||
$this->expectException('\Symfony\Component\Yaml\Exception\ParseException');
|
||||
$this->expectExceptionMessage(sprintf('Unexpected characters near "," at line %d (near "bar: "123",").', $lineNumber));
|
||||
|
||||
$this->parser->parse($yaml);
|
||||
}
|
||||
|
Reference in New Issue
Block a user