minor #29899 Simplify PHPUnit exception expectations (fabpot)
This PR was merged into the 4.3-dev branch.
Discussion
----------
Simplify PHPUnit exception expectations
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks? | no <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass? | yes <!-- please add some, will be required by reviewers -->
| Fixed tickets | n/a
| License | MIT
| Doc PR | n/a
<!--
Write a short README entry for your feature/bugfix here (replace this comment block.)
This will help people understand your PR and can be used as a start of the Doc PR.
Additionally:
- Bug fixes must be submitted against the lowest branch where they apply
(lowest branches are regularly merged to upper ones so they get the fixes too).
- Features and deprecations must be submitted against the master branch.
-->
Commits
-------
eb75781ccd
simplified PHPUnit exception expectations
This commit is contained in:
commit
18fb7f87d4
@ -105,7 +105,7 @@ class EntityUserProviderTest extends TestCase
|
||||
$user1 = new User(null, null, 'user1');
|
||||
$provider = new EntityUserProvider($this->getManager($em), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User', 'name');
|
||||
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(
|
||||
$this->expectException(
|
||||
'InvalidArgumentException',
|
||||
'You cannot refresh a user from the EntityUserProvider that does not contain an identifier. The user object has to be serialized with its own identifier mapped by Doctrine'
|
||||
);
|
||||
@ -125,7 +125,7 @@ class EntityUserProviderTest extends TestCase
|
||||
$provider = new EntityUserProvider($this->getManager($em), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User', 'name');
|
||||
|
||||
$user2 = new User(1, 2, 'user2');
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(
|
||||
$this->expectException(
|
||||
'Symfony\Component\Security\Core\Exception\UsernameNotFoundException',
|
||||
'User with id {"id1":1,"id2":2} not found'
|
||||
);
|
||||
|
@ -103,7 +103,7 @@ class CookieTest extends TestCase
|
||||
|
||||
public function testFromStringThrowsAnExceptionIfCookieIsNotValid()
|
||||
{
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('InvalidArgumentException');
|
||||
$this->expectException('InvalidArgumentException');
|
||||
Cookie::fromString('foo');
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ class CookieTest extends TestCase
|
||||
|
||||
public function testFromStringThrowsAnExceptionIfUrlIsNotValid()
|
||||
{
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('InvalidArgumentException');
|
||||
$this->expectException('InvalidArgumentException');
|
||||
Cookie::fromString('foo=bar', 'foobar');
|
||||
}
|
||||
|
||||
|
@ -188,7 +188,7 @@ class CommandTest extends TestCase
|
||||
public function testSetAliasesNull()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('InvalidArgumentException');
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$command->setAliases(null);
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ class OutputFormatterStyleTest extends TestCase
|
||||
$style->setForeground('default');
|
||||
$this->assertEquals("\033[39mfoo\033[39m", $style->apply('foo'));
|
||||
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('InvalidArgumentException');
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$style->setForeground('undefined-color');
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ class OutputFormatterStyleTest extends TestCase
|
||||
$style->setBackground('default');
|
||||
$this->assertEquals("\033[49mfoo\033[49m", $style->apply('foo'));
|
||||
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('InvalidArgumentException');
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$style->setBackground('undefined-color');
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ class ParserTest extends TestCase
|
||||
|
||||
/** @var FunctionNode $function */
|
||||
$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());
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ class TokenStreamTest extends TestCase
|
||||
|
||||
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->push(new Token(Token::TYPE_DELIMITER, '.', 2));
|
||||
@ -73,7 +73,7 @@ class TokenStreamTest extends TestCase
|
||||
|
||||
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->push(new Token(Token::TYPE_DELIMITER, '.', 2));
|
||||
|
@ -1008,7 +1008,7 @@ class ContainerBuilderTest extends TestCase
|
||||
$container->registerExtension($extension = new \ProjectExtension());
|
||||
$this->assertSame($container->getExtension('project'), $extension, '->registerExtension() registers an extension');
|
||||
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('LogicException');
|
||||
$this->expectException('LogicException');
|
||||
$container->getExtension('no_registered');
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ class GenericEventTest extends TestCase
|
||||
$this->assertEquals('Event', $this->event['name']);
|
||||
|
||||
// test getting invalid arg
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('InvalidArgumentException');
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->assertFalse($this->event['nameNotExist']);
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,7 @@ class DateIntervalToArrayTransformerTest extends DateIntervalTestCase
|
||||
{
|
||||
$transformer = new DateIntervalToArrayTransformer();
|
||||
$this->assertNull($transformer->reverseTransform(null));
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(UnexpectedTypeException::class);
|
||||
$this->expectException(UnexpectedTypeException::class);
|
||||
$transformer->reverseTransform('12345');
|
||||
}
|
||||
|
||||
@ -184,7 +184,7 @@ class DateIntervalToArrayTransformerTest extends DateIntervalTestCase
|
||||
{
|
||||
$transformer = new DateIntervalToArrayTransformer();
|
||||
$input = array('years' => '1');
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(TransformationFailedException::class);
|
||||
$this->expectException(TransformationFailedException::class);
|
||||
$transformer->reverseTransform($input);
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ class DateIntervalToStringTransformerTest extends DateIntervalTestCase
|
||||
public function testTransformExpectsDateTime()
|
||||
{
|
||||
$transformer = new DateIntervalToStringTransformer();
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(UnexpectedTypeException::class);
|
||||
$this->expectException(UnexpectedTypeException::class);
|
||||
$transformer->transform('1234');
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ class DateIntervalToStringTransformerTest extends DateIntervalTestCase
|
||||
{
|
||||
$reverseTransformer = new DateIntervalToStringTransformer($format, true);
|
||||
$interval = new \DateInterval($output);
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(TransformationFailedException::class);
|
||||
$this->expectException(TransformationFailedException::class);
|
||||
$this->assertDateIntervalEquals($interval, $reverseTransformer->reverseTransform($input));
|
||||
}
|
||||
|
||||
@ -109,14 +109,14 @@ class DateIntervalToStringTransformerTest extends DateIntervalTestCase
|
||||
public function testReverseTransformExpectsString()
|
||||
{
|
||||
$reverseTransformer = new DateIntervalToStringTransformer();
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(UnexpectedTypeException::class);
|
||||
$this->expectException(UnexpectedTypeException::class);
|
||||
$reverseTransformer->reverseTransform(1234);
|
||||
}
|
||||
|
||||
public function testReverseTransformExpectsValidIntervalString()
|
||||
{
|
||||
$reverseTransformer = new DateIntervalToStringTransformer();
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(TransformationFailedException::class);
|
||||
$this->expectException(TransformationFailedException::class);
|
||||
$reverseTransformer->reverseTransform('10Y');
|
||||
}
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ class DateTimeToLocalizedStringTransformerTest extends TestCase
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ class DateTimeToStringTransformerTest extends TestCase
|
||||
{
|
||||
$transformer = new DateTimeToStringTransformer();
|
||||
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||
|
||||
$transformer->transform('1234');
|
||||
}
|
||||
@ -150,7 +150,7 @@ class DateTimeToStringTransformerTest extends TestCase
|
||||
{
|
||||
$reverseTransformer = new DateTimeToStringTransformer();
|
||||
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||
|
||||
$reverseTransformer->reverseTransform(1234);
|
||||
}
|
||||
@ -159,7 +159,7 @@ class DateTimeToStringTransformerTest extends TestCase
|
||||
{
|
||||
$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');
|
||||
}
|
||||
@ -168,7 +168,7 @@ class DateTimeToStringTransformerTest extends TestCase
|
||||
{
|
||||
$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');
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ class DateTimeToTimestampTransformerTest extends TestCase
|
||||
{
|
||||
$transformer = new DateTimeToTimestampTransformer();
|
||||
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||
|
||||
$transformer->transform('1234');
|
||||
}
|
||||
@ -109,7 +109,7 @@ class DateTimeToTimestampTransformerTest extends TestCase
|
||||
{
|
||||
$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');
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ class MoneyToLocalizedStringTransformerTest extends TestCase
|
||||
{
|
||||
$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');
|
||||
}
|
||||
@ -61,7 +61,7 @@ class MoneyToLocalizedStringTransformerTest extends TestCase
|
||||
{
|
||||
$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);
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase
|
||||
{
|
||||
$transformer = new PercentToLocalizedStringTransformer();
|
||||
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||
|
||||
$transformer->transform('foo');
|
||||
}
|
||||
@ -115,7 +115,7 @@ class PercentToLocalizedStringTransformerTest extends TestCase
|
||||
{
|
||||
$transformer = new PercentToLocalizedStringTransformer();
|
||||
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
|
||||
|
||||
$transformer->reverseTransform(1);
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ class CollectionTypeTest extends BaseTypeTest
|
||||
$form = $this->factory->create(static::TESTED_TYPE, null, array(
|
||||
'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());
|
||||
}
|
||||
|
||||
|
@ -51,13 +51,13 @@ class FormBuilderTest extends TestCase
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ class FileTest extends TestCase
|
||||
|
||||
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');
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ class MimeTypeTest extends TestCase
|
||||
|
||||
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');
|
||||
}
|
||||
@ -53,7 +53,7 @@ class MimeTypeTest extends TestCase
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ class MimeTypeTest extends TestCase
|
||||
@chmod($path, 0333);
|
||||
|
||||
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);
|
||||
} else {
|
||||
$this->markTestSkipped('Can not verify chmod operations, change of file permissions failed');
|
||||
|
@ -33,7 +33,7 @@ class UploadedFileTest extends TestCase
|
||||
|
||||
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(
|
||||
__DIR__.'/Fixtures/not_here',
|
||||
|
@ -30,7 +30,7 @@ class FileLocatorTest extends TestCase
|
||||
$kernel
|
||||
->expects($this->never())
|
||||
->method('locateResource');
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('LogicException');
|
||||
$this->expectException('LogicException');
|
||||
$locator->locate('/some/path');
|
||||
}
|
||||
|
||||
|
@ -329,7 +329,7 @@ abstract class AbstractNumberFormatterTest extends TestCase
|
||||
$exceptionCode = 'PHPUnit_Framework_Error_Warning';
|
||||
}
|
||||
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}($exceptionCode);
|
||||
$this->expectException($exceptionCode);
|
||||
|
||||
$formatter->format($value, NumberFormatter::TYPE_CURRENCY);
|
||||
}
|
||||
@ -712,7 +712,7 @@ abstract class AbstractNumberFormatterTest extends TestCase
|
||||
$exceptionCode = 'PHPUnit_Framework_Error_Warning';
|
||||
}
|
||||
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}($exceptionCode);
|
||||
$this->expectException($exceptionCode);
|
||||
|
||||
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
||||
$formatter->parse('1', NumberFormatter::TYPE_DEFAULT);
|
||||
@ -838,7 +838,7 @@ abstract class AbstractNumberFormatterTest extends TestCase
|
||||
$exceptionCode = 'PHPUnit_Framework_Error_Warning';
|
||||
}
|
||||
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}($exceptionCode);
|
||||
$this->expectException($exceptionCode);
|
||||
|
||||
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
||||
$formatter->parse('1', NumberFormatter::TYPE_CURRENCY);
|
||||
|
@ -74,7 +74,7 @@ class AdapterTest extends LdapTestCase
|
||||
public function testLdapQueryWithoutBind()
|
||||
{
|
||||
$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))', array());
|
||||
$query->execute();
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ class LdapManagerTest extends LdapTestCase
|
||||
*/
|
||||
public function testLdapAddInvalidEntry()
|
||||
{
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(LdapException::class);
|
||||
$this->expectException(LdapException::class);
|
||||
$this->executeSearchQuery(1);
|
||||
|
||||
// The entry is missing a subject name
|
||||
@ -107,7 +107,7 @@ class LdapManagerTest extends LdapTestCase
|
||||
public function testLdapUnboundAdd()
|
||||
{
|
||||
$this->adapter = new Adapter($this->getLdapConfig());
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(NotBoundException::class);
|
||||
$this->expectException(NotBoundException::class);
|
||||
$em = $this->adapter->getEntryManager();
|
||||
$em->add(new Entry(''));
|
||||
}
|
||||
@ -118,7 +118,7 @@ class LdapManagerTest extends LdapTestCase
|
||||
public function testLdapUnboundRemove()
|
||||
{
|
||||
$this->adapter = new Adapter($this->getLdapConfig());
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(NotBoundException::class);
|
||||
$this->expectException(NotBoundException::class);
|
||||
$em = $this->adapter->getEntryManager();
|
||||
$em->remove(new Entry(''));
|
||||
}
|
||||
@ -129,7 +129,7 @@ class LdapManagerTest extends LdapTestCase
|
||||
public function testLdapUnboundUpdate()
|
||||
{
|
||||
$this->adapter = new Adapter($this->getLdapConfig());
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(NotBoundException::class);
|
||||
$this->expectException(NotBoundException::class);
|
||||
$em = $this->adapter->getEntryManager();
|
||||
$em->update(new Entry(''));
|
||||
}
|
||||
@ -224,7 +224,7 @@ class LdapManagerTest extends LdapTestCase
|
||||
$result = $this->executeSearchQuery(1);
|
||||
$entry = $result[0];
|
||||
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(LdapException::class);
|
||||
$this->expectException(LdapException::class);
|
||||
|
||||
$entryManager->removeAttributeValues($entry, 'mail', array('fabpot@example.org'));
|
||||
}
|
||||
@ -236,7 +236,7 @@ class LdapManagerTest extends LdapTestCase
|
||||
$result = $this->executeSearchQuery(1);
|
||||
$entry = $result[0];
|
||||
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(LdapException::class);
|
||||
$this->expectException(LdapException::class);
|
||||
|
||||
$entryManager->addAttributeValues($entry, 'mail', $entry->getAttribute('mail'));
|
||||
}
|
||||
@ -248,7 +248,7 @@ class LdapManagerTest extends LdapTestCase
|
||||
$result = $this->executeSearchQuery(1);
|
||||
$entry = $result[0];
|
||||
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(UpdateOperationException::class);
|
||||
$this->expectException(UpdateOperationException::class);
|
||||
|
||||
$entryManager->applyOperations($entry->getDn(), array(new UpdateOperation(LDAP_MODIFY_BATCH_REMOVE_ALL, 'mail', array())));
|
||||
}
|
||||
@ -260,7 +260,7 @@ class LdapManagerTest extends LdapTestCase
|
||||
$result = $this->executeSearchQuery(1);
|
||||
$entry = $result[0];
|
||||
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(UpdateOperationException::class);
|
||||
$this->expectException(UpdateOperationException::class);
|
||||
|
||||
$entryManager->applyOperations($entry->getDn(), array(new UpdateOperation(512, 'mail', array())));
|
||||
}
|
||||
@ -337,7 +337,7 @@ class LdapManagerTest extends LdapTestCase
|
||||
$result = $this->executeSearchQuery(1);
|
||||
$entry = $result[0];
|
||||
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(UpdateOperationException::class);
|
||||
$this->expectException(UpdateOperationException::class);
|
||||
|
||||
$entryManager->applyOperations($entry->getDn(), $duplicateIterator);
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ class LdapTest extends TestCase
|
||||
|
||||
public function testCreateWithInvalidAdapterName()
|
||||
{
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(DriverNotFoundException::class);
|
||||
$this->expectException(DriverNotFoundException::class);
|
||||
Ldap::create('foo');
|
||||
}
|
||||
}
|
||||
|
@ -368,7 +368,7 @@ class UrlGeneratorTest extends TestCase
|
||||
|
||||
// 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.
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Routing\Exception\InvalidParameterException');
|
||||
$this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException');
|
||||
$generator->generate('test', array('x' => 'do.t', 'y' => '123', 'z' => 'bar', '_format' => 'xml'));
|
||||
}
|
||||
|
||||
|
@ -231,7 +231,7 @@ class UrlMatcherTest extends TestCase
|
||||
$matcher = $this->getUrlMatcher($collection);
|
||||
|
||||
$this->assertEquals(array('_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(array(), $matcher->match('/foo'));
|
||||
}
|
||||
|
||||
@ -300,7 +300,7 @@ class UrlMatcherTest extends TestCase
|
||||
// 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->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Routing\Exception\ResourceNotFoundException');
|
||||
$this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException');
|
||||
$matcher->match('/wxy.html');
|
||||
}
|
||||
|
||||
@ -315,7 +315,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.
|
||||
// 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');
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ class PhpEngineTest extends TestCase
|
||||
$foo = new \Symfony\Component\Templating\Tests\Fixtures\SimpleHelper('foo');
|
||||
$engine->set($foo);
|
||||
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('\LogicException');
|
||||
$this->expectException('\LogicException');
|
||||
|
||||
unset($engine['foo']);
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ abstract class AbstractOperationTest extends TestCase
|
||||
|
||||
public function testGetMessagesFromUnknownDomain()
|
||||
{
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('InvalidArgumentException');
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->createOperation(
|
||||
new MessageCatalogue('en'),
|
||||
new MessageCatalogue('en')
|
||||
|
@ -35,7 +35,7 @@ class ConstraintTest extends TestCase
|
||||
|
||||
public function testSetNotExistingPropertyThrowsException()
|
||||
{
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Validator\Exception\InvalidOptionsException');
|
||||
$this->expectException('Symfony\Component\Validator\Exception\InvalidOptionsException');
|
||||
|
||||
new ConstraintA(array(
|
||||
'foo' => 'bar',
|
||||
@ -46,14 +46,14 @@ class ConstraintTest extends TestCase
|
||||
{
|
||||
$constraint = new ConstraintA();
|
||||
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Validator\Exception\InvalidOptionsException');
|
||||
$this->expectException('Symfony\Component\Validator\Exception\InvalidOptionsException');
|
||||
|
||||
$constraint->foo = 'bar';
|
||||
}
|
||||
|
||||
public function testInvalidAndRequiredOptionsPassed()
|
||||
{
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Validator\Exception\InvalidOptionsException');
|
||||
$this->expectException('Symfony\Component\Validator\Exception\InvalidOptionsException');
|
||||
|
||||
new ConstraintC(array(
|
||||
'option1' => 'default',
|
||||
@ -101,14 +101,14 @@ class ConstraintTest extends TestCase
|
||||
|
||||
public function testSetUndefinedDefaultProperty()
|
||||
{
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
|
||||
$this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
|
||||
|
||||
new ConstraintB('foo');
|
||||
}
|
||||
|
||||
public function testRequiredOptionsMustBeDefined()
|
||||
{
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Validator\Exception\MissingOptionsException');
|
||||
$this->expectException('Symfony\Component\Validator\Exception\MissingOptionsException');
|
||||
|
||||
new ConstraintC();
|
||||
}
|
||||
|
@ -40,14 +40,14 @@ class ClassMetadataTest extends TestCase
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ class GetterMetadataTest extends TestCase
|
||||
|
||||
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');
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ class XmlFileLoaderTest extends TestCase
|
||||
$loader = new XmlFileLoader(__DIR__.'/withdoctype.xml');
|
||||
$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);
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ class XmlFileLoaderTest extends TestCase
|
||||
try {
|
||||
$loader->loadClassMetadata($metadata);
|
||||
} catch (MappingException $e) {
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('\Symfony\Component\Validator\Exception\MappingException');
|
||||
$this->expectException('\Symfony\Component\Validator\Exception\MappingException');
|
||||
$loader->loadClassMetadata($metadata);
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ class YamlFileLoaderTest extends TestCase
|
||||
$loader->loadClassMetadata($metadata);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
// Call again. Again an exception should be thrown
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('\InvalidArgumentException');
|
||||
$this->expectException('\InvalidArgumentException');
|
||||
$loader->loadClassMetadata($metadata);
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ class MemberMetadataTest extends TestCase
|
||||
|
||||
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());
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ class PropertyMetadataTest extends TestCase
|
||||
|
||||
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');
|
||||
}
|
||||
@ -50,7 +50,7 @@ class PropertyMetadataTest extends TestCase
|
||||
$metadata = new PropertyMetadata(self::CLASSNAME, 'internal');
|
||||
$metadata->name = 'test';
|
||||
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Validator\Exception\ValidatorException');
|
||||
$this->expectException('Symfony\Component\Validator\Exception\ValidatorException');
|
||||
$metadata->getPropertyValue($entity);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user