Further refactorings to PHPUnit namespaces
This commit is contained in:
parent
347f529206
commit
de8106fea6
@ -105,7 +105,7 @@ 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->setExpectedException(
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(
|
||||||
'InvalidArgumentException',
|
'InvalidArgumentException',
|
||||||
'You cannot refresh a user from the EntityUserProvider that does not contain an identifier. The user object has to be serialized with its own identifier mapped by Doctrine'
|
'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'
|
||||||
);
|
);
|
||||||
@ -125,7 +125,7 @@ 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->setExpectedException(
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(
|
||||||
'Symfony\Component\Security\Core\Exception\UsernameNotFoundException',
|
'Symfony\Component\Security\Core\Exception\UsernameNotFoundException',
|
||||||
'User with id {"id1":1,"id2":2} not found'
|
'User with id {"id1":1,"id2":2} not found'
|
||||||
);
|
);
|
||||||
|
@ -46,7 +46,13 @@ class HttpKernelExtensionTest extends TestCase
|
|||||||
;
|
;
|
||||||
$renderer = new FragmentHandler(array(), false, $context);
|
$renderer = new FragmentHandler(array(), false, $context);
|
||||||
|
|
||||||
$this->setExpectedException('InvalidArgumentException', 'The "inline" renderer does not exist.');
|
if (method_exists($this, 'expectException')) {
|
||||||
|
$this->expectException('InvalidArgumentException');
|
||||||
|
$this->expectExceptionMessage('The "inline" renderer does not exist.');
|
||||||
|
} else {
|
||||||
|
$this->setExpectedException('InvalidArgumentException', 'The "inline" renderer does not exist.');
|
||||||
|
}
|
||||||
|
|
||||||
$renderer->render('/foo');
|
$renderer->render('/foo');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +141,12 @@ class ControllerResolverTest extends BaseControllerResolverTest
|
|||||||
*/
|
*/
|
||||||
public function testGetControllerOnNonUndefinedFunction($controller, $exceptionName = null, $exceptionMessage = null)
|
public function testGetControllerOnNonUndefinedFunction($controller, $exceptionName = null, $exceptionMessage = null)
|
||||||
{
|
{
|
||||||
$this->setExpectedException($exceptionName, $exceptionMessage);
|
if (method_exists($this, 'expectException')) {
|
||||||
|
$this->expectException($exceptionName);
|
||||||
|
$this->expectExceptionMessage($exceptionMessage);
|
||||||
|
} else {
|
||||||
|
$this->setExpectedException($exceptionName, $exceptionMessage);
|
||||||
|
}
|
||||||
|
|
||||||
parent::testGetControllerOnNonUndefinedFunction($controller);
|
parent::testGetControllerOnNonUndefinedFunction($controller);
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,13 @@
|
|||||||
|
|
||||||
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
|
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\DataCollectorTranslatorPass;
|
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\DataCollectorTranslatorPass;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Component\DependencyInjection\Reference;
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
use Symfony\Component\Translation\TranslatorInterface;
|
use Symfony\Component\Translation\TranslatorInterface;
|
||||||
|
|
||||||
class DataCollectorTranslatorPassTest extends \PHPUnit_Framework_TestCase
|
class DataCollectorTranslatorPassTest extends TestCase
|
||||||
{
|
{
|
||||||
private $container;
|
private $container;
|
||||||
private $dataCollectorTranslatorPass;
|
private $dataCollectorTranslatorPass;
|
||||||
|
@ -41,7 +41,7 @@ class ProfilerPassTest extends TestCase
|
|||||||
|
|
||||||
$builder = $this->createContainerMock($services);
|
$builder = $this->createContainerMock($services);
|
||||||
|
|
||||||
$this->setExpectedException('InvalidArgumentException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('InvalidArgumentException');
|
||||||
|
|
||||||
$profilerPass = new ProfilerPass();
|
$profilerPass = new ProfilerPass();
|
||||||
$profilerPass->process($builder);
|
$profilerPass->process($builder);
|
||||||
|
@ -36,7 +36,7 @@ class SerializerPassTest extends TestCase
|
|||||||
->with('serializer.normalizer')
|
->with('serializer.normalizer')
|
||||||
->will($this->returnValue(array()));
|
->will($this->returnValue(array()));
|
||||||
|
|
||||||
$this->setExpectedException('RuntimeException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('RuntimeException');
|
||||||
|
|
||||||
$serializerPass = new SerializerPass();
|
$serializerPass = new SerializerPass();
|
||||||
$serializerPass->process($container);
|
$serializerPass->process($container);
|
||||||
@ -63,7 +63,7 @@ class SerializerPassTest extends TestCase
|
|||||||
->method('getDefinition')
|
->method('getDefinition')
|
||||||
->will($this->returnValue($definition));
|
->will($this->returnValue($definition));
|
||||||
|
|
||||||
$this->setExpectedException('RuntimeException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('RuntimeException');
|
||||||
|
|
||||||
$serializerPass = new SerializerPass();
|
$serializerPass = new SerializerPass();
|
||||||
$serializerPass->process($container);
|
$serializerPass->process($container);
|
||||||
|
@ -101,7 +101,7 @@ class TranslatorTest extends TestCase
|
|||||||
$translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir), 'loader', '\Symfony\Bundle\FrameworkBundle\Tests\Translation\TranslatorWithInvalidLocale');
|
$translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir), 'loader', '\Symfony\Bundle\FrameworkBundle\Tests\Translation\TranslatorWithInvalidLocale');
|
||||||
$translator->setLocale('invalid locale');
|
$translator->setLocale('invalid locale');
|
||||||
|
|
||||||
$this->setExpectedException('\InvalidArgumentException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('\InvalidArgumentException');
|
||||||
$translator->trans('foo');
|
$translator->trans('foo');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +129,12 @@ class UserPasswordEncoderCommandTest extends WebTestCase
|
|||||||
|
|
||||||
public function testEncodePasswordNoConfigForGivenUserClass()
|
public function testEncodePasswordNoConfigForGivenUserClass()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('\RuntimeException', 'No encoder has been configured for account "Foo\Bar\User".');
|
if (method_exists($this, 'expectException')) {
|
||||||
|
$this->expectException('\RuntimeException');
|
||||||
|
$this->expectExceptionMessage('No encoder has been configured for account "Foo\Bar\User".');
|
||||||
|
} else {
|
||||||
|
$this->setExpectedException('\RuntimeException', 'No encoder has been configured for account "Foo\Bar\User".');
|
||||||
|
}
|
||||||
|
|
||||||
$this->passwordEncoderCommandTester->execute(array(
|
$this->passwordEncoderCommandTester->execute(array(
|
||||||
'command' => 'security:encode-password',
|
'command' => 'security:encode-password',
|
||||||
|
@ -85,7 +85,7 @@ class CookieTest extends TestCase
|
|||||||
|
|
||||||
public function testFromStringThrowsAnExceptionIfCookieIsNotValid()
|
public function testFromStringThrowsAnExceptionIfCookieIsNotValid()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('InvalidArgumentException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('InvalidArgumentException');
|
||||||
Cookie::fromString('foo');
|
Cookie::fromString('foo');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ class CookieTest extends TestCase
|
|||||||
|
|
||||||
public function testFromStringThrowsAnExceptionIfUrlIsNotValid()
|
public function testFromStringThrowsAnExceptionIfUrlIsNotValid()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('InvalidArgumentException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('InvalidArgumentException');
|
||||||
Cookie::fromString('foo=bar', 'foobar');
|
Cookie::fromString('foo=bar', 'foobar');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,12 @@ class ScalarNodeTest extends TestCase
|
|||||||
{
|
{
|
||||||
$node = new ScalarNode('test');
|
$node = new ScalarNode('test');
|
||||||
|
|
||||||
$this->setExpectedException('Symfony\Component\Config\Definition\Exception\InvalidTypeException', 'Invalid type for path "test". Expected scalar, but got array.');
|
if (method_exists($this, 'expectException')) {
|
||||||
|
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException');
|
||||||
|
$this->expectExceptionMessage('Invalid type for path "test". Expected scalar, but got array.');
|
||||||
|
} else {
|
||||||
|
$this->setExpectedException('Symfony\Component\Config\Definition\Exception\InvalidTypeException', 'Invalid type for path "test". Expected scalar, but got array.');
|
||||||
|
}
|
||||||
|
|
||||||
$node->normalize(array());
|
$node->normalize(array());
|
||||||
}
|
}
|
||||||
@ -73,7 +78,12 @@ class ScalarNodeTest extends TestCase
|
|||||||
$node = new ScalarNode('test');
|
$node = new ScalarNode('test');
|
||||||
$node->setInfo('"the test value"');
|
$node->setInfo('"the test value"');
|
||||||
|
|
||||||
$this->setExpectedException('Symfony\Component\Config\Definition\Exception\InvalidTypeException', "Invalid type for path \"test\". Expected scalar, but got array.\nHint: \"the test value\"");
|
if (method_exists($this, 'expectException')) {
|
||||||
|
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException');
|
||||||
|
$this->expectExceptionMessage("Invalid type for path \"test\". Expected scalar, but got array.\nHint: \"the test value\"");
|
||||||
|
} else {
|
||||||
|
$this->setExpectedException('Symfony\Component\Config\Definition\Exception\InvalidTypeException', "Invalid type for path \"test\". Expected scalar, but got array.\nHint: \"the test value\"");
|
||||||
|
}
|
||||||
|
|
||||||
$node->normalize(array());
|
$node->normalize(array());
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,14 @@ class XmlUtilsTest extends TestCase
|
|||||||
public function testLoadEmptyXmlFile()
|
public function testLoadEmptyXmlFile()
|
||||||
{
|
{
|
||||||
$file = __DIR__.'/../Fixtures/foo.xml';
|
$file = __DIR__.'/../Fixtures/foo.xml';
|
||||||
$this->setExpectedException('InvalidArgumentException', sprintf('File %s does not contain valid XML, it is empty.', $file));
|
|
||||||
|
if (method_exists($this, 'expectException')) {
|
||||||
|
$this->expectException('InvalidArgumentException');
|
||||||
|
$this->expectExceptionMessage(sprintf('File %s does not contain valid XML, it is empty.', $file));
|
||||||
|
} else {
|
||||||
|
$this->setExpectedException('InvalidArgumentException', sprintf('File %s does not contain valid XML, it is empty.', $file));
|
||||||
|
}
|
||||||
|
|
||||||
XmlUtils::loadFile($file);
|
XmlUtils::loadFile($file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,7 +266,12 @@ class ApplicationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testFindWithAmbiguousAbbreviations($abbreviation, $expectedExceptionMessage)
|
public function testFindWithAmbiguousAbbreviations($abbreviation, $expectedExceptionMessage)
|
||||||
{
|
{
|
||||||
$this->setExpectedException('InvalidArgumentException', $expectedExceptionMessage);
|
if (method_exists($this, 'expectException')) {
|
||||||
|
$this->expectException('InvalidArgumentException');
|
||||||
|
$this->expectExceptionMessage($expectedExceptionMessage);
|
||||||
|
} else {
|
||||||
|
$this->setExpectedException('InvalidArgumentException', $expectedExceptionMessage);
|
||||||
|
}
|
||||||
|
|
||||||
$application = new Application();
|
$application = new Application();
|
||||||
$application->add(new \FooCommand());
|
$application->add(new \FooCommand());
|
||||||
@ -954,7 +959,12 @@ class ApplicationTest extends TestCase
|
|||||||
|
|
||||||
public function testRunWithError()
|
public function testRunWithError()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('Exception', 'dymerr');
|
if (method_exists($this, 'expectException')) {
|
||||||
|
$this->expectException('Exception');
|
||||||
|
$this->expectExceptionMessage('dymerr');
|
||||||
|
} else {
|
||||||
|
$this->setExpectedException('Exception', 'dymerr');
|
||||||
|
}
|
||||||
|
|
||||||
$application = new Application();
|
$application = new Application();
|
||||||
$application->setAutoExit(false);
|
$application->setAutoExit(false);
|
||||||
|
@ -110,7 +110,12 @@ class CommandTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testInvalidCommandNames($name)
|
public function testInvalidCommandNames($name)
|
||||||
{
|
{
|
||||||
$this->setExpectedException('InvalidArgumentException', sprintf('Command name "%s" is invalid.', $name));
|
if (method_exists($this, 'expectException')) {
|
||||||
|
$this->expectException('InvalidArgumentException');
|
||||||
|
$this->expectExceptionMessage(sprintf('Command name "%s" is invalid.', $name));
|
||||||
|
} else {
|
||||||
|
$this->setExpectedException('InvalidArgumentException', sprintf('Command name "%s" is invalid.', $name));
|
||||||
|
}
|
||||||
|
|
||||||
$command = new \TestCommand();
|
$command = new \TestCommand();
|
||||||
$command->setName($name);
|
$command->setName($name);
|
||||||
@ -168,7 +173,7 @@ class CommandTest extends TestCase
|
|||||||
public function testSetAliasesNull()
|
public function testSetAliasesNull()
|
||||||
{
|
{
|
||||||
$command = new \TestCommand();
|
$command = new \TestCommand();
|
||||||
$this->setExpectedException('InvalidArgumentException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('InvalidArgumentException');
|
||||||
$command->setAliases(null);
|
$command->setAliases(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,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->setExpectedException('InvalidArgumentException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('InvalidArgumentException');
|
||||||
$style->setForeground('undefined-color');
|
$style->setForeground('undefined-color');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +58,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->setExpectedException('InvalidArgumentException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('InvalidArgumentException');
|
||||||
$style->setBackground('undefined-color');
|
$style->setBackground('undefined-color');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,7 +164,12 @@ class ArgvInputTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testInvalidInput($argv, $definition, $expectedExceptionMessage)
|
public function testInvalidInput($argv, $definition, $expectedExceptionMessage)
|
||||||
{
|
{
|
||||||
$this->setExpectedException('RuntimeException', $expectedExceptionMessage);
|
if (method_exists($this, 'expectException')) {
|
||||||
|
$this->expectException('RuntimeException');
|
||||||
|
$this->expectExceptionMessage($expectedExceptionMessage);
|
||||||
|
} else {
|
||||||
|
$this->setExpectedException('RuntimeException', $expectedExceptionMessage);
|
||||||
|
}
|
||||||
|
|
||||||
$input = new ArgvInput($argv);
|
$input = new ArgvInput($argv);
|
||||||
$input->bind($definition);
|
$input->bind($definition);
|
||||||
|
@ -100,7 +100,12 @@ class ArrayInputTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testParseInvalidInput($parameters, $definition, $expectedExceptionMessage)
|
public function testParseInvalidInput($parameters, $definition, $expectedExceptionMessage)
|
||||||
{
|
{
|
||||||
$this->setExpectedException('InvalidArgumentException', $expectedExceptionMessage);
|
if (method_exists($this, 'expectException')) {
|
||||||
|
$this->expectException('InvalidArgumentException');
|
||||||
|
$this->expectExceptionMessage($expectedExceptionMessage);
|
||||||
|
} else {
|
||||||
|
$this->setExpectedException('InvalidArgumentException', $expectedExceptionMessage);
|
||||||
|
}
|
||||||
|
|
||||||
new ArrayInput($parameters, $definition);
|
new ArrayInput($parameters, $definition);
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,12 @@ class InputArgumentTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testInvalidModes($mode)
|
public function testInvalidModes($mode)
|
||||||
{
|
{
|
||||||
$this->setExpectedException('InvalidArgumentException', sprintf('Argument mode "%s" is not valid.', $mode));
|
if (method_exists($this, 'expectException')) {
|
||||||
|
$this->expectException('InvalidArgumentException');
|
||||||
|
$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);
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,12 @@ class InputOptionTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testInvalidModes($mode)
|
public function testInvalidModes($mode)
|
||||||
{
|
{
|
||||||
$this->setExpectedException('InvalidArgumentException', sprintf('Option mode "%s" is not valid.', $mode));
|
if (method_exists($this, 'expectException')) {
|
||||||
|
$this->expectException('InvalidArgumentException');
|
||||||
|
$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);
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ class ParserTest extends TestCase
|
|||||||
|
|
||||||
/** @var FunctionNode $function */
|
/** @var FunctionNode $function */
|
||||||
$function = $selectors[0]->getTree();
|
$function = $selectors[0]->getTree();
|
||||||
$this->setExpectedException('Symfony\Component\CssSelector\Exception\SyntaxErrorException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\CssSelector\Exception\SyntaxErrorException');
|
||||||
Parser::parseSeries($function->getArguments());
|
Parser::parseSeries($function->getArguments());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ class TokenStreamTest extends TestCase
|
|||||||
|
|
||||||
public function testFailToGetNextIdentifier()
|
public function testFailToGetNextIdentifier()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('Symfony\Component\CssSelector\Exception\SyntaxErrorException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('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 +73,7 @@ class TokenStreamTest extends TestCase
|
|||||||
|
|
||||||
public function testFailToGetNextIdentifierOrStar()
|
public function testFailToGetNextIdentifierOrStar()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('Symfony\Component\CssSelector\Exception\SyntaxErrorException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('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));
|
||||||
|
@ -621,7 +621,7 @@ class ContainerBuilderTest extends TestCase
|
|||||||
$container->registerExtension($extension = new \ProjectExtension());
|
$container->registerExtension($extension = new \ProjectExtension());
|
||||||
$this->assertTrue($container->getExtension('project') === $extension, '->registerExtension() registers an extension');
|
$this->assertTrue($container->getExtension('project') === $extension, '->registerExtension() registers an extension');
|
||||||
|
|
||||||
$this->setExpectedException('LogicException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('LogicException');
|
||||||
$container->getExtension('no_registered');
|
$container->getExtension('no_registered');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,14 @@ class DefinitionTest extends TestCase
|
|||||||
$this->assertNull($def->getDecoratedService());
|
$this->assertNull($def->getDecoratedService());
|
||||||
|
|
||||||
$def = new Definition('stdClass');
|
$def = new Definition('stdClass');
|
||||||
$this->setExpectedException('InvalidArgumentException', 'The decorated service inner name for "foo" must be different than the service name itself.');
|
|
||||||
|
if (method_exists($this, 'expectException')) {
|
||||||
|
$this->expectException('InvalidArgumentException');
|
||||||
|
$this->expectExceptionMessage('The decorated service inner name for "foo" must be different than the service name itself.');
|
||||||
|
} else {
|
||||||
|
$this->setExpectedException('InvalidArgumentException', 'The decorated service inner name for "foo" must be different than the service name itself.');
|
||||||
|
}
|
||||||
|
|
||||||
$def->setDecoratedService('foo', 'foo');
|
$def->setDecoratedService('foo', 'foo');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -886,6 +886,8 @@ HTML;
|
|||||||
$crawler = new Crawler('<p></p>');
|
$crawler = new Crawler('<p></p>');
|
||||||
$crawler->filter('p')->children();
|
$crawler->filter('p')->children();
|
||||||
$this->assertTrue(true, '->children() does not trigger a notice if the node has no children');
|
$this->assertTrue(true, '->children() does not trigger a notice if the node has no children');
|
||||||
|
} catch (\PHPUnit\Framework\Error\Notice $e) {
|
||||||
|
$this->fail('->children() does not trigger a notice if the node has no children');
|
||||||
} catch (\PHPUnit_Framework_Error_Notice $e) {
|
} catch (\PHPUnit_Framework_Error_Notice $e) {
|
||||||
$this->fail('->children() does not trigger a notice if the node has no children');
|
$this->fail('->children() does not trigger a notice if the node has no children');
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,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->setExpectedException('InvalidArgumentException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('InvalidArgumentException');
|
||||||
$this->assertFalse($this->event['nameNotExist']);
|
$this->assertFalse($this->event['nameNotExist']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -689,6 +689,10 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
|||||||
$this->fail(sprintf("Expected exception:\n%s\nGot:\n%s\nWith comparison failure:\n%s", $expectedExceptionClass, 'PHPUnit_Framework_ExpectationFailedException', $e->getComparisonFailure()->getExpectedAsString()));
|
$this->fail(sprintf("Expected exception:\n%s\nGot:\n%s\nWith comparison failure:\n%s", $expectedExceptionClass, 'PHPUnit_Framework_ExpectationFailedException', $e->getComparisonFailure()->getExpectedAsString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($e instanceof \PHPUnit\Framework\ExpectationFailedException) {
|
||||||
|
$this->fail(sprintf("Expected exception:\n%s\nGot:\n%s\nWith comparison failure:\n%s", $expectedExceptionClass, '\PHPUnit\Framework\ExpectationFailedException', $e->getComparisonFailure()->getExpectedAsString()));
|
||||||
|
}
|
||||||
|
|
||||||
$this->assertInstanceOf($expectedExceptionClass, $e);
|
$this->assertInstanceOf($expectedExceptionClass, $e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ class CommandTest extends TestCase
|
|||||||
$cmd = Command::create()->add('--force');
|
$cmd = Command::create()->add('--force');
|
||||||
|
|
||||||
$cmd->ins('label');
|
$cmd->ins('label');
|
||||||
$this->setExpectedException('RuntimeException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('RuntimeException');
|
||||||
$cmd->ins('label');
|
$cmd->ins('label');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ class CommandTest extends TestCase
|
|||||||
{
|
{
|
||||||
$cmd = Command::create();
|
$cmd = Command::create();
|
||||||
|
|
||||||
$this->setExpectedException('RuntimeException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('RuntimeException');
|
||||||
$cmd->end();
|
$cmd->end();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ class CommandTest extends TestCase
|
|||||||
{
|
{
|
||||||
$cmd = Command::create();
|
$cmd = Command::create();
|
||||||
|
|
||||||
$this->setExpectedException('RuntimeException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('RuntimeException');
|
||||||
$cmd->get('invalid');
|
$cmd->get('invalid');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,11 @@ class DeprecationErrorHandler
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return \PHPUnit_Util_ErrorHandler::handleError($errorNumber, $message, $file, $line);
|
if (class_exists('PHPUnit_Util_ErrorHandler')) {
|
||||||
|
return \PHPUnit_Util_ErrorHandler::handleError($errorNumber, $message, $file, $line);
|
||||||
|
}
|
||||||
|
|
||||||
|
return \PHPUnit\Util\ErrorHandler::handleError($errorNumber, $message, $file, $line);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function handleBC($errorNumber, $message, $file, $line, $context)
|
public static function handleBC($errorNumber, $message, $file, $line, $context)
|
||||||
|
@ -53,7 +53,7 @@ class ButtonBuilderTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testInvalidNames($name)
|
public function testInvalidNames($name)
|
||||||
{
|
{
|
||||||
$this->setExpectedException(
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(
|
||||||
'\Symfony\Component\Form\Exception\InvalidArgumentException',
|
'\Symfony\Component\Form\Exception\InvalidArgumentException',
|
||||||
'Buttons cannot have empty names.'
|
'Buttons cannot have empty names.'
|
||||||
);
|
);
|
||||||
|
@ -190,7 +190,7 @@ class DateTimeToLocalizedStringTransformerTest extends DateTimeTestCase
|
|||||||
|
|
||||||
// HOW TO REPRODUCE?
|
// HOW TO REPRODUCE?
|
||||||
|
|
||||||
//$this->setExpectedException('Symfony\Component\Form\Extension\Core\DataTransformer\TransformationFailedException');
|
//$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Extension\Core\DataTransformer\TransformationFailedException');
|
||||||
|
|
||||||
//$transformer->transform(1.5);
|
//$transformer->transform(1.5);
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ class DateTimeToStringTransformerTest extends DateTimeTestCase
|
|||||||
{
|
{
|
||||||
$transformer = new DateTimeToStringTransformer();
|
$transformer = new DateTimeToStringTransformer();
|
||||||
|
|
||||||
$this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||||
|
|
||||||
$transformer->transform('1234');
|
$transformer->transform('1234');
|
||||||
}
|
}
|
||||||
@ -163,7 +163,7 @@ class DateTimeToStringTransformerTest extends DateTimeTestCase
|
|||||||
{
|
{
|
||||||
$reverseTransformer = new DateTimeToStringTransformer();
|
$reverseTransformer = new DateTimeToStringTransformer();
|
||||||
|
|
||||||
$this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||||
|
|
||||||
$reverseTransformer->reverseTransform(1234);
|
$reverseTransformer->reverseTransform(1234);
|
||||||
}
|
}
|
||||||
@ -172,7 +172,7 @@ class DateTimeToStringTransformerTest extends DateTimeTestCase
|
|||||||
{
|
{
|
||||||
$reverseTransformer = new DateTimeToStringTransformer();
|
$reverseTransformer = new DateTimeToStringTransformer();
|
||||||
|
|
||||||
$this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||||
|
|
||||||
$reverseTransformer->reverseTransform('2010-2010-2010');
|
$reverseTransformer->reverseTransform('2010-2010-2010');
|
||||||
}
|
}
|
||||||
@ -181,7 +181,7 @@ class DateTimeToStringTransformerTest extends DateTimeTestCase
|
|||||||
{
|
{
|
||||||
$reverseTransformer = new DateTimeToStringTransformer();
|
$reverseTransformer = new DateTimeToStringTransformer();
|
||||||
|
|
||||||
$this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||||
|
|
||||||
$reverseTransformer->reverseTransform('2010-04-31');
|
$reverseTransformer->reverseTransform('2010-04-31');
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ class DateTimeToTimestampTransformerTest extends DateTimeTestCase
|
|||||||
{
|
{
|
||||||
$transformer = new DateTimeToTimestampTransformer();
|
$transformer = new DateTimeToTimestampTransformer();
|
||||||
|
|
||||||
$this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||||
|
|
||||||
$transformer->transform('1234');
|
$transformer->transform('1234');
|
||||||
}
|
}
|
||||||
@ -111,7 +111,7 @@ class DateTimeToTimestampTransformerTest extends DateTimeTestCase
|
|||||||
{
|
{
|
||||||
$reverseTransformer = new DateTimeToTimestampTransformer();
|
$reverseTransformer = new DateTimeToTimestampTransformer();
|
||||||
|
|
||||||
$this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||||
|
|
||||||
$reverseTransformer->reverseTransform('2010-2010-2010');
|
$reverseTransformer->reverseTransform('2010-2010-2010');
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ class MoneyToLocalizedStringTransformerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$transformer = new MoneyToLocalizedStringTransformer(null, null, null, 100);
|
$transformer = new MoneyToLocalizedStringTransformer(null, null, null, 100);
|
||||||
|
|
||||||
$this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||||
|
|
||||||
$transformer->transform('abcd');
|
$transformer->transform('abcd');
|
||||||
}
|
}
|
||||||
@ -61,7 +61,7 @@ class MoneyToLocalizedStringTransformerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$transformer = new MoneyToLocalizedStringTransformer(null, null, null, 100);
|
$transformer = new MoneyToLocalizedStringTransformer(null, null, null, 100);
|
||||||
|
|
||||||
$this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||||
|
|
||||||
$transformer->reverseTransform(12345);
|
$transformer->reverseTransform(12345);
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$transformer = new PercentToLocalizedStringTransformer();
|
$transformer = new PercentToLocalizedStringTransformer();
|
||||||
|
|
||||||
$this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||||
|
|
||||||
$transformer->transform('foo');
|
$transformer->transform('foo');
|
||||||
}
|
}
|
||||||
@ -115,7 +115,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$transformer = new PercentToLocalizedStringTransformer();
|
$transformer = new PercentToLocalizedStringTransformer();
|
||||||
|
|
||||||
$this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||||
|
|
||||||
$transformer->reverseTransform(1);
|
$transformer->reverseTransform(1);
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
$form = $this->factory->create('collection', null, array(
|
$form = $this->factory->create('collection', null, array(
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
));
|
));
|
||||||
$this->setExpectedException('Symfony\Component\Form\Exception\UnexpectedTypeException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\UnexpectedTypeException');
|
||||||
$form->setData(new \stdClass());
|
$form->setData(new \stdClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,13 +49,13 @@ class FormBuilderTest extends TestCase
|
|||||||
|
|
||||||
public function testAddNameNoStringAndNoInteger()
|
public function testAddNameNoStringAndNoInteger()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('Symfony\Component\Form\Exception\UnexpectedTypeException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\UnexpectedTypeException');
|
||||||
$this->builder->add(true);
|
$this->builder->add(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAddTypeNoString()
|
public function testAddTypeNoString()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('Symfony\Component\Form\Exception\UnexpectedTypeException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\UnexpectedTypeException');
|
||||||
$this->builder->add('foo', 1234);
|
$this->builder->add('foo', 1234);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,7 +165,13 @@ class FormBuilderTest extends TestCase
|
|||||||
|
|
||||||
public function testGetUnknown()
|
public function testGetUnknown()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('Symfony\Component\Form\Exception\InvalidArgumentException', 'The child with the name "foo" does not exist.');
|
if (method_exists($this, 'expectException')) {
|
||||||
|
$this->expectException('Symfony\Component\Form\Exception\InvalidArgumentException');
|
||||||
|
$this->expectExceptionMessage('The child with the name "foo" does not exist.');
|
||||||
|
} else {
|
||||||
|
$this->setExpectedException('Symfony\Component\Form\Exception\InvalidArgumentException', 'The child with the name "foo" does not exist.');
|
||||||
|
}
|
||||||
|
|
||||||
$this->builder->get('foo');
|
$this->builder->get('foo');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,11 @@ class TranslationFilesTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTranslationFileIsValid($filePath)
|
public function testTranslationFileIsValid($filePath)
|
||||||
{
|
{
|
||||||
\PHPUnit_Util_XML::loadfile($filePath, false, false, true);
|
if (class_exists('PHPUnit_Util_XML')) {
|
||||||
|
\PHPUnit_Util_XML::loadfile($filePath, false, false, true);
|
||||||
|
} else {
|
||||||
|
\PHPUnit\Util\XML::loadfile($filePath, false, false, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function provideTranslationFiles()
|
public function provideTranslationFiles()
|
||||||
|
@ -64,7 +64,7 @@ class FileTest extends TestCase
|
|||||||
|
|
||||||
public function testConstructWhenFileNotExists()
|
public function testConstructWhenFileNotExists()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException');
|
||||||
|
|
||||||
new File(__DIR__.'/Fixtures/not_here');
|
new File(__DIR__.'/Fixtures/not_here');
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ class MimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testGuessImageWithDirectory()
|
public function testGuessImageWithDirectory()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException');
|
||||||
|
|
||||||
MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/directory');
|
MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/directory');
|
||||||
}
|
}
|
||||||
@ -53,7 +53,7 @@ class MimeTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testGuessWithIncorrectPath()
|
public function testGuessWithIncorrectPath()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException');
|
||||||
MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/not_here');
|
MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/not_here');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ class MimeTypeTest extends TestCase
|
|||||||
@chmod($path, 0333);
|
@chmod($path, 0333);
|
||||||
|
|
||||||
if (substr(sprintf('%o', fileperms($path)), -4) == '0333') {
|
if (substr(sprintf('%o', fileperms($path)), -4) == '0333') {
|
||||||
$this->setExpectedException('Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('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');
|
||||||
|
@ -25,7 +25,7 @@ class UploadedFileTest extends TestCase
|
|||||||
|
|
||||||
public function testConstructWhenFileNotExists()
|
public function testConstructWhenFileNotExists()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException');
|
||||||
|
|
||||||
new UploadedFile(
|
new UploadedFile(
|
||||||
__DIR__.'/Fixtures/not_here',
|
__DIR__.'/Fixtures/not_here',
|
||||||
|
@ -1897,7 +1897,13 @@ class RequestTest extends TestCase
|
|||||||
$this->assertSame($expectedPort, $request->getPort());
|
$this->assertSame($expectedPort, $request->getPort());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->setExpectedException('UnexpectedValueException', 'Invalid Host');
|
if (method_exists($this, 'expectException')) {
|
||||||
|
$this->expectException('UnexpectedValueException');
|
||||||
|
$this->expectExceptionMessage('Invalid Host');
|
||||||
|
} else {
|
||||||
|
$this->setExpectedException('UnexpectedValueException', 'Invalid Host');
|
||||||
|
}
|
||||||
|
|
||||||
$request->getHost();
|
$request->getHost();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ class LegacyPdoSessionHandlerTest extends TestCase
|
|||||||
|
|
||||||
public function testIncompleteOptions()
|
public function testIncompleteOptions()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('InvalidArgumentException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('InvalidArgumentException');
|
||||||
$storage = new LegacyPdoSessionHandler($this->pdo, array());
|
$storage = new LegacyPdoSessionHandler($this->pdo, array());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,21 +44,21 @@ class LegacyPdoSessionHandlerTest extends TestCase
|
|||||||
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_SILENT);
|
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_SILENT);
|
||||||
$pdo->exec('CREATE TABLE sessions (sess_id VARCHAR(128) PRIMARY KEY, sess_data TEXT, sess_time INTEGER)');
|
$pdo->exec('CREATE TABLE sessions (sess_id VARCHAR(128) PRIMARY KEY, sess_data TEXT, sess_time INTEGER)');
|
||||||
|
|
||||||
$this->setExpectedException('InvalidArgumentException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('InvalidArgumentException');
|
||||||
$storage = new LegacyPdoSessionHandler($pdo, array('db_table' => 'sessions'));
|
$storage = new LegacyPdoSessionHandler($pdo, array('db_table' => 'sessions'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWrongTableOptionsWrite()
|
public function testWrongTableOptionsWrite()
|
||||||
{
|
{
|
||||||
$storage = new LegacyPdoSessionHandler($this->pdo, array('db_table' => 'bad_name'));
|
$storage = new LegacyPdoSessionHandler($this->pdo, array('db_table' => 'bad_name'));
|
||||||
$this->setExpectedException('RuntimeException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('RuntimeException');
|
||||||
$storage->write('foo', 'bar');
|
$storage->write('foo', 'bar');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWrongTableOptionsRead()
|
public function testWrongTableOptionsRead()
|
||||||
{
|
{
|
||||||
$storage = new LegacyPdoSessionHandler($this->pdo, array('db_table' => 'bad_name'));
|
$storage = new LegacyPdoSessionHandler($this->pdo, array('db_table' => 'bad_name'));
|
||||||
$this->setExpectedException('RuntimeException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('RuntimeException');
|
||||||
$storage->read('foo');
|
$storage->read('foo');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ class FileLocatorTest extends TestCase
|
|||||||
$kernel
|
$kernel
|
||||||
->expects($this->never())
|
->expects($this->never())
|
||||||
->method('locateResource');
|
->method('locateResource');
|
||||||
$this->setExpectedException('LogicException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('LogicException');
|
||||||
$locator->locate('/some/path');
|
$locator->locate('/some/path');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,6 +104,8 @@ class ContainerAwareHttpKernelTest extends TestCase
|
|||||||
try {
|
try {
|
||||||
$kernel->handle($request, $type);
|
$kernel->handle($request, $type);
|
||||||
$this->fail('->handle() suppresses the controller exception');
|
$this->fail('->handle() suppresses the controller exception');
|
||||||
|
} catch (\PHPUnit\Framework\Exception $e) {
|
||||||
|
throw $e;
|
||||||
} catch (\PHPUnit_Framework_Exception $e) {
|
} catch (\PHPUnit_Framework_Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
@ -306,10 +306,17 @@ abstract class AbstractNumberFormatterTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider formatTypeCurrencyProvider
|
* @dataProvider formatTypeCurrencyProvider
|
||||||
* @expectedException \PHPUnit_Framework_Error_Warning
|
|
||||||
*/
|
*/
|
||||||
public function testFormatTypeCurrency($formatter, $value)
|
public function testFormatTypeCurrency($formatter, $value)
|
||||||
{
|
{
|
||||||
|
$exceptionCode = 'PHPUnit\Framework\Error\Warning';
|
||||||
|
|
||||||
|
if (class_exists('PHPUnit_Framework_Error_Warning')) {
|
||||||
|
$exceptionCode = 'PHPUnit_Framework_Error_Warning';
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}($exceptionCode);
|
||||||
|
|
||||||
$formatter->format($value, NumberFormatter::TYPE_CURRENCY);
|
$formatter->format($value, NumberFormatter::TYPE_CURRENCY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -641,11 +648,16 @@ abstract class AbstractNumberFormatterTest extends TestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \PHPUnit_Framework_Error_Warning
|
|
||||||
*/
|
|
||||||
public function testParseTypeDefault()
|
public function testParseTypeDefault()
|
||||||
{
|
{
|
||||||
|
$exceptionCode = 'PHPUnit\Framework\Error\Warning';
|
||||||
|
|
||||||
|
if (class_exists('PHPUnit_Framework_Error_Warning')) {
|
||||||
|
$exceptionCode = 'PHPUnit_Framework_Error_Warning';
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}($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);
|
||||||
}
|
}
|
||||||
@ -782,11 +794,16 @@ abstract class AbstractNumberFormatterTest extends TestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \PHPUnit_Framework_Error_Warning
|
|
||||||
*/
|
|
||||||
public function testParseTypeCurrency()
|
public function testParseTypeCurrency()
|
||||||
{
|
{
|
||||||
|
$exceptionCode = 'PHPUnit\Framework\Error\Warning';
|
||||||
|
|
||||||
|
if (class_exists('PHPUnit_Framework_Error_Warning')) {
|
||||||
|
$exceptionCode = 'PHPUnit_Framework_Error_Warning';
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}($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);
|
||||||
}
|
}
|
||||||
|
@ -507,7 +507,14 @@ class OptionsResolver2Dot6Test extends TestCase
|
|||||||
{
|
{
|
||||||
$this->resolver->setDefined('option');
|
$this->resolver->setDefined('option');
|
||||||
$this->resolver->setAllowedTypes('option', $allowedType);
|
$this->resolver->setAllowedTypes('option', $allowedType);
|
||||||
$this->setExpectedException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException', $exceptionMessage);
|
|
||||||
|
if (method_exists($this, 'expectException')) {
|
||||||
|
$this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException');
|
||||||
|
$this->expectExceptionMessage($exceptionMessage);
|
||||||
|
} else {
|
||||||
|
$this->setExpectedException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException', $exceptionMessage);
|
||||||
|
}
|
||||||
|
|
||||||
$this->resolver->resolve(array('option' => $actualType));
|
$this->resolver->resolve(array('option' => $actualType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ class ProcessFailedExceptionTest extends TestCase
|
|||||||
->method('isSuccessful')
|
->method('isSuccessful')
|
||||||
->will($this->returnValue(true));
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
$this->setExpectedException(
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(
|
||||||
'\InvalidArgumentException',
|
'\InvalidArgumentException',
|
||||||
'Expected a failed process, but the given process was successful.'
|
'Expected a failed process, but the given process was successful.'
|
||||||
);
|
);
|
||||||
|
@ -927,7 +927,14 @@ class ProcessTest extends TestCase
|
|||||||
public function testMethodsThatNeedARunningProcess($method)
|
public function testMethodsThatNeedARunningProcess($method)
|
||||||
{
|
{
|
||||||
$process = $this->getProcess('foo');
|
$process = $this->getProcess('foo');
|
||||||
$this->setExpectedException('Symfony\Component\Process\Exception\LogicException', sprintf('Process must be started before calling %s.', $method));
|
|
||||||
|
if (method_exists($this, 'expectException')) {
|
||||||
|
$this->expectException('Symfony\Component\Process\Exception\LogicException');
|
||||||
|
$this->expectExceptionMessage(sprintf('Process must be started before calling %s.', $method));
|
||||||
|
} else {
|
||||||
|
$this->setExpectedException('Symfony\Component\Process\Exception\LogicException', sprintf('Process must be started before calling %s.', $method));
|
||||||
|
}
|
||||||
|
|
||||||
$process->{$method}();
|
$process->{$method}();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1081,7 +1088,14 @@ class ProcessTest extends TestCase
|
|||||||
{
|
{
|
||||||
$p = $this->getProcess('foo');
|
$p = $this->getProcess('foo');
|
||||||
$p->disableOutput();
|
$p->disableOutput();
|
||||||
$this->setExpectedException($exception, $exceptionMessage);
|
|
||||||
|
if (method_exists($this, 'expectException')) {
|
||||||
|
$this->expectException($exception);
|
||||||
|
$this->expectExceptionMessage($exceptionMessage);
|
||||||
|
} else {
|
||||||
|
$this->setExpectedException($exception, $exceptionMessage);
|
||||||
|
}
|
||||||
|
|
||||||
if ('mustRun' === $startMethod) {
|
if ('mustRun' === $startMethod) {
|
||||||
$this->skipIfNotEnhancedSigchild();
|
$this->skipIfNotEnhancedSigchild();
|
||||||
}
|
}
|
||||||
@ -1250,7 +1264,12 @@ class ProcessTest extends TestCase
|
|||||||
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) {
|
||||||
$this->setExpectedException('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild.');
|
if (method_exists($this, 'expectException')) {
|
||||||
|
$this->expectException('Symfony\Component\Process\Exception\RuntimeException');
|
||||||
|
$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.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -359,7 +359,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->setExpectedException('Symfony\Component\Routing\Exception\InvalidParameterException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Routing\Exception\InvalidParameterException');
|
||||||
$generator->generate('test', array('x' => 'do.t', 'y' => '123', 'z' => 'bar', '_format' => 'xml'));
|
$generator->generate('test', array('x' => 'do.t', 'y' => '123', 'z' => 'bar', '_format' => 'xml'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ class UrlMatcherTest extends TestCase
|
|||||||
$matcher = new UrlMatcher($collection, new RequestContext());
|
$matcher = new UrlMatcher($collection, new RequestContext());
|
||||||
|
|
||||||
$this->assertEquals(array('_route' => 'foo'), $matcher->match('/foo1'));
|
$this->assertEquals(array('_route' => 'foo'), $matcher->match('/foo1'));
|
||||||
$this->setExpectedException('Symfony\Component\Routing\Exception\ResourceNotFoundException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Routing\Exception\ResourceNotFoundException');
|
||||||
$this->assertEquals(array(), $matcher->match('/foo'));
|
$this->assertEquals(array(), $matcher->match('/foo'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,7 +252,7 @@ class UrlMatcherTest extends TestCase
|
|||||||
// z and _format are optional.
|
// z and _format are optional.
|
||||||
$this->assertEquals(array('w' => 'wwwww', 'x' => 'x', 'y' => 'y', 'z' => 'default-z', '_format' => 'html', '_route' => 'test'), $matcher->match('/wwwwwxy'));
|
$this->assertEquals(array('w' => 'wwwww', 'x' => 'x', 'y' => 'y', 'z' => 'default-z', '_format' => 'html', '_route' => 'test'), $matcher->match('/wwwwwxy'));
|
||||||
|
|
||||||
$this->setExpectedException('Symfony\Component\Routing\Exception\ResourceNotFoundException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Routing\Exception\ResourceNotFoundException');
|
||||||
$matcher->match('/wxy.html');
|
$matcher->match('/wxy.html');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,7 +267,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->setExpectedException('Symfony\Component\Routing\Exception\ResourceNotFoundException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Routing\Exception\ResourceNotFoundException');
|
||||||
$matcher->match('/ge');
|
$matcher->match('/ge');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase
|
|||||||
try {
|
try {
|
||||||
random_bytes(1);
|
random_bytes(1);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw new \PHPUnit_Framework_SkippedTestError($e->getMessage());
|
self::markTestSkipped($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,11 @@ class TranslationFilesTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTranslationFileIsValid($filePath)
|
public function testTranslationFileIsValid($filePath)
|
||||||
{
|
{
|
||||||
\PHPUnit_Util_XML::loadfile($filePath, false, false, true);
|
if (class_exists('PHPUnit_Util_XML')) {
|
||||||
|
\PHPUnit_Util_XML::loadfile($filePath, false, false, true);
|
||||||
|
} else {
|
||||||
|
\PHPUnit\Util\XML::loadfile($filePath, false, false, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function provideTranslationFiles()
|
public function provideTranslationFiles()
|
||||||
|
@ -450,7 +450,12 @@ XML;
|
|||||||
|
|
||||||
public function testDecodeEmptyXml()
|
public function testDecodeEmptyXml()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('Symfony\Component\Serializer\Exception\UnexpectedValueException', 'Invalid XML data, it can not be empty.');
|
if (method_exists($this, 'expectException')) {
|
||||||
|
$this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException');
|
||||||
|
$this->expectExceptionMessage('Invalid XML data, it can not be empty.');
|
||||||
|
} else {
|
||||||
|
$this->setExpectedException('Symfony\Component\Serializer\Exception\UnexpectedValueException', 'Invalid XML data, it can not be empty.');
|
||||||
|
}
|
||||||
$this->encoder->decode(' ', 'xml');
|
$this->encoder->decode(' ', 'xml');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ class LegacyCoreAssetsHelperTest extends TestCase
|
|||||||
{
|
{
|
||||||
$helper = new CoreAssetsHelper($this->package);
|
$helper = new CoreAssetsHelper($this->package);
|
||||||
|
|
||||||
$this->setExpectedException('\InvalidArgumentException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('\InvalidArgumentException');
|
||||||
|
|
||||||
$helper->getPackage('foo');
|
$helper->getPackage('foo');
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,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->setExpectedException('\LogicException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('\LogicException');
|
||||||
|
|
||||||
unset($engine['foo']);
|
unset($engine['foo']);
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ abstract class AbstractOperationTest extends TestCase
|
|||||||
|
|
||||||
public function testGetMessagesFromUnknownDomain()
|
public function testGetMessagesFromUnknownDomain()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('InvalidArgumentException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('InvalidArgumentException');
|
||||||
$this->createOperation(
|
$this->createOperation(
|
||||||
new MessageCatalogue('en'),
|
new MessageCatalogue('en'),
|
||||||
new MessageCatalogue('en')
|
new MessageCatalogue('en')
|
||||||
|
@ -62,7 +62,14 @@ class QtFileLoaderTest extends TestCase
|
|||||||
{
|
{
|
||||||
$loader = new QtFileLoader();
|
$loader = new QtFileLoader();
|
||||||
$resource = __DIR__.'/../fixtures/empty.xlf';
|
$resource = __DIR__.'/../fixtures/empty.xlf';
|
||||||
$this->setExpectedException('Symfony\Component\Translation\Exception\InvalidResourceException', sprintf('Unable to load "%s".', $resource));
|
|
||||||
|
if (method_exists($this, 'expectException')) {
|
||||||
|
$this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException');
|
||||||
|
$this->expectExceptionMessage(sprintf('Unable to load "%s".', $resource));
|
||||||
|
} else {
|
||||||
|
$this->setExpectedException('Symfony\Component\Translation\Exception\InvalidResourceException', sprintf('Unable to load "%s".', $resource));
|
||||||
|
}
|
||||||
|
|
||||||
$loader->load($resource, 'en', 'domain1');
|
$loader->load($resource, 'en', 'domain1');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,14 @@ class XliffFileLoaderTest extends TestCase
|
|||||||
{
|
{
|
||||||
$loader = new XliffFileLoader();
|
$loader = new XliffFileLoader();
|
||||||
$resource = __DIR__.'/../fixtures/empty.xlf';
|
$resource = __DIR__.'/../fixtures/empty.xlf';
|
||||||
$this->setExpectedException('Symfony\Component\Translation\Exception\InvalidResourceException', sprintf('Unable to load "%s":', $resource));
|
|
||||||
|
if (method_exists($this, 'expectException')) {
|
||||||
|
$this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException');
|
||||||
|
$this->expectExceptionMessage(sprintf('Unable to load "%s":', $resource));
|
||||||
|
} else {
|
||||||
|
$this->setExpectedException('Symfony\Component\Translation\Exception\InvalidResourceException', sprintf('Unable to load "%s":', $resource));
|
||||||
|
}
|
||||||
|
|
||||||
$loader->load($resource, 'en', 'domain1');
|
$loader->load($resource, 'en', 'domain1');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ class ConstraintTest extends TestCase
|
|||||||
|
|
||||||
public function testSetNotExistingPropertyThrowsException()
|
public function testSetNotExistingPropertyThrowsException()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('Symfony\Component\Validator\Exception\InvalidOptionsException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Validator\Exception\InvalidOptionsException');
|
||||||
|
|
||||||
new ConstraintA(array(
|
new ConstraintA(array(
|
||||||
'foo' => 'bar',
|
'foo' => 'bar',
|
||||||
@ -46,14 +46,14 @@ class ConstraintTest extends TestCase
|
|||||||
{
|
{
|
||||||
$constraint = new ConstraintA();
|
$constraint = new ConstraintA();
|
||||||
|
|
||||||
$this->setExpectedException('Symfony\Component\Validator\Exception\InvalidOptionsException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Validator\Exception\InvalidOptionsException');
|
||||||
|
|
||||||
$constraint->foo = 'bar';
|
$constraint->foo = 'bar';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testInvalidAndRequiredOptionsPassed()
|
public function testInvalidAndRequiredOptionsPassed()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('Symfony\Component\Validator\Exception\InvalidOptionsException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Validator\Exception\InvalidOptionsException');
|
||||||
|
|
||||||
new ConstraintC(array(
|
new ConstraintC(array(
|
||||||
'option1' => 'default',
|
'option1' => 'default',
|
||||||
@ -101,14 +101,14 @@ class ConstraintTest extends TestCase
|
|||||||
|
|
||||||
public function testSetUndefinedDefaultProperty()
|
public function testSetUndefinedDefaultProperty()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
|
||||||
|
|
||||||
new ConstraintB('foo');
|
new ConstraintB('foo');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRequiredOptionsMustBeDefined()
|
public function testRequiredOptionsMustBeDefined()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('Symfony\Component\Validator\Exception\MissingOptionsException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Validator\Exception\MissingOptionsException');
|
||||||
|
|
||||||
new ConstraintC();
|
new ConstraintC();
|
||||||
}
|
}
|
||||||
|
@ -39,14 +39,14 @@ class ClassMetadataTest extends TestCase
|
|||||||
|
|
||||||
public function testAddConstraintDoesNotAcceptValid()
|
public function testAddConstraintDoesNotAcceptValid()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
|
||||||
|
|
||||||
$this->metadata->addConstraint(new Valid());
|
$this->metadata->addConstraint(new Valid());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAddConstraintRequiresClassConstraints()
|
public function testAddConstraintRequiresClassConstraints()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
|
||||||
|
|
||||||
$this->metadata->addConstraint(new PropertyConstraint());
|
$this->metadata->addConstraint(new PropertyConstraint());
|
||||||
}
|
}
|
||||||
@ -249,14 +249,14 @@ class ClassMetadataTest extends TestCase
|
|||||||
|
|
||||||
public function testGroupSequencesFailIfNotContainingDefaultGroup()
|
public function testGroupSequencesFailIfNotContainingDefaultGroup()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('Symfony\Component\Validator\Exception\GroupDefinitionException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Validator\Exception\GroupDefinitionException');
|
||||||
|
|
||||||
$this->metadata->setGroupSequence(array('Foo', 'Bar'));
|
$this->metadata->setGroupSequence(array('Foo', 'Bar'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGroupSequencesFailIfContainingDefault()
|
public function testGroupSequencesFailIfContainingDefault()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('Symfony\Component\Validator\Exception\GroupDefinitionException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Validator\Exception\GroupDefinitionException');
|
||||||
|
|
||||||
$this->metadata->setGroupSequence(array('Foo', $this->metadata->getDefaultGroup(), Constraint::DEFAULT_GROUP));
|
$this->metadata->setGroupSequence(array('Foo', $this->metadata->getDefaultGroup(), Constraint::DEFAULT_GROUP));
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ class GetterMetadataTest extends TestCase
|
|||||||
|
|
||||||
public function testInvalidPropertyName()
|
public function testInvalidPropertyName()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('Symfony\Component\Validator\Exception\ValidatorException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Validator\Exception\ValidatorException');
|
||||||
|
|
||||||
new GetterMetadata(self::CLASSNAME, 'foobar');
|
new GetterMetadata(self::CLASSNAME, 'foobar');
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,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->setExpectedException('\Symfony\Component\Validator\Exception\MappingException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('\Symfony\Component\Validator\Exception\MappingException');
|
||||||
$loader->loadClassMetadata($metadata);
|
$loader->loadClassMetadata($metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ class XmlFileLoaderTest extends TestCase
|
|||||||
try {
|
try {
|
||||||
$loader->loadClassMetadata($metadata);
|
$loader->loadClassMetadata($metadata);
|
||||||
} catch (MappingException $e) {
|
} catch (MappingException $e) {
|
||||||
$this->setExpectedException('\Symfony\Component\Validator\Exception\MappingException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('\Symfony\Component\Validator\Exception\MappingException');
|
||||||
$loader->loadClassMetadata($metadata);
|
$loader->loadClassMetadata($metadata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,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->setExpectedException('\InvalidArgumentException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('\InvalidArgumentException');
|
||||||
$loader->loadClassMetadata($metadata);
|
$loader->loadClassMetadata($metadata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ class MemberMetadataTest extends TestCase
|
|||||||
|
|
||||||
public function testAddConstraintRequiresClassConstraints()
|
public function testAddConstraintRequiresClassConstraints()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
|
||||||
|
|
||||||
$this->metadata->addConstraint(new ClassConstraint());
|
$this->metadata->addConstraint(new ClassConstraint());
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ class PropertyMetadataTest extends TestCase
|
|||||||
|
|
||||||
public function testInvalidPropertyName()
|
public function testInvalidPropertyName()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('Symfony\Component\Validator\Exception\ValidatorException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Validator\Exception\ValidatorException');
|
||||||
|
|
||||||
new PropertyMetadata(self::CLASSNAME, 'foobar');
|
new PropertyMetadata(self::CLASSNAME, 'foobar');
|
||||||
}
|
}
|
||||||
@ -50,7 +50,7 @@ class PropertyMetadataTest extends TestCase
|
|||||||
$metadata = new PropertyMetadata(self::CLASSNAME, 'internal');
|
$metadata = new PropertyMetadata(self::CLASSNAME, 'internal');
|
||||||
$metadata->name = 'test';
|
$metadata->name = 'test';
|
||||||
|
|
||||||
$this->setExpectedException('Symfony\Component\Validator\Exception\ValidatorException');
|
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Validator\Exception\ValidatorException');
|
||||||
$metadata->getPropertyValue($entity);
|
$metadata->getPropertyValue($entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,11 @@ class TranslationFilesTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTranslationFileIsValid($filePath)
|
public function testTranslationFileIsValid($filePath)
|
||||||
{
|
{
|
||||||
\PHPUnit_Util_XML::loadfile($filePath, false, false, true);
|
if (class_exists('PHPUnit_Util_XML')) {
|
||||||
|
\PHPUnit_Util_XML::loadfile($filePath, false, false, true);
|
||||||
|
} else {
|
||||||
|
\PHPUnit\Util\XML::loadfile($filePath, false, false, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function provideTranslationFiles()
|
public function provideTranslationFiles()
|
||||||
|
@ -1084,10 +1084,12 @@ EOT
|
|||||||
*/
|
*/
|
||||||
public function testParserThrowsExceptionWithCorrectLineNumber($lineNumber, $yaml)
|
public function testParserThrowsExceptionWithCorrectLineNumber($lineNumber, $yaml)
|
||||||
{
|
{
|
||||||
$this->setExpectedException(
|
if (method_exists($this, 'expectException')) {
|
||||||
'\Symfony\Component\Yaml\Exception\ParseException',
|
$this->expectException('\Symfony\Component\Yaml\Exception\ParseException');
|
||||||
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