Replace calls to setExpectedException by Pollyfill
This commit is contained in:
parent
9f40b100e5
commit
41c02d7ead
@ -16,9 +16,12 @@ use PHPUnit\Framework\TestCase;
|
|||||||
use Symfony\Bridge\Doctrine\Security\User\EntityUserProvider;
|
use Symfony\Bridge\Doctrine\Security\User\EntityUserProvider;
|
||||||
use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper;
|
use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper;
|
||||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\User;
|
use Symfony\Bridge\Doctrine\Tests\Fixtures\User;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
|
|
||||||
class EntityUserProviderTest extends TestCase
|
class EntityUserProviderTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
public function testRefreshUserGetsUserByPrimaryKey()
|
public function testRefreshUserGetsUserByPrimaryKey()
|
||||||
{
|
{
|
||||||
$em = DoctrineTestHelper::createTestEntityManager();
|
$em = DoctrineTestHelper::createTestEntityManager();
|
||||||
@ -105,10 +108,9 @@ class EntityUserProviderTest extends TestCase
|
|||||||
$user1 = new User(null, null, 'user1');
|
$user1 = new User(null, null, 'user1');
|
||||||
$provider = new EntityUserProvider($this->getManager($em), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User', 'name');
|
$provider = new EntityUserProvider($this->getManager($em), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User', 'name');
|
||||||
|
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(
|
$this->expectException('InvalidArgumentException');
|
||||||
'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');
|
||||||
'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);
|
$provider->refreshUser($user1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,10 +127,9 @@ class EntityUserProviderTest extends TestCase
|
|||||||
$provider = new EntityUserProvider($this->getManager($em), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User', 'name');
|
$provider = new EntityUserProvider($this->getManager($em), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User', 'name');
|
||||||
|
|
||||||
$user2 = new User(1, 2, 'user2');
|
$user2 = new User(1, 2, 'user2');
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(
|
$this->expectException('Symfony\Component\Security\Core\Exception\UsernameNotFoundException');
|
||||||
'Symfony\Component\Security\Core\Exception\UsernameNotFoundException',
|
$this->expectExceptionMessage('User with id {"id1":1,"id2":2} not found');
|
||||||
'User with id {"id1":1,"id2":2} not found'
|
|
||||||
);
|
|
||||||
$provider->refreshUser($user2);
|
$provider->refreshUser($user2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,12 +12,16 @@
|
|||||||
namespace Symfony\Bridge\PhpUnit\Legacy;
|
namespace Symfony\Bridge\PhpUnit\Legacy;
|
||||||
|
|
||||||
use PHPUnit\Framework\MockObject\MockObject;
|
use PHPUnit\Framework\MockObject\MockObject;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
trait ForwardCompatTestTraitForV5
|
trait ForwardCompatTestTraitForV5
|
||||||
{
|
{
|
||||||
|
private $forwardCompatExpectedExceptionMessage = '';
|
||||||
|
private $forwardCompatExpectedExceptionCode = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@ -210,4 +214,93 @@ trait ForwardCompatTestTraitForV5
|
|||||||
{
|
{
|
||||||
static::assertInternalType('iterable', $actual, $message);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace Symfony\Bridge\PhpUnit\Tests;
|
namespace Symfony\Bridge\PhpUnit\Tests;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Don't remove this test case, it tests the legacy group.
|
* Don't remove this test case, it tests the legacy group.
|
||||||
@ -13,6 +14,8 @@ use PHPUnit\Framework\TestCase;
|
|||||||
*/
|
*/
|
||||||
class ProcessIsolationTest extends TestCase
|
class ProcessIsolationTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedDeprecation Test abc
|
* @expectedDeprecation Test abc
|
||||||
*/
|
*/
|
||||||
@ -25,12 +28,8 @@ class ProcessIsolationTest extends TestCase
|
|||||||
public function testCallingOtherErrorHandler()
|
public function testCallingOtherErrorHandler()
|
||||||
{
|
{
|
||||||
$class = class_exists('PHPUnit\Framework\Exception') ? 'PHPUnit\Framework\Exception' : 'PHPUnit_Framework_Exception';
|
$class = class_exists('PHPUnit\Framework\Exception') ? 'PHPUnit\Framework\Exception' : 'PHPUnit_Framework_Exception';
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException($class);
|
$this->expectException($class);
|
||||||
$this->expectExceptionMessage('Test that PHPUnit\'s error handler fires.');
|
$this->expectExceptionMessage('Test that PHPUnit\'s error handler fires.');
|
||||||
} else {
|
|
||||||
$this->setExpectedException($class, 'Test that PHPUnit\'s error handler fires.');
|
|
||||||
}
|
|
||||||
|
|
||||||
trigger_error('Test that PHPUnit\'s error handler fires.', E_USER_WARNING);
|
trigger_error('Test that PHPUnit\'s error handler fires.', E_USER_WARNING);
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Bridge\Twig\Tests\Extension;
|
namespace Symfony\Bridge\Twig\Tests\Extension;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Bridge\Twig\Extension\HttpKernelExtension;
|
use Symfony\Bridge\Twig\Extension\HttpKernelExtension;
|
||||||
use Symfony\Bridge\Twig\Extension\HttpKernelRuntime;
|
use Symfony\Bridge\Twig\Extension\HttpKernelRuntime;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
@ -22,6 +23,8 @@ use Twig\Loader\ArrayLoader;
|
|||||||
|
|
||||||
class HttpKernelExtensionTest extends TestCase
|
class HttpKernelExtensionTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Twig\Error\RuntimeError
|
* @expectedException \Twig\Error\RuntimeError
|
||||||
*/
|
*/
|
||||||
@ -49,12 +52,8 @@ class HttpKernelExtensionTest extends TestCase
|
|||||||
;
|
;
|
||||||
$renderer = new FragmentHandler($context);
|
$renderer = new FragmentHandler($context);
|
||||||
|
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException('InvalidArgumentException');
|
$this->expectException('InvalidArgumentException');
|
||||||
$this->expectExceptionMessage('The "inline" renderer does not exist.');
|
$this->expectExceptionMessage('The "inline" renderer does not exist.');
|
||||||
} else {
|
|
||||||
$this->setExpectedException('InvalidArgumentException', 'The "inline" renderer does not exist.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$renderer->render('/foo');
|
$renderer->render('/foo');
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection;
|
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Configuration;
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Configuration;
|
||||||
use Symfony\Bundle\FullStack;
|
use Symfony\Bundle\FullStack;
|
||||||
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||||
@ -20,6 +21,8 @@ use Symfony\Component\Lock\Store\SemaphoreStore;
|
|||||||
|
|
||||||
class ConfigurationTest extends TestCase
|
class ConfigurationTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
public function testDefaultConfig()
|
public function testDefaultConfig()
|
||||||
{
|
{
|
||||||
$processor = new Processor();
|
$processor = new Processor();
|
||||||
@ -245,12 +248,8 @@ class ConfigurationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testInvalidAssetsConfiguration(array $assetConfig, $expectedMessage)
|
public function testInvalidAssetsConfiguration(array $assetConfig, $expectedMessage)
|
||||||
{
|
{
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException(InvalidConfigurationException::class);
|
$this->expectException(InvalidConfigurationException::class);
|
||||||
$this->expectExceptionMessage($expectedMessage);
|
$this->expectExceptionMessage($expectedMessage);
|
||||||
} else {
|
|
||||||
$this->setExpectedException(InvalidConfigurationException::class, $expectedMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
$processor = new Processor();
|
$processor = new Processor();
|
||||||
$configuration = new Configuration(true);
|
$configuration = new Configuration(true);
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Compiler;
|
namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Compiler;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Bundle\SecurityBundle\DependencyInjection\Compiler\AddSecurityVotersPass;
|
use Symfony\Bundle\SecurityBundle\DependencyInjection\Compiler\AddSecurityVotersPass;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Component\DependencyInjection\Exception\LogicException;
|
use Symfony\Component\DependencyInjection\Exception\LogicException;
|
||||||
@ -21,6 +22,8 @@ use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
|||||||
|
|
||||||
class AddSecurityVotersPassTest extends TestCase
|
class AddSecurityVotersPassTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\DependencyInjection\Exception\LogicException
|
* @expectedException \Symfony\Component\DependencyInjection\Exception\LogicException
|
||||||
*/
|
*/
|
||||||
@ -101,12 +104,8 @@ class AddSecurityVotersPassTest extends TestCase
|
|||||||
$exception = LogicException::class;
|
$exception = LogicException::class;
|
||||||
$message = 'stdClass should implement the Symfony\Component\Security\Core\Authorization\Voter\VoterInterface interface when used as voter.';
|
$message = 'stdClass should implement the Symfony\Component\Security\Core\Authorization\Voter\VoterInterface interface when used as voter.';
|
||||||
|
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException($exception);
|
$this->expectException($exception);
|
||||||
$this->expectExceptionMessage($message);
|
$this->expectExceptionMessage($message);
|
||||||
} else {
|
|
||||||
$this->setExpectedException($exception, $message);
|
|
||||||
}
|
|
||||||
|
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
$container
|
$container
|
||||||
|
@ -170,12 +170,8 @@ class UserPasswordEncoderCommandTest extends AbstractWebTestCase
|
|||||||
|
|
||||||
public function testEncodePasswordNoConfigForGivenUserClass()
|
public function testEncodePasswordNoConfigForGivenUserClass()
|
||||||
{
|
{
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException('\RuntimeException');
|
$this->expectException('\RuntimeException');
|
||||||
$this->expectExceptionMessage('No encoder has been configured for account "Foo\Bar\User".');
|
$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->passwordEncoderCommandTester->execute([
|
$this->passwordEncoderCommandTester->execute([
|
||||||
'command' => 'security:encode-password',
|
'command' => 'security:encode-password',
|
||||||
|
@ -12,10 +12,13 @@
|
|||||||
namespace Symfony\Component\BrowserKit\Tests;
|
namespace Symfony\Component\BrowserKit\Tests;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\BrowserKit\Cookie;
|
use Symfony\Component\BrowserKit\Cookie;
|
||||||
|
|
||||||
class CookieTest extends TestCase
|
class CookieTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
public function testToString()
|
public function testToString()
|
||||||
{
|
{
|
||||||
$cookie = new Cookie('foo', 'bar', strtotime('Fri, 20-May-2011 15:25:52 GMT'), '/', '.myfoodomain.com', true);
|
$cookie = new Cookie('foo', 'bar', strtotime('Fri, 20-May-2011 15:25:52 GMT'), '/', '.myfoodomain.com', true);
|
||||||
@ -100,7 +103,7 @@ class CookieTest extends TestCase
|
|||||||
|
|
||||||
public function testFromStringThrowsAnExceptionIfCookieIsNotValid()
|
public function testFromStringThrowsAnExceptionIfCookieIsNotValid()
|
||||||
{
|
{
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('InvalidArgumentException');
|
$this->expectException('InvalidArgumentException');
|
||||||
Cookie::fromString('foo');
|
Cookie::fromString('foo');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,7 +116,7 @@ class CookieTest extends TestCase
|
|||||||
|
|
||||||
public function testFromStringThrowsAnExceptionIfUrlIsNotValid()
|
public function testFromStringThrowsAnExceptionIfUrlIsNotValid()
|
||||||
{
|
{
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('InvalidArgumentException');
|
$this->expectException('InvalidArgumentException');
|
||||||
Cookie::fromString('foo=bar', 'foobar');
|
Cookie::fromString('foo=bar', 'foobar');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,12 +12,15 @@
|
|||||||
namespace Symfony\Component\Config\Tests\Definition;
|
namespace Symfony\Component\Config\Tests\Definition;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\Config\Definition\ArrayNode;
|
use Symfony\Component\Config\Definition\ArrayNode;
|
||||||
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||||
use Symfony\Component\Config\Definition\ScalarNode;
|
use Symfony\Component\Config\Definition\ScalarNode;
|
||||||
|
|
||||||
class ArrayNodeTest extends TestCase
|
class ArrayNodeTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidTypeException
|
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidTypeException
|
||||||
*/
|
*/
|
||||||
@ -55,12 +58,8 @@ class ArrayNodeTest extends TestCase
|
|||||||
public function testIgnoreAndRemoveBehaviors($ignore, $remove, $expected, $message = '')
|
public function testIgnoreAndRemoveBehaviors($ignore, $remove, $expected, $message = '')
|
||||||
{
|
{
|
||||||
if ($expected instanceof \Exception) {
|
if ($expected instanceof \Exception) {
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException(\get_class($expected));
|
$this->expectException(\get_class($expected));
|
||||||
$this->expectExceptionMessage($expected->getMessage());
|
$this->expectExceptionMessage($expected->getMessage());
|
||||||
} else {
|
|
||||||
$this->setExpectedException(\get_class($expected), $expected->getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$node = new ArrayNode('root');
|
$node = new ArrayNode('root');
|
||||||
$node->setIgnoreExtraKeys($ignore, $remove);
|
$node->setIgnoreExtraKeys($ignore, $remove);
|
||||||
|
@ -12,11 +12,14 @@
|
|||||||
namespace Symfony\Component\Config\Tests\Definition;
|
namespace Symfony\Component\Config\Tests\Definition;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\Config\Definition\ArrayNode;
|
use Symfony\Component\Config\Definition\ArrayNode;
|
||||||
use Symfony\Component\Config\Definition\ScalarNode;
|
use Symfony\Component\Config\Definition\ScalarNode;
|
||||||
|
|
||||||
class ScalarNodeTest extends TestCase
|
class ScalarNodeTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider getValidValues
|
* @dataProvider getValidValues
|
||||||
*/
|
*/
|
||||||
@ -95,12 +98,8 @@ class ScalarNodeTest extends TestCase
|
|||||||
{
|
{
|
||||||
$node = new ScalarNode('test');
|
$node = new ScalarNode('test');
|
||||||
|
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException');
|
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException');
|
||||||
$this->expectExceptionMessage('Invalid type for path "test". Expected scalar, but got array.');
|
$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.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$node->normalize([]);
|
$node->normalize([]);
|
||||||
}
|
}
|
||||||
@ -110,12 +109,8 @@ class ScalarNodeTest extends TestCase
|
|||||||
$node = new ScalarNode('test');
|
$node = new ScalarNode('test');
|
||||||
$node->setInfo('"the test value"');
|
$node->setInfo('"the test value"');
|
||||||
|
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException');
|
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException');
|
||||||
$this->expectExceptionMessage("Invalid type for path \"test\". Expected scalar, but got array.\nHint: \"the test value\"");
|
$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\"");
|
|
||||||
}
|
|
||||||
|
|
||||||
$node->normalize([]);
|
$node->normalize([]);
|
||||||
}
|
}
|
||||||
|
@ -12,10 +12,13 @@
|
|||||||
namespace Symfony\Component\Config\Tests\Util;
|
namespace Symfony\Component\Config\Tests\Util;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\Config\Util\XmlUtils;
|
use Symfony\Component\Config\Util\XmlUtils;
|
||||||
|
|
||||||
class XmlUtilsTest extends TestCase
|
class XmlUtilsTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
public function testLoadFile()
|
public function testLoadFile()
|
||||||
{
|
{
|
||||||
$fixtures = __DIR__.'/../Fixtures/Util/';
|
$fixtures = __DIR__.'/../Fixtures/Util/';
|
||||||
@ -166,12 +169,8 @@ class XmlUtilsTest extends TestCase
|
|||||||
{
|
{
|
||||||
$file = __DIR__.'/../Fixtures/foo.xml';
|
$file = __DIR__.'/../Fixtures/foo.xml';
|
||||||
|
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException('InvalidArgumentException');
|
$this->expectException('InvalidArgumentException');
|
||||||
$this->expectExceptionMessage(sprintf('File %s does not contain valid XML, it is empty.', $file));
|
$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));
|
|
||||||
}
|
|
||||||
|
|
||||||
XmlUtils::loadFile($file);
|
XmlUtils::loadFile($file);
|
||||||
}
|
}
|
||||||
|
@ -314,12 +314,8 @@ class ApplicationTest extends TestCase
|
|||||||
|
|
||||||
$expectedMsg = "The namespace \"f\" is ambiguous.\nDid you mean one of these?\n foo\n foo1";
|
$expectedMsg = "The namespace \"f\" is ambiguous.\nDid you mean one of these?\n foo\n foo1";
|
||||||
|
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException(CommandNotFoundException::class);
|
$this->expectException(CommandNotFoundException::class);
|
||||||
$this->expectExceptionMessage($expectedMsg);
|
$this->expectExceptionMessage($expectedMsg);
|
||||||
} else {
|
|
||||||
$this->setExpectedException(CommandNotFoundException::class, $expectedMsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
$application->findNamespace('f');
|
$application->findNamespace('f');
|
||||||
}
|
}
|
||||||
@ -423,12 +419,8 @@ class ApplicationTest extends TestCase
|
|||||||
public function testFindWithAmbiguousAbbreviations($abbreviation, $expectedExceptionMessage)
|
public function testFindWithAmbiguousAbbreviations($abbreviation, $expectedExceptionMessage)
|
||||||
{
|
{
|
||||||
putenv('COLUMNS=120');
|
putenv('COLUMNS=120');
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException('Symfony\Component\Console\Exception\CommandNotFoundException');
|
$this->expectException('Symfony\Component\Console\Exception\CommandNotFoundException');
|
||||||
$this->expectExceptionMessage($expectedExceptionMessage);
|
$this->expectExceptionMessage($expectedExceptionMessage);
|
||||||
} else {
|
|
||||||
$this->setExpectedException('Symfony\Component\Console\Exception\CommandNotFoundException', $expectedExceptionMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
$application = new Application();
|
$application = new Application();
|
||||||
$application->add(new \FooCommand());
|
$application->add(new \FooCommand());
|
||||||
|
@ -120,12 +120,8 @@ class CommandTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testInvalidCommandNames($name)
|
public function testInvalidCommandNames($name)
|
||||||
{
|
{
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException('InvalidArgumentException');
|
$this->expectException('InvalidArgumentException');
|
||||||
$this->expectExceptionMessage(sprintf('Command name "%s" is invalid.', $name));
|
$this->expectExceptionMessage(sprintf('Command name "%s" is invalid.', $name));
|
||||||
} else {
|
|
||||||
$this->setExpectedException('InvalidArgumentException', sprintf('Command name "%s" is invalid.', $name));
|
|
||||||
}
|
|
||||||
|
|
||||||
$command = new \TestCommand();
|
$command = new \TestCommand();
|
||||||
$command->setName($name);
|
$command->setName($name);
|
||||||
@ -191,7 +187,7 @@ class CommandTest extends TestCase
|
|||||||
public function testSetAliasesNull()
|
public function testSetAliasesNull()
|
||||||
{
|
{
|
||||||
$command = new \TestCommand();
|
$command = new \TestCommand();
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('InvalidArgumentException');
|
$this->expectException('InvalidArgumentException');
|
||||||
$command->setAliases(null);
|
$command->setAliases(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,10 +12,13 @@
|
|||||||
namespace Symfony\Component\Console\Tests\Formatter;
|
namespace Symfony\Component\Console\Tests\Formatter;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
|
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
|
||||||
|
|
||||||
class OutputFormatterStyleTest extends TestCase
|
class OutputFormatterStyleTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
public function testConstructor()
|
public function testConstructor()
|
||||||
{
|
{
|
||||||
$style = new OutputFormatterStyle('green', 'black', ['bold', 'underscore']);
|
$style = new OutputFormatterStyle('green', 'black', ['bold', 'underscore']);
|
||||||
@ -41,7 +44,7 @@ class OutputFormatterStyleTest extends TestCase
|
|||||||
$style->setForeground('default');
|
$style->setForeground('default');
|
||||||
$this->assertEquals("\033[39mfoo\033[39m", $style->apply('foo'));
|
$this->assertEquals("\033[39mfoo\033[39m", $style->apply('foo'));
|
||||||
|
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('InvalidArgumentException');
|
$this->expectException('InvalidArgumentException');
|
||||||
$style->setForeground('undefined-color');
|
$style->setForeground('undefined-color');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +61,7 @@ class OutputFormatterStyleTest extends TestCase
|
|||||||
$style->setBackground('default');
|
$style->setBackground('default');
|
||||||
$this->assertEquals("\033[49mfoo\033[49m", $style->apply('foo'));
|
$this->assertEquals("\033[49mfoo\033[49m", $style->apply('foo'));
|
||||||
|
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('InvalidArgumentException');
|
$this->expectException('InvalidArgumentException');
|
||||||
$style->setBackground('undefined-color');
|
$style->setBackground('undefined-color');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Component\Console\Tests\Input;
|
namespace Symfony\Component\Console\Tests\Input;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\Console\Input\ArgvInput;
|
use Symfony\Component\Console\Input\ArgvInput;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputDefinition;
|
use Symfony\Component\Console\Input\InputDefinition;
|
||||||
@ -19,6 +20,8 @@ use Symfony\Component\Console\Input\InputOption;
|
|||||||
|
|
||||||
class ArgvInputTest extends TestCase
|
class ArgvInputTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
public function testConstructor()
|
public function testConstructor()
|
||||||
{
|
{
|
||||||
$_SERVER['argv'] = ['cli.php', 'foo'];
|
$_SERVER['argv'] = ['cli.php', 'foo'];
|
||||||
@ -182,12 +185,8 @@ class ArgvInputTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testInvalidInput($argv, $definition, $expectedExceptionMessage)
|
public function testInvalidInput($argv, $definition, $expectedExceptionMessage)
|
||||||
{
|
{
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException('RuntimeException');
|
$this->expectException('RuntimeException');
|
||||||
$this->expectExceptionMessage($expectedExceptionMessage);
|
$this->expectExceptionMessage($expectedExceptionMessage);
|
||||||
} else {
|
|
||||||
$this->setExpectedException('RuntimeException', $expectedExceptionMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
$input = new ArgvInput($argv);
|
$input = new ArgvInput($argv);
|
||||||
$input->bind($definition);
|
$input->bind($definition);
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Component\Console\Tests\Input;
|
namespace Symfony\Component\Console\Tests\Input;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\Console\Input\ArrayInput;
|
use Symfony\Component\Console\Input\ArrayInput;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputDefinition;
|
use Symfony\Component\Console\Input\InputDefinition;
|
||||||
@ -19,6 +20,8 @@ use Symfony\Component\Console\Input\InputOption;
|
|||||||
|
|
||||||
class ArrayInputTest extends TestCase
|
class ArrayInputTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
public function testGetFirstArgument()
|
public function testGetFirstArgument()
|
||||||
{
|
{
|
||||||
$input = new ArrayInput([]);
|
$input = new ArrayInput([]);
|
||||||
@ -127,12 +130,8 @@ class ArrayInputTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testParseInvalidInput($parameters, $definition, $expectedExceptionMessage)
|
public function testParseInvalidInput($parameters, $definition, $expectedExceptionMessage)
|
||||||
{
|
{
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException('InvalidArgumentException');
|
$this->expectException('InvalidArgumentException');
|
||||||
$this->expectExceptionMessage($expectedExceptionMessage);
|
$this->expectExceptionMessage($expectedExceptionMessage);
|
||||||
} else {
|
|
||||||
$this->setExpectedException('InvalidArgumentException', $expectedExceptionMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
new ArrayInput($parameters, $definition);
|
new ArrayInput($parameters, $definition);
|
||||||
}
|
}
|
||||||
|
@ -12,10 +12,13 @@
|
|||||||
namespace Symfony\Component\Console\Tests\Input;
|
namespace Symfony\Component\Console\Tests\Input;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
|
|
||||||
class InputArgumentTest extends TestCase
|
class InputArgumentTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
public function testConstructor()
|
public function testConstructor()
|
||||||
{
|
{
|
||||||
$argument = new InputArgument('foo');
|
$argument = new InputArgument('foo');
|
||||||
@ -42,12 +45,8 @@ class InputArgumentTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testInvalidModes($mode)
|
public function testInvalidModes($mode)
|
||||||
{
|
{
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException('InvalidArgumentException');
|
$this->expectException('InvalidArgumentException');
|
||||||
$this->expectExceptionMessage(sprintf('Argument mode "%s" is not valid.', $mode));
|
$this->expectExceptionMessage(sprintf('Argument mode "%s" is not valid.', $mode));
|
||||||
} else {
|
|
||||||
$this->setExpectedException('InvalidArgumentException', sprintf('Argument mode "%s" is not valid.', $mode));
|
|
||||||
}
|
|
||||||
|
|
||||||
new InputArgument('foo', $mode);
|
new InputArgument('foo', $mode);
|
||||||
}
|
}
|
||||||
|
@ -12,10 +12,13 @@
|
|||||||
namespace Symfony\Component\Console\Tests\Input;
|
namespace Symfony\Component\Console\Tests\Input;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
|
||||||
class InputOptionTest extends TestCase
|
class InputOptionTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
public function testConstructor()
|
public function testConstructor()
|
||||||
{
|
{
|
||||||
$option = new InputOption('foo');
|
$option = new InputOption('foo');
|
||||||
@ -78,12 +81,8 @@ class InputOptionTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testInvalidModes($mode)
|
public function testInvalidModes($mode)
|
||||||
{
|
{
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException('InvalidArgumentException');
|
$this->expectException('InvalidArgumentException');
|
||||||
$this->expectExceptionMessage(sprintf('Option mode "%s" is not valid.', $mode));
|
$this->expectExceptionMessage(sprintf('Option mode "%s" is not valid.', $mode));
|
||||||
} else {
|
|
||||||
$this->setExpectedException('InvalidArgumentException', sprintf('Option mode "%s" is not valid.', $mode));
|
|
||||||
}
|
|
||||||
|
|
||||||
new InputOption('foo', 'f', $mode);
|
new InputOption('foo', 'f', $mode);
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Component\CssSelector\Tests\Parser;
|
namespace Symfony\Component\CssSelector\Tests\Parser;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\CssSelector\Exception\SyntaxErrorException;
|
use Symfony\Component\CssSelector\Exception\SyntaxErrorException;
|
||||||
use Symfony\Component\CssSelector\Node\FunctionNode;
|
use Symfony\Component\CssSelector\Node\FunctionNode;
|
||||||
use Symfony\Component\CssSelector\Node\SelectorNode;
|
use Symfony\Component\CssSelector\Node\SelectorNode;
|
||||||
@ -20,6 +21,8 @@ use Symfony\Component\CssSelector\Parser\Token;
|
|||||||
|
|
||||||
class ParserTest extends TestCase
|
class ParserTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
/** @dataProvider getParserTestData */
|
/** @dataProvider getParserTestData */
|
||||||
public function testParser($source, $representation)
|
public function testParser($source, $representation)
|
||||||
{
|
{
|
||||||
@ -89,7 +92,7 @@ class ParserTest extends TestCase
|
|||||||
|
|
||||||
/** @var FunctionNode $function */
|
/** @var FunctionNode $function */
|
||||||
$function = $selectors[0]->getTree();
|
$function = $selectors[0]->getTree();
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\CssSelector\Exception\SyntaxErrorException');
|
$this->expectException('Symfony\Component\CssSelector\Exception\SyntaxErrorException');
|
||||||
Parser::parseSeries($function->getArguments());
|
Parser::parseSeries($function->getArguments());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,11 +12,14 @@
|
|||||||
namespace Symfony\Component\CssSelector\Tests\Parser;
|
namespace Symfony\Component\CssSelector\Tests\Parser;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\CssSelector\Parser\Token;
|
use Symfony\Component\CssSelector\Parser\Token;
|
||||||
use Symfony\Component\CssSelector\Parser\TokenStream;
|
use Symfony\Component\CssSelector\Parser\TokenStream;
|
||||||
|
|
||||||
class TokenStreamTest extends TestCase
|
class TokenStreamTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
public function testGetNext()
|
public function testGetNext()
|
||||||
{
|
{
|
||||||
$stream = new TokenStream();
|
$stream = new TokenStream();
|
||||||
@ -53,7 +56,7 @@ class TokenStreamTest extends TestCase
|
|||||||
|
|
||||||
public function testFailToGetNextIdentifier()
|
public function testFailToGetNextIdentifier()
|
||||||
{
|
{
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\CssSelector\Exception\SyntaxErrorException');
|
$this->expectException('Symfony\Component\CssSelector\Exception\SyntaxErrorException');
|
||||||
|
|
||||||
$stream = new TokenStream();
|
$stream = new TokenStream();
|
||||||
$stream->push(new Token(Token::TYPE_DELIMITER, '.', 2));
|
$stream->push(new Token(Token::TYPE_DELIMITER, '.', 2));
|
||||||
@ -73,7 +76,7 @@ class TokenStreamTest extends TestCase
|
|||||||
|
|
||||||
public function testFailToGetNextIdentifierOrStar()
|
public function testFailToGetNextIdentifierOrStar()
|
||||||
{
|
{
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\CssSelector\Exception\SyntaxErrorException');
|
$this->expectException('Symfony\Component\CssSelector\Exception\SyntaxErrorException');
|
||||||
|
|
||||||
$stream = new TokenStream();
|
$stream = new TokenStream();
|
||||||
$stream->push(new Token(Token::TYPE_DELIMITER, '.', 2));
|
$stream->push(new Token(Token::TYPE_DELIMITER, '.', 2));
|
||||||
|
@ -13,6 +13,7 @@ namespace Symfony\Component\DependencyInjection\Tests\Compiler;
|
|||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use PHPUnit\Framework\Warning;
|
use PHPUnit\Framework\Warning;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\Config\FileLocator;
|
use Symfony\Component\Config\FileLocator;
|
||||||
use Symfony\Component\DependencyInjection\Compiler\AutowirePass;
|
use Symfony\Component\DependencyInjection\Compiler\AutowirePass;
|
||||||
use Symfony\Component\DependencyInjection\Compiler\AutowireRequiredMethodsPass;
|
use Symfony\Component\DependencyInjection\Compiler\AutowireRequiredMethodsPass;
|
||||||
@ -33,6 +34,8 @@ require_once __DIR__.'/../Fixtures/includes/autowiring_classes.php';
|
|||||||
*/
|
*/
|
||||||
class AutowirePassTest extends TestCase
|
class AutowirePassTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
public function testProcess()
|
public function testProcess()
|
||||||
{
|
{
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
@ -841,12 +844,8 @@ class AutowirePassTest extends TestCase
|
|||||||
$foo->addMethodCall($method, []);
|
$foo->addMethodCall($method, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException(RuntimeException::class);
|
$this->expectException(RuntimeException::class);
|
||||||
$this->expectExceptionMessage($expectedMsg);
|
$this->expectExceptionMessage($expectedMsg);
|
||||||
} else {
|
|
||||||
$this->setExpectedException(RuntimeException::class, $expectedMsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
(new ResolveClassPass())->process($container);
|
(new ResolveClassPass())->process($container);
|
||||||
(new AutowireRequiredMethodsPass())->process($container);
|
(new AutowireRequiredMethodsPass())->process($container);
|
||||||
|
@ -1056,7 +1056,7 @@ class ContainerBuilderTest extends TestCase
|
|||||||
$container->registerExtension($extension = new \ProjectExtension());
|
$container->registerExtension($extension = new \ProjectExtension());
|
||||||
$this->assertSame($container->getExtension('project'), $extension, '->registerExtension() registers an extension');
|
$this->assertSame($container->getExtension('project'), $extension, '->registerExtension() registers an extension');
|
||||||
|
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('LogicException');
|
$this->expectException('LogicException');
|
||||||
$container->getExtension('no_registered');
|
$container->getExtension('no_registered');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,10 +12,13 @@
|
|||||||
namespace Symfony\Component\DependencyInjection\Tests;
|
namespace Symfony\Component\DependencyInjection\Tests;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\DependencyInjection\Definition;
|
use Symfony\Component\DependencyInjection\Definition;
|
||||||
|
|
||||||
class DefinitionTest extends TestCase
|
class DefinitionTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
public function testConstructor()
|
public function testConstructor()
|
||||||
{
|
{
|
||||||
$def = new Definition('stdClass');
|
$def = new Definition('stdClass');
|
||||||
@ -69,12 +72,8 @@ class DefinitionTest extends TestCase
|
|||||||
|
|
||||||
$def = new Definition('stdClass');
|
$def = new Definition('stdClass');
|
||||||
|
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException('InvalidArgumentException');
|
$this->expectException('InvalidArgumentException');
|
||||||
$this->expectExceptionMessage('The decorated service inner name for "foo" must be different than the service name itself.');
|
$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.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$def->setDecoratedService('foo', 'foo');
|
$def->setDecoratedService('foo', 'foo');
|
||||||
}
|
}
|
||||||
|
@ -550,12 +550,8 @@ class PhpDumperTest extends TestCase
|
|||||||
$dumper = new PhpDumper($container);
|
$dumper = new PhpDumper($container);
|
||||||
|
|
||||||
$message = 'Circular reference detected for service "foo", path: "foo -> bar -> foo". Try running "composer require symfony/proxy-manager-bridge".';
|
$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->expectException(ServiceCircularReferenceException::class);
|
||||||
$this->expectExceptionMessage($message);
|
$this->expectExceptionMessage($message);
|
||||||
} else {
|
|
||||||
$this->setExpectedException(ServiceCircularReferenceException::class, $message);
|
|
||||||
}
|
|
||||||
|
|
||||||
$dumper->dump();
|
$dumper->dump();
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Component\DependencyInjection\Tests\ParameterBag;
|
namespace Symfony\Component\DependencyInjection\Tests\ParameterBag;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\DependencyInjection\Exception\ParameterCircularReferenceException;
|
use Symfony\Component\DependencyInjection\Exception\ParameterCircularReferenceException;
|
||||||
use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
|
use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
|
||||||
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
||||||
@ -19,6 +20,8 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
|||||||
|
|
||||||
class ParameterBagTest extends TestCase
|
class ParameterBagTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
public function testConstructor()
|
public function testConstructor()
|
||||||
{
|
{
|
||||||
$bag = new ParameterBag($parameters = [
|
$bag = new ParameterBag($parameters = [
|
||||||
@ -78,12 +81,8 @@ class ParameterBagTest extends TestCase
|
|||||||
'fiz' => ['bar' => ['boo' => 12]],
|
'fiz' => ['bar' => ['boo' => 12]],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException(ParameterNotFoundException::class);
|
$this->expectException(ParameterNotFoundException::class);
|
||||||
$this->expectExceptionMessage($exceptionMessage);
|
$this->expectExceptionMessage($exceptionMessage);
|
||||||
} else {
|
|
||||||
$this->setExpectedException(ParameterNotFoundException::class, $exceptionMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
$bag->get($parameterKey);
|
$bag->get($parameterKey);
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ class GenericEventTest extends TestCase
|
|||||||
$this->assertEquals('Event', $this->event['name']);
|
$this->assertEquals('Event', $this->event['name']);
|
||||||
|
|
||||||
// test getting invalid arg
|
// test getting invalid arg
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('InvalidArgumentException');
|
$this->expectException('InvalidArgumentException');
|
||||||
$this->assertFalse($this->event['nameNotExist']);
|
$this->assertFalse($this->event['nameNotExist']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Component\ExpressionLanguage\Tests;
|
namespace Symfony\Component\ExpressionLanguage\Tests;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\ExpressionLanguage\Node\Node;
|
use Symfony\Component\ExpressionLanguage\Node\Node;
|
||||||
use Symfony\Component\ExpressionLanguage\ParsedExpression;
|
use Symfony\Component\ExpressionLanguage\ParsedExpression;
|
||||||
use Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheAdapter;
|
use Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheAdapter;
|
||||||
@ -21,6 +22,8 @@ use Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheAdapter;
|
|||||||
*/
|
*/
|
||||||
class ParserCacheAdapterTest extends TestCase
|
class ParserCacheAdapterTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
public function testGetItem()
|
public function testGetItem()
|
||||||
{
|
{
|
||||||
$poolMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
|
$poolMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
|
||||||
@ -75,7 +78,7 @@ class ParserCacheAdapterTest extends TestCase
|
|||||||
{
|
{
|
||||||
$poolMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
|
$poolMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
|
||||||
$parserCacheAdapter = new ParserCacheAdapter($poolMock);
|
$parserCacheAdapter = new ParserCacheAdapter($poolMock);
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(\BadMethodCallException::class);
|
$this->expectException(\BadMethodCallException::class);
|
||||||
|
|
||||||
$parserCacheAdapter->getItems();
|
$parserCacheAdapter->getItems();
|
||||||
}
|
}
|
||||||
@ -85,7 +88,7 @@ class ParserCacheAdapterTest extends TestCase
|
|||||||
$poolMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
|
$poolMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
|
||||||
$key = 'key';
|
$key = 'key';
|
||||||
$parserCacheAdapter = new ParserCacheAdapter($poolMock);
|
$parserCacheAdapter = new ParserCacheAdapter($poolMock);
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(\BadMethodCallException::class);
|
$this->expectException(\BadMethodCallException::class);
|
||||||
|
|
||||||
$parserCacheAdapter->hasItem($key);
|
$parserCacheAdapter->hasItem($key);
|
||||||
}
|
}
|
||||||
@ -94,7 +97,7 @@ class ParserCacheAdapterTest extends TestCase
|
|||||||
{
|
{
|
||||||
$poolMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
|
$poolMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
|
||||||
$parserCacheAdapter = new ParserCacheAdapter($poolMock);
|
$parserCacheAdapter = new ParserCacheAdapter($poolMock);
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(\BadMethodCallException::class);
|
$this->expectException(\BadMethodCallException::class);
|
||||||
|
|
||||||
$parserCacheAdapter->clear();
|
$parserCacheAdapter->clear();
|
||||||
}
|
}
|
||||||
@ -104,7 +107,7 @@ class ParserCacheAdapterTest extends TestCase
|
|||||||
$poolMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
|
$poolMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
|
||||||
$key = 'key';
|
$key = 'key';
|
||||||
$parserCacheAdapter = new ParserCacheAdapter($poolMock);
|
$parserCacheAdapter = new ParserCacheAdapter($poolMock);
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(\BadMethodCallException::class);
|
$this->expectException(\BadMethodCallException::class);
|
||||||
|
|
||||||
$parserCacheAdapter->deleteItem($key);
|
$parserCacheAdapter->deleteItem($key);
|
||||||
}
|
}
|
||||||
@ -114,7 +117,7 @@ class ParserCacheAdapterTest extends TestCase
|
|||||||
$poolMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
|
$poolMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
|
||||||
$keys = ['key'];
|
$keys = ['key'];
|
||||||
$parserCacheAdapter = new ParserCacheAdapter($poolMock);
|
$parserCacheAdapter = new ParserCacheAdapter($poolMock);
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(\BadMethodCallException::class);
|
$this->expectException(\BadMethodCallException::class);
|
||||||
|
|
||||||
$parserCacheAdapter->deleteItems($keys);
|
$parserCacheAdapter->deleteItems($keys);
|
||||||
}
|
}
|
||||||
@ -124,7 +127,7 @@ class ParserCacheAdapterTest extends TestCase
|
|||||||
$poolMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
|
$poolMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
|
||||||
$parserCacheAdapter = new ParserCacheAdapter($poolMock);
|
$parserCacheAdapter = new ParserCacheAdapter($poolMock);
|
||||||
$cacheItemMock = $this->getMockBuilder('Psr\Cache\CacheItemInterface')->getMock();
|
$cacheItemMock = $this->getMockBuilder('Psr\Cache\CacheItemInterface')->getMock();
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(\BadMethodCallException::class);
|
$this->expectException(\BadMethodCallException::class);
|
||||||
|
|
||||||
$parserCacheAdapter->saveDeferred($cacheItemMock);
|
$parserCacheAdapter->saveDeferred($cacheItemMock);
|
||||||
}
|
}
|
||||||
@ -133,7 +136,7 @@ class ParserCacheAdapterTest extends TestCase
|
|||||||
{
|
{
|
||||||
$poolMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
|
$poolMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
|
||||||
$parserCacheAdapter = new ParserCacheAdapter($poolMock);
|
$parserCacheAdapter = new ParserCacheAdapter($poolMock);
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(\BadMethodCallException::class);
|
$this->expectException(\BadMethodCallException::class);
|
||||||
|
|
||||||
$parserCacheAdapter->commit();
|
$parserCacheAdapter->commit();
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Component\Form\Tests;
|
namespace Symfony\Component\Form\Tests;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\Form\ButtonBuilder;
|
use Symfony\Component\Form\ButtonBuilder;
|
||||||
use Symfony\Component\Form\Exception\InvalidArgumentException;
|
use Symfony\Component\Form\Exception\InvalidArgumentException;
|
||||||
|
|
||||||
@ -20,6 +21,8 @@ use Symfony\Component\Form\Exception\InvalidArgumentException;
|
|||||||
*/
|
*/
|
||||||
class ButtonBuilderTest extends TestCase
|
class ButtonBuilderTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
public function getValidNames()
|
public function getValidNames()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
@ -54,12 +57,8 @@ class ButtonBuilderTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testInvalidNames($name)
|
public function testInvalidNames($name)
|
||||||
{
|
{
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException(InvalidArgumentException::class);
|
$this->expectException(InvalidArgumentException::class);
|
||||||
$this->expectExceptionMessage('Buttons cannot have empty names.');
|
$this->expectExceptionMessage('Buttons cannot have empty names.');
|
||||||
} else {
|
|
||||||
$this->setExpectedException(InvalidArgumentException::class, 'Buttons cannot have empty names.');
|
|
||||||
}
|
|
||||||
new ButtonBuilder($name);
|
new ButtonBuilder($name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Component\Form\Tests\Command;
|
namespace Symfony\Component\Form\Tests\Command;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\Console\Application;
|
use Symfony\Component\Console\Application;
|
||||||
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||||
use Symfony\Component\Console\Tester\CommandTester;
|
use Symfony\Component\Console\Tester\CommandTester;
|
||||||
@ -21,6 +22,8 @@ use Symfony\Component\Form\ResolvedFormTypeFactory;
|
|||||||
|
|
||||||
class DebugCommandTest extends TestCase
|
class DebugCommandTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
public function testDebugDefaults()
|
public function testDebugDefaults()
|
||||||
{
|
{
|
||||||
$tester = $this->createCommandTester();
|
$tester = $this->createCommandTester();
|
||||||
@ -68,12 +71,8 @@ Did you mean one of these?
|
|||||||
Symfony\Component\Form\Tests\Fixtures\Debug\B\AmbiguousType
|
Symfony\Component\Form\Tests\Fixtures\Debug\B\AmbiguousType
|
||||||
TXT;
|
TXT;
|
||||||
|
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException(InvalidArgumentException::class);
|
$this->expectException(InvalidArgumentException::class);
|
||||||
$this->expectExceptionMessage($expectedMessage);
|
$this->expectExceptionMessage($expectedMessage);
|
||||||
} else {
|
|
||||||
$this->setExpectedException(InvalidArgumentException::class, $expectedMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
$tester = $this->createCommandTester([
|
$tester = $this->createCommandTester([
|
||||||
'Symfony\Component\Form\Tests\Fixtures\Debug\A',
|
'Symfony\Component\Form\Tests\Fixtures\Debug\A',
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
|
namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
|
||||||
|
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\Form\Exception\TransformationFailedException;
|
use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||||
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||||
use Symfony\Component\Form\Extension\Core\DataTransformer\DateIntervalToArrayTransformer;
|
use Symfony\Component\Form\Extension\Core\DataTransformer\DateIntervalToArrayTransformer;
|
||||||
@ -20,6 +21,8 @@ use Symfony\Component\Form\Extension\Core\DataTransformer\DateIntervalToArrayTra
|
|||||||
*/
|
*/
|
||||||
class DateIntervalToArrayTransformerTest extends DateIntervalTestCase
|
class DateIntervalToArrayTransformerTest extends DateIntervalTestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
public function testTransform()
|
public function testTransform()
|
||||||
{
|
{
|
||||||
$transformer = new DateIntervalToArrayTransformer();
|
$transformer = new DateIntervalToArrayTransformer();
|
||||||
@ -176,7 +179,7 @@ class DateIntervalToArrayTransformerTest extends DateIntervalTestCase
|
|||||||
{
|
{
|
||||||
$transformer = new DateIntervalToArrayTransformer();
|
$transformer = new DateIntervalToArrayTransformer();
|
||||||
$this->assertNull($transformer->reverseTransform(null));
|
$this->assertNull($transformer->reverseTransform(null));
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(UnexpectedTypeException::class);
|
$this->expectException(UnexpectedTypeException::class);
|
||||||
$transformer->reverseTransform('12345');
|
$transformer->reverseTransform('12345');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +187,7 @@ class DateIntervalToArrayTransformerTest extends DateIntervalTestCase
|
|||||||
{
|
{
|
||||||
$transformer = new DateIntervalToArrayTransformer();
|
$transformer = new DateIntervalToArrayTransformer();
|
||||||
$input = ['years' => '1'];
|
$input = ['years' => '1'];
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(TransformationFailedException::class);
|
$this->expectException(TransformationFailedException::class);
|
||||||
$transformer->reverseTransform($input);
|
$transformer->reverseTransform($input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,12 +199,8 @@ class DateIntervalToArrayTransformerTest extends DateIntervalTestCase
|
|||||||
'minutes' => '',
|
'minutes' => '',
|
||||||
'seconds' => '6',
|
'seconds' => '6',
|
||||||
];
|
];
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException(TransformationFailedException::class);
|
$this->expectException(TransformationFailedException::class);
|
||||||
$this->expectExceptionMessage('This amount of "minutes" is invalid');
|
$this->expectExceptionMessage('This amount of "minutes" is invalid');
|
||||||
} else {
|
|
||||||
$this->setExpectedException(TransformationFailedException::class, 'This amount of "minutes" is invalid');
|
|
||||||
}
|
|
||||||
$transformer->reverseTransform($input);
|
$transformer->reverseTransform($input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,12 +210,8 @@ class DateIntervalToArrayTransformerTest extends DateIntervalTestCase
|
|||||||
$input = [
|
$input = [
|
||||||
'invert' => '1',
|
'invert' => '1',
|
||||||
];
|
];
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException(TransformationFailedException::class);
|
$this->expectException(TransformationFailedException::class);
|
||||||
$this->expectExceptionMessage('The value of "invert" must be boolean');
|
$this->expectExceptionMessage('The value of "invert" must be boolean');
|
||||||
} else {
|
|
||||||
$this->setExpectedException(TransformationFailedException::class, 'The value of "invert" must be boolean');
|
|
||||||
}
|
|
||||||
$transformer->reverseTransform($input);
|
$transformer->reverseTransform($input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
|
namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
|
||||||
|
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\Form\Exception\TransformationFailedException;
|
use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||||
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||||
use Symfony\Component\Form\Extension\Core\DataTransformer\DateIntervalToStringTransformer;
|
use Symfony\Component\Form\Extension\Core\DataTransformer\DateIntervalToStringTransformer;
|
||||||
@ -20,6 +21,8 @@ use Symfony\Component\Form\Extension\Core\DataTransformer\DateIntervalToStringTr
|
|||||||
*/
|
*/
|
||||||
class DateIntervalToStringTransformerTest extends DateIntervalTestCase
|
class DateIntervalToStringTransformerTest extends DateIntervalTestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
public function dataProviderISO()
|
public function dataProviderISO()
|
||||||
{
|
{
|
||||||
$data = [
|
$data = [
|
||||||
@ -75,7 +78,7 @@ class DateIntervalToStringTransformerTest extends DateIntervalTestCase
|
|||||||
public function testTransformExpectsDateTime()
|
public function testTransformExpectsDateTime()
|
||||||
{
|
{
|
||||||
$transformer = new DateIntervalToStringTransformer();
|
$transformer = new DateIntervalToStringTransformer();
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(UnexpectedTypeException::class);
|
$this->expectException(UnexpectedTypeException::class);
|
||||||
$transformer->transform('1234');
|
$transformer->transform('1234');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +99,7 @@ class DateIntervalToStringTransformerTest extends DateIntervalTestCase
|
|||||||
{
|
{
|
||||||
$reverseTransformer = new DateIntervalToStringTransformer($format, true);
|
$reverseTransformer = new DateIntervalToStringTransformer($format, true);
|
||||||
$interval = new \DateInterval($output);
|
$interval = new \DateInterval($output);
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(TransformationFailedException::class);
|
$this->expectException(TransformationFailedException::class);
|
||||||
$this->assertDateIntervalEquals($interval, $reverseTransformer->reverseTransform($input));
|
$this->assertDateIntervalEquals($interval, $reverseTransformer->reverseTransform($input));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,14 +112,14 @@ class DateIntervalToStringTransformerTest extends DateIntervalTestCase
|
|||||||
public function testReverseTransformExpectsString()
|
public function testReverseTransformExpectsString()
|
||||||
{
|
{
|
||||||
$reverseTransformer = new DateIntervalToStringTransformer();
|
$reverseTransformer = new DateIntervalToStringTransformer();
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(UnexpectedTypeException::class);
|
$this->expectException(UnexpectedTypeException::class);
|
||||||
$reverseTransformer->reverseTransform(1234);
|
$reverseTransformer->reverseTransform(1234);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testReverseTransformExpectsValidIntervalString()
|
public function testReverseTransformExpectsValidIntervalString()
|
||||||
{
|
{
|
||||||
$reverseTransformer = new DateIntervalToStringTransformer();
|
$reverseTransformer = new DateIntervalToStringTransformer();
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(TransformationFailedException::class);
|
$this->expectException(TransformationFailedException::class);
|
||||||
$reverseTransformer->reverseTransform('10Y');
|
$reverseTransformer->reverseTransform('10Y');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -192,7 +192,7 @@ class DateTimeToLocalizedStringTransformerTest extends TestCase
|
|||||||
|
|
||||||
// HOW TO REPRODUCE?
|
// HOW TO REPRODUCE?
|
||||||
|
|
||||||
//$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Extension\Core\DataTransformer\TransformationFailedException');
|
//$this->expectException('Symfony\Component\Form\Extension\Core\DataTransformer\TransformationFailedException');
|
||||||
|
|
||||||
//$transformer->transform(1.5);
|
//$transformer->transform(1.5);
|
||||||
}
|
}
|
||||||
|
@ -12,10 +12,13 @@
|
|||||||
namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
|
namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer;
|
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer;
|
||||||
|
|
||||||
class DateTimeToStringTransformerTest extends TestCase
|
class DateTimeToStringTransformerTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
public function dataProvider()
|
public function dataProvider()
|
||||||
{
|
{
|
||||||
$data = [
|
$data = [
|
||||||
@ -111,7 +114,7 @@ class DateTimeToStringTransformerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$transformer = new DateTimeToStringTransformer();
|
$transformer = new DateTimeToStringTransformer();
|
||||||
|
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\TransformationFailedException');
|
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||||
|
|
||||||
$transformer->transform('1234');
|
$transformer->transform('1234');
|
||||||
}
|
}
|
||||||
@ -150,7 +153,7 @@ class DateTimeToStringTransformerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$reverseTransformer = new DateTimeToStringTransformer();
|
$reverseTransformer = new DateTimeToStringTransformer();
|
||||||
|
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\TransformationFailedException');
|
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||||
|
|
||||||
$reverseTransformer->reverseTransform(1234);
|
$reverseTransformer->reverseTransform(1234);
|
||||||
}
|
}
|
||||||
@ -159,7 +162,7 @@ class DateTimeToStringTransformerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$reverseTransformer = new DateTimeToStringTransformer();
|
$reverseTransformer = new DateTimeToStringTransformer();
|
||||||
|
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\TransformationFailedException');
|
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||||
|
|
||||||
$reverseTransformer->reverseTransform('2010-2010-2010');
|
$reverseTransformer->reverseTransform('2010-2010-2010');
|
||||||
}
|
}
|
||||||
@ -168,7 +171,7 @@ class DateTimeToStringTransformerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$reverseTransformer = new DateTimeToStringTransformer();
|
$reverseTransformer = new DateTimeToStringTransformer();
|
||||||
|
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\TransformationFailedException');
|
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||||
|
|
||||||
$reverseTransformer->reverseTransform('2010-04-31');
|
$reverseTransformer->reverseTransform('2010-04-31');
|
||||||
}
|
}
|
||||||
|
@ -12,10 +12,13 @@
|
|||||||
namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
|
namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToTimestampTransformer;
|
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToTimestampTransformer;
|
||||||
|
|
||||||
class DateTimeToTimestampTransformerTest extends TestCase
|
class DateTimeToTimestampTransformerTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
public function testTransform()
|
public function testTransform()
|
||||||
{
|
{
|
||||||
$transformer = new DateTimeToTimestampTransformer('UTC', 'UTC');
|
$transformer = new DateTimeToTimestampTransformer('UTC', 'UTC');
|
||||||
@ -72,7 +75,7 @@ class DateTimeToTimestampTransformerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$transformer = new DateTimeToTimestampTransformer();
|
$transformer = new DateTimeToTimestampTransformer();
|
||||||
|
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\TransformationFailedException');
|
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||||
|
|
||||||
$transformer->transform('1234');
|
$transformer->transform('1234');
|
||||||
}
|
}
|
||||||
@ -109,7 +112,7 @@ class DateTimeToTimestampTransformerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$reverseTransformer = new DateTimeToTimestampTransformer();
|
$reverseTransformer = new DateTimeToTimestampTransformer();
|
||||||
|
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\TransformationFailedException');
|
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||||
|
|
||||||
$reverseTransformer->reverseTransform('2010-2010-2010');
|
$reverseTransformer->reverseTransform('2010-2010-2010');
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ class MoneyToLocalizedStringTransformerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$transformer = new MoneyToLocalizedStringTransformer(null, null, null, 100);
|
$transformer = new MoneyToLocalizedStringTransformer(null, null, null, 100);
|
||||||
|
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\TransformationFailedException');
|
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||||
|
|
||||||
$transformer->transform('abcd');
|
$transformer->transform('abcd');
|
||||||
}
|
}
|
||||||
@ -76,7 +76,7 @@ class MoneyToLocalizedStringTransformerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$transformer = new MoneyToLocalizedStringTransformer(null, null, null, 100);
|
$transformer = new MoneyToLocalizedStringTransformer(null, null, null, 100);
|
||||||
|
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\TransformationFailedException');
|
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||||
|
|
||||||
$transformer->reverseTransform(12345);
|
$transformer->reverseTransform(12345);
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$transformer = new PercentToLocalizedStringTransformer();
|
$transformer = new PercentToLocalizedStringTransformer();
|
||||||
|
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\TransformationFailedException');
|
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||||
|
|
||||||
$transformer->transform('foo');
|
$transformer->transform('foo');
|
||||||
}
|
}
|
||||||
@ -124,7 +124,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$transformer = new PercentToLocalizedStringTransformer();
|
$transformer = new PercentToLocalizedStringTransformer();
|
||||||
|
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\TransformationFailedException');
|
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||||
|
|
||||||
$transformer->reverseTransform(1);
|
$transformer->reverseTransform(1);
|
||||||
}
|
}
|
||||||
|
@ -11,11 +11,14 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
|
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\Author;
|
||||||
use Symfony\Component\Form\Tests\Fixtures\AuthorType;
|
use Symfony\Component\Form\Tests\Fixtures\AuthorType;
|
||||||
|
|
||||||
class CollectionTypeTest extends BaseTypeTest
|
class CollectionTypeTest extends BaseTypeTest
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\CollectionType';
|
const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\CollectionType';
|
||||||
|
|
||||||
public function testContainsNoChildByDefault()
|
public function testContainsNoChildByDefault()
|
||||||
@ -61,7 +64,7 @@ class CollectionTypeTest extends BaseTypeTest
|
|||||||
$form = $this->factory->create(static::TESTED_TYPE, null, [
|
$form = $this->factory->create(static::TESTED_TYPE, null, [
|
||||||
'entry_type' => TextTypeTest::TESTED_TYPE,
|
'entry_type' => TextTypeTest::TESTED_TYPE,
|
||||||
]);
|
]);
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\UnexpectedTypeException');
|
$this->expectException('Symfony\Component\Form\Exception\UnexpectedTypeException');
|
||||||
$form->setData(new \stdClass());
|
$form->setData(new \stdClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,13 +52,13 @@ class FormBuilderTest extends TestCase
|
|||||||
|
|
||||||
public function testAddNameNoStringAndNoInteger()
|
public function testAddNameNoStringAndNoInteger()
|
||||||
{
|
{
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\UnexpectedTypeException');
|
$this->expectException('Symfony\Component\Form\Exception\UnexpectedTypeException');
|
||||||
$this->builder->add(true);
|
$this->builder->add(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAddTypeNoString()
|
public function testAddTypeNoString()
|
||||||
{
|
{
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\UnexpectedTypeException');
|
$this->expectException('Symfony\Component\Form\Exception\UnexpectedTypeException');
|
||||||
$this->builder->add('foo', 1234);
|
$this->builder->add('foo', 1234);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,12 +170,8 @@ class FormBuilderTest extends TestCase
|
|||||||
|
|
||||||
public function testGetUnknown()
|
public function testGetUnknown()
|
||||||
{
|
{
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException('Symfony\Component\Form\Exception\InvalidArgumentException');
|
$this->expectException('Symfony\Component\Form\Exception\InvalidArgumentException');
|
||||||
$this->expectExceptionMessage('The child with the name "foo" does not exist.');
|
$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->builder->get('foo');
|
$this->builder->get('foo');
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Component\Form\Tests;
|
namespace Symfony\Component\Form\Tests;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\Form\FormConfigBuilder;
|
use Symfony\Component\Form\FormConfigBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -19,6 +20,8 @@ use Symfony\Component\Form\FormConfigBuilder;
|
|||||||
*/
|
*/
|
||||||
class FormConfigTest extends TestCase
|
class FormConfigTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
public function getHtml4Ids()
|
public function getHtml4Ids()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
@ -72,10 +75,8 @@ class FormConfigTest extends TestCase
|
|||||||
{
|
{
|
||||||
$dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
|
$dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
|
||||||
|
|
||||||
if (null !== $expectedException && method_exists($this, 'expectException')) {
|
if (null !== $expectedException) {
|
||||||
$this->expectException($expectedException);
|
$this->expectException($expectedException);
|
||||||
} elseif (null !== $expectedException) {
|
|
||||||
$this->setExpectedException($expectedException);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$formConfigBuilder = new FormConfigBuilder($name, null, $dispatcher);
|
$formConfigBuilder = new FormConfigBuilder($name, null, $dispatcher);
|
||||||
|
@ -12,11 +12,14 @@
|
|||||||
namespace Symfony\Component\HttpFoundation\Tests\File;
|
namespace Symfony\Component\HttpFoundation\Tests\File;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\HttpFoundation\File\File;
|
use Symfony\Component\HttpFoundation\File\File;
|
||||||
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser;
|
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser;
|
||||||
|
|
||||||
class FileTest extends TestCase
|
class FileTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
protected $file;
|
protected $file;
|
||||||
|
|
||||||
public function testGetMimeTypeUsesMimeTypeGuessers()
|
public function testGetMimeTypeUsesMimeTypeGuessers()
|
||||||
@ -64,7 +67,7 @@ class FileTest extends TestCase
|
|||||||
|
|
||||||
public function testConstructWhenFileNotExists()
|
public function testConstructWhenFileNotExists()
|
||||||
{
|
{
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException');
|
$this->expectException('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException');
|
||||||
|
|
||||||
new File(__DIR__.'/Fixtures/not_here');
|
new File(__DIR__.'/Fixtures/not_here');
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ class MimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testGuessImageWithDirectory()
|
public function testGuessImageWithDirectory()
|
||||||
{
|
{
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException');
|
$this->expectException('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException');
|
||||||
|
|
||||||
MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/directory');
|
MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/directory');
|
||||||
}
|
}
|
||||||
@ -56,7 +56,7 @@ class MimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testGuessWithIncorrectPath()
|
public function testGuessWithIncorrectPath()
|
||||||
{
|
{
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException');
|
$this->expectException('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException');
|
||||||
MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/not_here');
|
MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/not_here');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ class MimeTypeTest extends TestCase
|
|||||||
@chmod($path, 0333);
|
@chmod($path, 0333);
|
||||||
|
|
||||||
if ('0333' == substr(sprintf('%o', fileperms($path)), -4)) {
|
if ('0333' == substr(sprintf('%o', fileperms($path)), -4)) {
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException');
|
$this->expectException('Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException');
|
||||||
MimeTypeGuesser::getInstance()->guess($path);
|
MimeTypeGuesser::getInstance()->guess($path);
|
||||||
} else {
|
} else {
|
||||||
$this->markTestSkipped('Can not verify chmod operations, change of file permissions failed');
|
$this->markTestSkipped('Can not verify chmod operations, change of file permissions failed');
|
||||||
|
@ -28,7 +28,7 @@ class UploadedFileTest extends TestCase
|
|||||||
|
|
||||||
public function testConstructWhenFileNotExists()
|
public function testConstructWhenFileNotExists()
|
||||||
{
|
{
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException');
|
$this->expectException('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException');
|
||||||
|
|
||||||
new UploadedFile(
|
new UploadedFile(
|
||||||
__DIR__.'/Fixtures/not_here',
|
__DIR__.'/Fixtures/not_here',
|
||||||
|
@ -2121,12 +2121,8 @@ class RequestTest extends TestCase
|
|||||||
$this->assertSame($expectedPort, $request->getPort());
|
$this->assertSame($expectedPort, $request->getPort());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException(SuspiciousOperationException::class);
|
$this->expectException(SuspiciousOperationException::class);
|
||||||
$this->expectExceptionMessage('Invalid Host');
|
$this->expectExceptionMessage('Invalid Host');
|
||||||
} else {
|
|
||||||
$this->setExpectedException(SuspiciousOperationException::class, 'Invalid Host');
|
|
||||||
}
|
|
||||||
|
|
||||||
$request->getHost();
|
$request->getHost();
|
||||||
}
|
}
|
||||||
|
@ -12,10 +12,13 @@
|
|||||||
namespace Symfony\Component\HttpKernel\Tests\Config;
|
namespace Symfony\Component\HttpKernel\Tests\Config;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\HttpKernel\Config\FileLocator;
|
use Symfony\Component\HttpKernel\Config\FileLocator;
|
||||||
|
|
||||||
class FileLocatorTest extends TestCase
|
class FileLocatorTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
public function testLocate()
|
public function testLocate()
|
||||||
{
|
{
|
||||||
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
|
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
|
||||||
@ -30,7 +33,7 @@ class FileLocatorTest extends TestCase
|
|||||||
$kernel
|
$kernel
|
||||||
->expects($this->never())
|
->expects($this->never())
|
||||||
->method('locateResource');
|
->method('locateResource');
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('LogicException');
|
$this->expectException('LogicException');
|
||||||
$locator->locate('/some/path');
|
$locator->locate('/some/path');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ namespace Symfony\Component\HttpKernel\Tests\Controller;
|
|||||||
|
|
||||||
use Psr\Container\ContainerInterface;
|
use Psr\Container\ContainerInterface;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\Debug\ErrorHandler;
|
use Symfony\Component\Debug\ErrorHandler;
|
||||||
use Symfony\Component\DependencyInjection\Container;
|
use Symfony\Component\DependencyInjection\Container;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
@ -20,6 +21,8 @@ use Symfony\Component\HttpKernel\Controller\ContainerControllerResolver;
|
|||||||
|
|
||||||
class ContainerControllerResolverTest extends ControllerResolverTest
|
class ContainerControllerResolverTest extends ControllerResolverTest
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
public function testGetControllerService()
|
public function testGetControllerService()
|
||||||
{
|
{
|
||||||
$container = $this->createMockContainer();
|
$container = $this->createMockContainer();
|
||||||
@ -237,12 +240,8 @@ class ContainerControllerResolverTest extends ControllerResolverTest
|
|||||||
{
|
{
|
||||||
// All this logic needs to be duplicated, since calling parent::testGetControllerOnNonUndefinedFunction will override the expected excetion and not use the regex
|
// All this logic needs to be duplicated, since calling parent::testGetControllerOnNonUndefinedFunction will override the expected excetion and not use the regex
|
||||||
$resolver = $this->createControllerResolver();
|
$resolver = $this->createControllerResolver();
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException($exceptionName);
|
$this->expectException($exceptionName);
|
||||||
$this->expectExceptionMessageRegExp($exceptionMessage);
|
$this->expectExceptionMessageRegExp($exceptionMessage);
|
||||||
} else {
|
|
||||||
$this->setExpectedExceptionRegExp($exceptionName, $exceptionMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
$request = Request::create('/');
|
$request = Request::create('/');
|
||||||
$request->attributes->set('_controller', $controller);
|
$request->attributes->set('_controller', $controller);
|
||||||
|
@ -13,6 +13,7 @@ namespace Symfony\Component\HttpKernel\Tests\Controller;
|
|||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpKernel\Controller\ControllerResolver;
|
use Symfony\Component\HttpKernel\Controller\ControllerResolver;
|
||||||
use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\NullableController;
|
use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\NullableController;
|
||||||
@ -20,6 +21,8 @@ use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\VariadicController;
|
|||||||
|
|
||||||
class ControllerResolverTest extends TestCase
|
class ControllerResolverTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
public function testGetControllerWithoutControllerParameter()
|
public function testGetControllerWithoutControllerParameter()
|
||||||
{
|
{
|
||||||
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
|
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
|
||||||
@ -118,12 +121,8 @@ class ControllerResolverTest extends TestCase
|
|||||||
public function testGetControllerOnNonUndefinedFunction($controller, $exceptionName = null, $exceptionMessage = null)
|
public function testGetControllerOnNonUndefinedFunction($controller, $exceptionName = null, $exceptionMessage = null)
|
||||||
{
|
{
|
||||||
$resolver = $this->createControllerResolver();
|
$resolver = $this->createControllerResolver();
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException($exceptionName);
|
$this->expectException($exceptionName);
|
||||||
$this->expectExceptionMessage($exceptionMessage);
|
$this->expectExceptionMessage($exceptionMessage);
|
||||||
} else {
|
|
||||||
$this->setExpectedException($exceptionName, $exceptionMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
$request = Request::create('/');
|
$request = Request::create('/');
|
||||||
$request->attributes->set('_controller', $controller);
|
$request->attributes->set('_controller', $controller);
|
||||||
|
@ -332,7 +332,7 @@ abstract class AbstractNumberFormatterTest extends TestCase
|
|||||||
$exceptionCode = 'PHPUnit_Framework_Error_Warning';
|
$exceptionCode = 'PHPUnit_Framework_Error_Warning';
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}($exceptionCode);
|
$this->expectException($exceptionCode);
|
||||||
|
|
||||||
$formatter->format($value, NumberFormatter::TYPE_CURRENCY);
|
$formatter->format($value, NumberFormatter::TYPE_CURRENCY);
|
||||||
}
|
}
|
||||||
@ -715,7 +715,7 @@ abstract class AbstractNumberFormatterTest extends TestCase
|
|||||||
$exceptionCode = 'PHPUnit_Framework_Error_Warning';
|
$exceptionCode = 'PHPUnit_Framework_Error_Warning';
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}($exceptionCode);
|
$this->expectException($exceptionCode);
|
||||||
|
|
||||||
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
||||||
$formatter->parse('1', NumberFormatter::TYPE_DEFAULT);
|
$formatter->parse('1', NumberFormatter::TYPE_DEFAULT);
|
||||||
@ -841,7 +841,7 @@ abstract class AbstractNumberFormatterTest extends TestCase
|
|||||||
$exceptionCode = 'PHPUnit_Framework_Error_Warning';
|
$exceptionCode = 'PHPUnit_Framework_Error_Warning';
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}($exceptionCode);
|
$this->expectException($exceptionCode);
|
||||||
|
|
||||||
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
||||||
$formatter->parse('1', NumberFormatter::TYPE_CURRENCY);
|
$formatter->parse('1', NumberFormatter::TYPE_CURRENCY);
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Component\Intl\Tests\Util;
|
namespace Symfony\Component\Intl\Tests\Util;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\Filesystem\Filesystem;
|
use Symfony\Component\Filesystem\Filesystem;
|
||||||
use Symfony\Component\Intl\Exception\RuntimeException;
|
use Symfony\Component\Intl\Exception\RuntimeException;
|
||||||
use Symfony\Component\Intl\Util\GitRepository;
|
use Symfony\Component\Intl\Util\GitRepository;
|
||||||
@ -21,6 +22,8 @@ use Symfony\Component\Intl\Util\GitRepository;
|
|||||||
*/
|
*/
|
||||||
class GitRepositoryTest extends TestCase
|
class GitRepositoryTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
private $targetDir;
|
private $targetDir;
|
||||||
|
|
||||||
const REPO_URL = 'https://github.com/symfony/intl.git';
|
const REPO_URL = 'https://github.com/symfony/intl.git';
|
||||||
@ -39,11 +42,7 @@ class GitRepositoryTest extends TestCase
|
|||||||
|
|
||||||
public function testItThrowsAnExceptionIfInitialisedWithNonGitDirectory()
|
public function testItThrowsAnExceptionIfInitialisedWithNonGitDirectory()
|
||||||
{
|
{
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException(RuntimeException::class);
|
$this->expectException(RuntimeException::class);
|
||||||
} else {
|
|
||||||
$this->setExpectedException(RuntimeException::class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@mkdir($this->targetDir, 0777, true);
|
@mkdir($this->targetDir, 0777, true);
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Ldap\Tests;
|
namespace Symfony\Component\Ldap\Tests;
|
||||||
|
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\Ldap\Adapter\ExtLdap\Adapter;
|
use Symfony\Component\Ldap\Adapter\ExtLdap\Adapter;
|
||||||
use Symfony\Component\Ldap\Adapter\ExtLdap\Collection;
|
use Symfony\Component\Ldap\Adapter\ExtLdap\Collection;
|
||||||
use Symfony\Component\Ldap\Adapter\ExtLdap\Query;
|
use Symfony\Component\Ldap\Adapter\ExtLdap\Query;
|
||||||
@ -23,6 +24,8 @@ use Symfony\Component\Ldap\LdapInterface;
|
|||||||
*/
|
*/
|
||||||
class AdapterTest extends LdapTestCase
|
class AdapterTest extends LdapTestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
public function testLdapEscape()
|
public function testLdapEscape()
|
||||||
{
|
{
|
||||||
$ldap = new Adapter();
|
$ldap = new Adapter();
|
||||||
@ -74,7 +77,7 @@ class AdapterTest extends LdapTestCase
|
|||||||
public function testLdapQueryWithoutBind()
|
public function testLdapQueryWithoutBind()
|
||||||
{
|
{
|
||||||
$ldap = new Adapter($this->getLdapConfig());
|
$ldap = new Adapter($this->getLdapConfig());
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(NotBoundException::class);
|
$this->expectException(NotBoundException::class);
|
||||||
$query = $ldap->createQuery('dc=symfony,dc=com', '(&(objectclass=person)(ou=Maintainers))', []);
|
$query = $ldap->createQuery('dc=symfony,dc=com', '(&(objectclass=person)(ou=Maintainers))', []);
|
||||||
$query->execute();
|
$query->execute();
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ class LdapManagerTest extends LdapTestCase
|
|||||||
*/
|
*/
|
||||||
public function testLdapAddInvalidEntry()
|
public function testLdapAddInvalidEntry()
|
||||||
{
|
{
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(LdapException::class);
|
$this->expectException(LdapException::class);
|
||||||
$this->executeSearchQuery(1);
|
$this->executeSearchQuery(1);
|
||||||
|
|
||||||
// The entry is missing a subject name
|
// The entry is missing a subject name
|
||||||
@ -108,7 +108,7 @@ class LdapManagerTest extends LdapTestCase
|
|||||||
public function testLdapUnboundAdd()
|
public function testLdapUnboundAdd()
|
||||||
{
|
{
|
||||||
$this->adapter = new Adapter($this->getLdapConfig());
|
$this->adapter = new Adapter($this->getLdapConfig());
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(NotBoundException::class);
|
$this->expectException(NotBoundException::class);
|
||||||
$em = $this->adapter->getEntryManager();
|
$em = $this->adapter->getEntryManager();
|
||||||
$em->add(new Entry(''));
|
$em->add(new Entry(''));
|
||||||
}
|
}
|
||||||
@ -119,7 +119,7 @@ class LdapManagerTest extends LdapTestCase
|
|||||||
public function testLdapUnboundRemove()
|
public function testLdapUnboundRemove()
|
||||||
{
|
{
|
||||||
$this->adapter = new Adapter($this->getLdapConfig());
|
$this->adapter = new Adapter($this->getLdapConfig());
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(NotBoundException::class);
|
$this->expectException(NotBoundException::class);
|
||||||
$em = $this->adapter->getEntryManager();
|
$em = $this->adapter->getEntryManager();
|
||||||
$em->remove(new Entry(''));
|
$em->remove(new Entry(''));
|
||||||
}
|
}
|
||||||
@ -130,7 +130,7 @@ class LdapManagerTest extends LdapTestCase
|
|||||||
public function testLdapUnboundUpdate()
|
public function testLdapUnboundUpdate()
|
||||||
{
|
{
|
||||||
$this->adapter = new Adapter($this->getLdapConfig());
|
$this->adapter = new Adapter($this->getLdapConfig());
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(NotBoundException::class);
|
$this->expectException(NotBoundException::class);
|
||||||
$em = $this->adapter->getEntryManager();
|
$em = $this->adapter->getEntryManager();
|
||||||
$em->update(new Entry(''));
|
$em->update(new Entry(''));
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ class LdapTest extends TestCase
|
|||||||
|
|
||||||
public function testCreateWithInvalidAdapterName()
|
public function testCreateWithInvalidAdapterName()
|
||||||
{
|
{
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(DriverNotFoundException::class);
|
$this->expectException(DriverNotFoundException::class);
|
||||||
Ldap::create('foo');
|
Ldap::create('foo');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -549,12 +549,8 @@ class OptionsResolverTest extends TestCase
|
|||||||
$this->resolver->setDefined('option');
|
$this->resolver->setDefined('option');
|
||||||
$this->resolver->setAllowedTypes('option', $allowedType);
|
$this->resolver->setAllowedTypes('option', $allowedType);
|
||||||
|
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
|
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
|
||||||
$this->expectExceptionMessage($exceptionMessage);
|
$this->expectExceptionMessage($exceptionMessage);
|
||||||
} else {
|
|
||||||
$this->setExpectedException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException', $exceptionMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->resolver->resolve(['option' => $actualType]);
|
$this->resolver->resolve(['option' => $actualType]);
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Component\Process\Tests;
|
namespace Symfony\Component\Process\Tests;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\Process\Exception\ProcessFailedException;
|
use Symfony\Component\Process\Exception\ProcessFailedException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -19,6 +20,8 @@ use Symfony\Component\Process\Exception\ProcessFailedException;
|
|||||||
*/
|
*/
|
||||||
class ProcessFailedExceptionTest extends TestCase
|
class ProcessFailedExceptionTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* tests ProcessFailedException throws exception if the process was successful.
|
* tests ProcessFailedException throws exception if the process was successful.
|
||||||
*/
|
*/
|
||||||
@ -29,12 +32,8 @@ class ProcessFailedExceptionTest extends TestCase
|
|||||||
->method('isSuccessful')
|
->method('isSuccessful')
|
||||||
->willReturn(true);
|
->willReturn(true);
|
||||||
|
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException(\InvalidArgumentException::class);
|
$this->expectException(\InvalidArgumentException::class);
|
||||||
$this->expectExceptionMessage('Expected a failed process, but the given process was successful.');
|
$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.');
|
|
||||||
}
|
|
||||||
|
|
||||||
new ProcessFailedException($process);
|
new ProcessFailedException($process);
|
||||||
}
|
}
|
||||||
|
@ -960,12 +960,8 @@ class ProcessTest extends TestCase
|
|||||||
{
|
{
|
||||||
$process = $this->getProcess('foo');
|
$process = $this->getProcess('foo');
|
||||||
|
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException('Symfony\Component\Process\Exception\LogicException');
|
$this->expectException('Symfony\Component\Process\Exception\LogicException');
|
||||||
$this->expectExceptionMessage(sprintf('Process must be started before calling %s.', $method));
|
$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));
|
|
||||||
}
|
|
||||||
|
|
||||||
$process->{$method}();
|
$process->{$method}();
|
||||||
}
|
}
|
||||||
@ -1614,12 +1610,8 @@ EOTXT;
|
|||||||
if (!$expectException) {
|
if (!$expectException) {
|
||||||
$this->markTestSkipped('PHP is compiled with --enable-sigchild.');
|
$this->markTestSkipped('PHP is compiled with --enable-sigchild.');
|
||||||
} elseif (self::$notEnhancedSigchild) {
|
} elseif (self::$notEnhancedSigchild) {
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException('Symfony\Component\Process\Exception\RuntimeException');
|
$this->expectException('Symfony\Component\Process\Exception\RuntimeException');
|
||||||
$this->expectExceptionMessage('This PHP has been compiled with --enable-sigchild.');
|
$this->expectExceptionMessage('This PHP has been compiled with --enable-sigchild.');
|
||||||
} else {
|
|
||||||
$this->setExpectedException('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild.');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Component\Routing\Tests\Generator;
|
namespace Symfony\Component\Routing\Tests\Generator;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\Routing\Generator\UrlGenerator;
|
use Symfony\Component\Routing\Generator\UrlGenerator;
|
||||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||||
use Symfony\Component\Routing\RequestContext;
|
use Symfony\Component\Routing\RequestContext;
|
||||||
@ -20,6 +21,8 @@ use Symfony\Component\Routing\RouteCollection;
|
|||||||
|
|
||||||
class UrlGeneratorTest extends TestCase
|
class UrlGeneratorTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
public function testAbsoluteUrlWithPort80()
|
public function testAbsoluteUrlWithPort80()
|
||||||
{
|
{
|
||||||
$routes = $this->getRoutes('test', new Route('/testing'));
|
$routes = $this->getRoutes('test', new Route('/testing'));
|
||||||
@ -368,7 +371,7 @@ class UrlGeneratorTest extends TestCase
|
|||||||
|
|
||||||
// The default requirement for 'x' should not allow the separator '.' in this case because it would otherwise match everything
|
// The default requirement for 'x' should not allow the separator '.' in this case because it would otherwise match everything
|
||||||
// and following optional variables like _format could never match.
|
// and following optional variables like _format could never match.
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Routing\Exception\InvalidParameterException');
|
$this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException');
|
||||||
$generator->generate('test', ['x' => 'do.t', 'y' => '123', 'z' => 'bar', '_format' => 'xml']);
|
$generator->generate('test', ['x' => 'do.t', 'y' => '123', 'z' => 'bar', '_format' => 'xml']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ class UrlMatcherTest extends TestCase
|
|||||||
$matcher = $this->getUrlMatcher($collection);
|
$matcher = $this->getUrlMatcher($collection);
|
||||||
|
|
||||||
$this->assertEquals(['_route' => 'foo'], $matcher->match('/foo1'));
|
$this->assertEquals(['_route' => 'foo'], $matcher->match('/foo1'));
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Routing\Exception\ResourceNotFoundException');
|
$this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException');
|
||||||
$this->assertEquals([], $matcher->match('/foo'));
|
$this->assertEquals([], $matcher->match('/foo'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,7 +282,7 @@ class UrlMatcherTest extends TestCase
|
|||||||
// z and _format are optional.
|
// z and _format are optional.
|
||||||
$this->assertEquals(['w' => 'wwwww', 'x' => 'x', 'y' => 'y', 'z' => 'default-z', '_format' => 'html', '_route' => 'test'], $matcher->match('/wwwwwxy'));
|
$this->assertEquals(['w' => 'wwwww', 'x' => 'x', 'y' => 'y', 'z' => 'default-z', '_format' => 'html', '_route' => 'test'], $matcher->match('/wwwwwxy'));
|
||||||
|
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Routing\Exception\ResourceNotFoundException');
|
$this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException');
|
||||||
$matcher->match('/wxy.html');
|
$matcher->match('/wxy.html');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,7 +297,7 @@ class UrlMatcherTest extends TestCase
|
|||||||
|
|
||||||
// Usually the character in front of an optional parameter can be left out, e.g. with pattern '/get/{what}' just '/get' would match.
|
// Usually the character in front of an optional parameter can be left out, e.g. with pattern '/get/{what}' just '/get' would match.
|
||||||
// But here the 't' in 'get' is not a separating character, so it makes no sense to match without it.
|
// But here the 't' in 'get' is not a separating character, so it makes no sense to match without it.
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Routing\Exception\ResourceNotFoundException');
|
$this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException');
|
||||||
$matcher->match('/ge');
|
$matcher->match('/ge');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Component\Security\Core\Tests\Authorization;
|
namespace Symfony\Component\Security\Core\Tests\Authorization;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||||
use Symfony\Component\Security\Core\Authorization\AccessDecisionManager;
|
use Symfony\Component\Security\Core\Authorization\AccessDecisionManager;
|
||||||
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
|
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
|
||||||
@ -20,6 +21,8 @@ use Symfony\Component\Security\Core\Tests\Authorization\Stub\VoterWithoutInterfa
|
|||||||
|
|
||||||
class AccessDecisionManagerTest extends TestCase
|
class AccessDecisionManagerTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \InvalidArgumentException
|
* @expectedException \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
@ -147,12 +150,8 @@ class AccessDecisionManagerTest extends TestCase
|
|||||||
$exception = LogicException::class;
|
$exception = LogicException::class;
|
||||||
$message = sprintf('stdClass should implement the %s interface when used as voter.', VoterInterface::class);
|
$message = sprintf('stdClass should implement the %s interface when used as voter.', VoterInterface::class);
|
||||||
|
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException($exception);
|
$this->expectException($exception);
|
||||||
$this->expectExceptionMessage($message);
|
$this->expectExceptionMessage($message);
|
||||||
} else {
|
|
||||||
$this->setExpectedException($exception, $message);
|
|
||||||
}
|
|
||||||
|
|
||||||
$adm = new AccessDecisionManager([new \stdClass()]);
|
$adm = new AccessDecisionManager([new \stdClass()]);
|
||||||
$token = $this->getMockBuilder(TokenInterface::class)->getMock();
|
$token = $this->getMockBuilder(TokenInterface::class)->getMock();
|
||||||
|
@ -580,12 +580,8 @@ XML;
|
|||||||
|
|
||||||
public function testDecodeEmptyXml()
|
public function testDecodeEmptyXml()
|
||||||
{
|
{
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException');
|
$this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException');
|
||||||
$this->expectExceptionMessage('Invalid XML data, it can not be empty.');
|
$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->encoder->decode(' ', 'xml');
|
$this->encoder->decode(' ', 'xml');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ class PhpEngineTest extends TestCase
|
|||||||
$foo = new \Symfony\Component\Templating\Tests\Fixtures\SimpleHelper('foo');
|
$foo = new \Symfony\Component\Templating\Tests\Fixtures\SimpleHelper('foo');
|
||||||
$engine->set($foo);
|
$engine->set($foo);
|
||||||
|
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('\LogicException');
|
$this->expectException('\LogicException');
|
||||||
|
|
||||||
unset($engine['foo']);
|
unset($engine['foo']);
|
||||||
}
|
}
|
||||||
|
@ -12,11 +12,14 @@
|
|||||||
namespace Symfony\Component\Translation\Tests\Catalogue;
|
namespace Symfony\Component\Translation\Tests\Catalogue;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\Translation\MessageCatalogue;
|
use Symfony\Component\Translation\MessageCatalogue;
|
||||||
use Symfony\Component\Translation\MessageCatalogueInterface;
|
use Symfony\Component\Translation\MessageCatalogueInterface;
|
||||||
|
|
||||||
abstract class AbstractOperationTest extends TestCase
|
abstract class AbstractOperationTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
public function testGetEmptyDomains()
|
public function testGetEmptyDomains()
|
||||||
{
|
{
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
@ -41,7 +44,7 @@ abstract class AbstractOperationTest extends TestCase
|
|||||||
|
|
||||||
public function testGetMessagesFromUnknownDomain()
|
public function testGetMessagesFromUnknownDomain()
|
||||||
{
|
{
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('InvalidArgumentException');
|
$this->expectException('InvalidArgumentException');
|
||||||
$this->createOperation(
|
$this->createOperation(
|
||||||
new MessageCatalogue('en'),
|
new MessageCatalogue('en'),
|
||||||
new MessageCatalogue('en')
|
new MessageCatalogue('en')
|
||||||
|
@ -12,11 +12,14 @@
|
|||||||
namespace Symfony\Component\Translation\Tests\Loader;
|
namespace Symfony\Component\Translation\Tests\Loader;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\Config\Resource\FileResource;
|
use Symfony\Component\Config\Resource\FileResource;
|
||||||
use Symfony\Component\Translation\Loader\QtFileLoader;
|
use Symfony\Component\Translation\Loader\QtFileLoader;
|
||||||
|
|
||||||
class QtFileLoaderTest extends TestCase
|
class QtFileLoaderTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
public function testLoad()
|
public function testLoad()
|
||||||
{
|
{
|
||||||
$loader = new QtFileLoader();
|
$loader = new QtFileLoader();
|
||||||
@ -63,12 +66,8 @@ class QtFileLoaderTest extends TestCase
|
|||||||
$loader = new QtFileLoader();
|
$loader = new QtFileLoader();
|
||||||
$resource = __DIR__.'/../fixtures/empty.xlf';
|
$resource = __DIR__.'/../fixtures/empty.xlf';
|
||||||
|
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException');
|
$this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException');
|
||||||
$this->expectExceptionMessage(sprintf('Unable to load "%s".', $resource));
|
$this->expectExceptionMessage(sprintf('Unable to load "%s".', $resource));
|
||||||
} else {
|
|
||||||
$this->setExpectedException('Symfony\Component\Translation\Exception\InvalidResourceException', sprintf('Unable to load "%s".', $resource));
|
|
||||||
}
|
|
||||||
|
|
||||||
$loader->load($resource, 'en', 'domain1');
|
$loader->load($resource, 'en', 'domain1');
|
||||||
}
|
}
|
||||||
|
@ -12,11 +12,14 @@
|
|||||||
namespace Symfony\Component\Translation\Tests\Loader;
|
namespace Symfony\Component\Translation\Tests\Loader;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\Config\Resource\FileResource;
|
use Symfony\Component\Config\Resource\FileResource;
|
||||||
use Symfony\Component\Translation\Loader\XliffFileLoader;
|
use Symfony\Component\Translation\Loader\XliffFileLoader;
|
||||||
|
|
||||||
class XliffFileLoaderTest extends TestCase
|
class XliffFileLoaderTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
public function testLoad()
|
public function testLoad()
|
||||||
{
|
{
|
||||||
$loader = new XliffFileLoader();
|
$loader = new XliffFileLoader();
|
||||||
@ -149,12 +152,8 @@ class XliffFileLoaderTest extends TestCase
|
|||||||
$loader = new XliffFileLoader();
|
$loader = new XliffFileLoader();
|
||||||
$resource = __DIR__.'/../fixtures/empty.xlf';
|
$resource = __DIR__.'/../fixtures/empty.xlf';
|
||||||
|
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException');
|
$this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException');
|
||||||
$this->expectExceptionMessage(sprintf('Unable to load "%s":', $resource));
|
$this->expectExceptionMessage(sprintf('Unable to load "%s":', $resource));
|
||||||
} else {
|
|
||||||
$this->setExpectedException('Symfony\Component\Translation\Exception\InvalidResourceException', sprintf('Unable to load "%s":', $resource));
|
|
||||||
}
|
|
||||||
|
|
||||||
$loader->load($resource, 'en', 'domain1');
|
$loader->load($resource, 'en', 'domain1');
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Component\Validator\Tests;
|
namespace Symfony\Component\Validator\Tests;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\Validator\Constraint;
|
use Symfony\Component\Validator\Constraint;
|
||||||
use Symfony\Component\Validator\Tests\Fixtures\ClassConstraint;
|
use Symfony\Component\Validator\Tests\Fixtures\ClassConstraint;
|
||||||
use Symfony\Component\Validator\Tests\Fixtures\ConstraintA;
|
use Symfony\Component\Validator\Tests\Fixtures\ConstraintA;
|
||||||
@ -22,6 +23,8 @@ use Symfony\Component\Validator\Tests\Fixtures\ConstraintWithValueAsDefault;
|
|||||||
|
|
||||||
class ConstraintTest extends TestCase
|
class ConstraintTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
public function testSetProperties()
|
public function testSetProperties()
|
||||||
{
|
{
|
||||||
$constraint = new ConstraintA([
|
$constraint = new ConstraintA([
|
||||||
@ -35,7 +38,7 @@ class ConstraintTest extends TestCase
|
|||||||
|
|
||||||
public function testSetNotExistingPropertyThrowsException()
|
public function testSetNotExistingPropertyThrowsException()
|
||||||
{
|
{
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Validator\Exception\InvalidOptionsException');
|
$this->expectException('Symfony\Component\Validator\Exception\InvalidOptionsException');
|
||||||
|
|
||||||
new ConstraintA([
|
new ConstraintA([
|
||||||
'foo' => 'bar',
|
'foo' => 'bar',
|
||||||
@ -46,14 +49,14 @@ class ConstraintTest extends TestCase
|
|||||||
{
|
{
|
||||||
$constraint = new ConstraintA();
|
$constraint = new ConstraintA();
|
||||||
|
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Validator\Exception\InvalidOptionsException');
|
$this->expectException('Symfony\Component\Validator\Exception\InvalidOptionsException');
|
||||||
|
|
||||||
$constraint->foo = 'bar';
|
$constraint->foo = 'bar';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testInvalidAndRequiredOptionsPassed()
|
public function testInvalidAndRequiredOptionsPassed()
|
||||||
{
|
{
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Validator\Exception\InvalidOptionsException');
|
$this->expectException('Symfony\Component\Validator\Exception\InvalidOptionsException');
|
||||||
|
|
||||||
new ConstraintC([
|
new ConstraintC([
|
||||||
'option1' => 'default',
|
'option1' => 'default',
|
||||||
@ -101,14 +104,14 @@ class ConstraintTest extends TestCase
|
|||||||
|
|
||||||
public function testSetUndefinedDefaultProperty()
|
public function testSetUndefinedDefaultProperty()
|
||||||
{
|
{
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
|
$this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
|
||||||
|
|
||||||
new ConstraintB('foo');
|
new ConstraintB('foo');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRequiredOptionsMustBeDefined()
|
public function testRequiredOptionsMustBeDefined()
|
||||||
{
|
{
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Validator\Exception\MissingOptionsException');
|
$this->expectException('Symfony\Component\Validator\Exception\MissingOptionsException');
|
||||||
|
|
||||||
new ConstraintC();
|
new ConstraintC();
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Validator\Tests\Constraints;
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\Intl\Util\IntlTestHelper;
|
use Symfony\Component\Intl\Util\IntlTestHelper;
|
||||||
use Symfony\Component\Validator\Constraint;
|
use Symfony\Component\Validator\Constraint;
|
||||||
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
|
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
|
||||||
@ -41,6 +42,8 @@ class ComparisonTest_Class
|
|||||||
*/
|
*/
|
||||||
abstract class AbstractComparisonValidatorTestCase extends ConstraintValidatorTestCase
|
abstract class AbstractComparisonValidatorTestCase extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
protected static function addPhp5Dot5Comparisons(array $comparisons)
|
protected static function addPhp5Dot5Comparisons(array $comparisons)
|
||||||
{
|
{
|
||||||
$result = $comparisons;
|
$result = $comparisons;
|
||||||
@ -163,12 +166,8 @@ abstract class AbstractComparisonValidatorTestCase extends ConstraintValidatorTe
|
|||||||
{
|
{
|
||||||
$constraint = $this->createConstraint(['propertyPath' => 'foo']);
|
$constraint = $this->createConstraint(['propertyPath' => 'foo']);
|
||||||
|
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException(ConstraintDefinitionException::class);
|
$this->expectException(ConstraintDefinitionException::class);
|
||||||
$this->expectExceptionMessage(sprintf('Invalid property path "foo" provided to "%s" constraint', \get_class($constraint)));
|
$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)));
|
|
||||||
}
|
|
||||||
|
|
||||||
$object = new ComparisonTest_Class(5);
|
$object = new ComparisonTest_Class(5);
|
||||||
|
|
||||||
|
@ -43,14 +43,14 @@ class ClassMetadataTest extends TestCase
|
|||||||
|
|
||||||
public function testAddConstraintDoesNotAcceptValid()
|
public function testAddConstraintDoesNotAcceptValid()
|
||||||
{
|
{
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
|
$this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
|
||||||
|
|
||||||
$this->metadata->addConstraint(new Valid());
|
$this->metadata->addConstraint(new Valid());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAddConstraintRequiresClassConstraints()
|
public function testAddConstraintRequiresClassConstraints()
|
||||||
{
|
{
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
|
$this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
|
||||||
|
|
||||||
$this->metadata->addConstraint(new PropertyConstraint());
|
$this->metadata->addConstraint(new PropertyConstraint());
|
||||||
}
|
}
|
||||||
|
@ -12,16 +12,19 @@
|
|||||||
namespace Symfony\Component\Validator\Tests\Mapping;
|
namespace Symfony\Component\Validator\Tests\Mapping;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\Validator\Mapping\GetterMetadata;
|
use Symfony\Component\Validator\Mapping\GetterMetadata;
|
||||||
use Symfony\Component\Validator\Tests\Fixtures\Entity;
|
use Symfony\Component\Validator\Tests\Fixtures\Entity;
|
||||||
|
|
||||||
class GetterMetadataTest extends TestCase
|
class GetterMetadataTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
const CLASSNAME = 'Symfony\Component\Validator\Tests\Fixtures\Entity';
|
const CLASSNAME = 'Symfony\Component\Validator\Tests\Fixtures\Entity';
|
||||||
|
|
||||||
public function testInvalidPropertyName()
|
public function testInvalidPropertyName()
|
||||||
{
|
{
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Validator\Exception\ValidatorException');
|
$this->expectException('Symfony\Component\Validator\Exception\ValidatorException');
|
||||||
|
|
||||||
new GetterMetadata(self::CLASSNAME, 'foobar');
|
new GetterMetadata(self::CLASSNAME, 'foobar');
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Component\Validator\Tests\Mapping\Loader;
|
namespace Symfony\Component\Validator\Tests\Mapping\Loader;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\Validator\Constraints\All;
|
use Symfony\Component\Validator\Constraints\All;
|
||||||
use Symfony\Component\Validator\Constraints\Callback;
|
use Symfony\Component\Validator\Constraints\Callback;
|
||||||
use Symfony\Component\Validator\Constraints\Choice;
|
use Symfony\Component\Validator\Constraints\Choice;
|
||||||
@ -29,6 +30,8 @@ use Symfony\Component\Validator\Tests\Fixtures\ConstraintB;
|
|||||||
|
|
||||||
class XmlFileLoaderTest extends TestCase
|
class XmlFileLoaderTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
public function testLoadClassMetadataReturnsTrueIfSuccessful()
|
public function testLoadClassMetadataReturnsTrueIfSuccessful()
|
||||||
{
|
{
|
||||||
$loader = new XmlFileLoader(__DIR__.'/constraint-mapping.xml');
|
$loader = new XmlFileLoader(__DIR__.'/constraint-mapping.xml');
|
||||||
@ -114,7 +117,7 @@ class XmlFileLoaderTest extends TestCase
|
|||||||
$loader = new XmlFileLoader(__DIR__.'/withdoctype.xml');
|
$loader = new XmlFileLoader(__DIR__.'/withdoctype.xml');
|
||||||
$metadata = new ClassMetadata('Symfony\Component\Validator\Tests\Fixtures\Entity');
|
$metadata = new ClassMetadata('Symfony\Component\Validator\Tests\Fixtures\Entity');
|
||||||
|
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('\Symfony\Component\Validator\Exception\MappingException');
|
$this->expectException('\Symfony\Component\Validator\Exception\MappingException');
|
||||||
$loader->loadClassMetadata($metadata);
|
$loader->loadClassMetadata($metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,7 +132,7 @@ class XmlFileLoaderTest extends TestCase
|
|||||||
try {
|
try {
|
||||||
$loader->loadClassMetadata($metadata);
|
$loader->loadClassMetadata($metadata);
|
||||||
} catch (MappingException $e) {
|
} catch (MappingException $e) {
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('\Symfony\Component\Validator\Exception\MappingException');
|
$this->expectException('\Symfony\Component\Validator\Exception\MappingException');
|
||||||
$loader->loadClassMetadata($metadata);
|
$loader->loadClassMetadata($metadata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Component\Validator\Tests\Mapping\Loader;
|
namespace Symfony\Component\Validator\Tests\Mapping\Loader;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\Validator\Constraints\All;
|
use Symfony\Component\Validator\Constraints\All;
|
||||||
use Symfony\Component\Validator\Constraints\Callback;
|
use Symfony\Component\Validator\Constraints\Callback;
|
||||||
use Symfony\Component\Validator\Constraints\Choice;
|
use Symfony\Component\Validator\Constraints\Choice;
|
||||||
@ -26,6 +27,8 @@ use Symfony\Component\Validator\Tests\Fixtures\ConstraintB;
|
|||||||
|
|
||||||
class YamlFileLoaderTest extends TestCase
|
class YamlFileLoaderTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
public function testLoadClassMetadataReturnsFalseIfEmpty()
|
public function testLoadClassMetadataReturnsFalseIfEmpty()
|
||||||
{
|
{
|
||||||
$loader = new YamlFileLoader(__DIR__.'/empty-mapping.yml');
|
$loader = new YamlFileLoader(__DIR__.'/empty-mapping.yml');
|
||||||
@ -69,7 +72,7 @@ class YamlFileLoaderTest extends TestCase
|
|||||||
$loader->loadClassMetadata($metadata);
|
$loader->loadClassMetadata($metadata);
|
||||||
} catch (\InvalidArgumentException $e) {
|
} catch (\InvalidArgumentException $e) {
|
||||||
// Call again. Again an exception should be thrown
|
// Call again. Again an exception should be thrown
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('\InvalidArgumentException');
|
$this->expectException('\InvalidArgumentException');
|
||||||
$loader->loadClassMetadata($metadata);
|
$loader->loadClassMetadata($metadata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ class MemberMetadataTest extends TestCase
|
|||||||
|
|
||||||
public function testAddConstraintRequiresClassConstraints()
|
public function testAddConstraintRequiresClassConstraints()
|
||||||
{
|
{
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
|
$this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
|
||||||
|
|
||||||
$this->metadata->addConstraint(new ClassConstraint());
|
$this->metadata->addConstraint(new ClassConstraint());
|
||||||
}
|
}
|
||||||
|
@ -12,17 +12,20 @@
|
|||||||
namespace Symfony\Component\Validator\Tests\Mapping;
|
namespace Symfony\Component\Validator\Tests\Mapping;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
|
||||||
use Symfony\Component\Validator\Mapping\PropertyMetadata;
|
use Symfony\Component\Validator\Mapping\PropertyMetadata;
|
||||||
use Symfony\Component\Validator\Tests\Fixtures\Entity;
|
use Symfony\Component\Validator\Tests\Fixtures\Entity;
|
||||||
|
|
||||||
class PropertyMetadataTest extends TestCase
|
class PropertyMetadataTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use ForwardCompatTestTrait;
|
||||||
|
|
||||||
const CLASSNAME = 'Symfony\Component\Validator\Tests\Fixtures\Entity';
|
const CLASSNAME = 'Symfony\Component\Validator\Tests\Fixtures\Entity';
|
||||||
const PARENTCLASS = 'Symfony\Component\Validator\Tests\Fixtures\EntityParent';
|
const PARENTCLASS = 'Symfony\Component\Validator\Tests\Fixtures\EntityParent';
|
||||||
|
|
||||||
public function testInvalidPropertyName()
|
public function testInvalidPropertyName()
|
||||||
{
|
{
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Validator\Exception\ValidatorException');
|
$this->expectException('Symfony\Component\Validator\Exception\ValidatorException');
|
||||||
|
|
||||||
new PropertyMetadata(self::CLASSNAME, 'foobar');
|
new PropertyMetadata(self::CLASSNAME, 'foobar');
|
||||||
}
|
}
|
||||||
@ -50,7 +53,7 @@ class PropertyMetadataTest extends TestCase
|
|||||||
$metadata = new PropertyMetadata(self::CLASSNAME, 'internal');
|
$metadata = new PropertyMetadata(self::CLASSNAME, 'internal');
|
||||||
$metadata->name = 'test';
|
$metadata->name = 'test';
|
||||||
|
|
||||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Validator\Exception\ValidatorException');
|
$this->expectException('Symfony\Component\Validator\Exception\ValidatorException');
|
||||||
$metadata->getPropertyValue($entity);
|
$metadata->getPropertyValue($entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -307,12 +307,8 @@ class InlineTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testParseUnquotedScalarStartingWithReservedIndicator($indicator)
|
public function testParseUnquotedScalarStartingWithReservedIndicator($indicator)
|
||||||
{
|
{
|
||||||
if (method_exists($this, 'expectExceptionMessage')) {
|
|
||||||
$this->expectException(ParseException::class);
|
$this->expectException(ParseException::class);
|
||||||
$this->expectExceptionMessage(sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo ").', $indicator));
|
$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));
|
|
||||||
}
|
|
||||||
|
|
||||||
Inline::parse(sprintf('{ foo: %sfoo }', $indicator));
|
Inline::parse(sprintf('{ foo: %sfoo }', $indicator));
|
||||||
}
|
}
|
||||||
@ -327,12 +323,8 @@ class InlineTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testParseUnquotedScalarStartingWithScalarIndicator($indicator)
|
public function testParseUnquotedScalarStartingWithScalarIndicator($indicator)
|
||||||
{
|
{
|
||||||
if (method_exists($this, 'expectExceptionMessage')) {
|
|
||||||
$this->expectException(ParseException::class);
|
$this->expectException(ParseException::class);
|
||||||
$this->expectExceptionMessage(sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo ").', $indicator));
|
$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));
|
|
||||||
}
|
|
||||||
|
|
||||||
Inline::parse(sprintf('{ foo: %sfoo }', $indicator));
|
Inline::parse(sprintf('{ foo: %sfoo }', $indicator));
|
||||||
}
|
}
|
||||||
@ -700,11 +692,7 @@ class InlineTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testParseInvalidBinaryData($data, $expectedMessage)
|
public function testParseInvalidBinaryData($data, $expectedMessage)
|
||||||
{
|
{
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectExceptionMessageRegExp($expectedMessage);
|
$this->expectExceptionMessageRegExp($expectedMessage);
|
||||||
} else {
|
|
||||||
$this->setExpectedExceptionRegExp(ParseException::class, $expectedMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
Inline::parse($data);
|
Inline::parse($data);
|
||||||
}
|
}
|
||||||
|
@ -1488,11 +1488,7 @@ EOT
|
|||||||
*/
|
*/
|
||||||
public function testParseInvalidBinaryData($data, $expectedMessage)
|
public function testParseInvalidBinaryData($data, $expectedMessage)
|
||||||
{
|
{
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectExceptionMessageRegExp($expectedMessage);
|
$this->expectExceptionMessageRegExp($expectedMessage);
|
||||||
} else {
|
|
||||||
$this->setExpectedExceptionRegExp(ParseException::class, $expectedMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->parser->parse($data);
|
$this->parser->parse($data);
|
||||||
}
|
}
|
||||||
@ -1559,12 +1555,8 @@ EOT;
|
|||||||
*/
|
*/
|
||||||
public function testParserThrowsExceptionWithCorrectLineNumber($lineNumber, $yaml)
|
public function testParserThrowsExceptionWithCorrectLineNumber($lineNumber, $yaml)
|
||||||
{
|
{
|
||||||
if (method_exists($this, 'expectException')) {
|
|
||||||
$this->expectException('\Symfony\Component\Yaml\Exception\ParseException');
|
$this->expectException('\Symfony\Component\Yaml\Exception\ParseException');
|
||||||
$this->expectExceptionMessage(sprintf('Unexpected characters near "," at line %d (near "bar: "123",").', $lineNumber));
|
$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->parser->parse($yaml);
|
$this->parser->parse($yaml);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user