8000 Fixed mistake in exception expectation by uuf6429 · Pull Request #24557 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Fixed mistake in exception expectation #24557

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fixed mistake in exception expectation
  • Loading branch information
uuf6429 committed Oct 14, 2017
commit 03be003018a3d2734528e89ffbca6eb14e8f8f03
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,11 @@ public function testAssetsCanBeEnabled()
*/
public function testInvalidAssetsConfiguration(array $assetConfig, $expectedMessage)
{
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(
InvalidConfigurationException::class,
$expectedMessage
);
if (method_exists($this, 'expectExceptionMessage')) {
if (method_exists($this, 'expectException')) {
$this->expectException(InvalidConfigurationException::class);
$this->expectExceptionMessage($expectedMessage);
} else {
$this->setExpectedException(InvalidConfigurationException::class, $expectedMessage);
}

$processor = new Processor();
Expand Down
11 changes: 7 additions & 4 deletions src/Symfony/Component/Form/Tests/ButtonBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\ButtonBuilder;
use Symfony\Component\Form\Exception\InvalidArgumentException;

/**
* @author Alexander Cheprasov <cheprasov.84@ya.ru>
Expand Down Expand Up @@ -53,10 +54,12 @@ public function getInvalidNames()
*/
public function testInvalidNames($name)
{
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(
'\Symfony\Component\Form\Exception\InvalidArgumentException',
'Buttons cannot have empty names.'
);
if (method_exists($this, 'expectException')) {
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Buttons cannot have empty names.');
} else {
$this->setExpectedException(InvalidArgumentException::class, 'Buttons cannot have empty names.');
}
new ButtonBuilder($name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,12 @@ public function testReverseTransformWithEmptyFields()
'minutes' => '',
'seconds' => '6',
);
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(TransformationFailedException::class, 'This amount of "minutes" is invalid');
if (method_exists($this, 'expectException')) {
$this->expectException(TransformationFailedException::class);
$this->expectExceptionMessage('This amount of "minutes" is invalid');
} else {
$this->setExpectedException(TransformationFailedException::class, 'This amount of "minutes" is invalid');
}
$transformer->reverseTransform($input);
}

Expand All @@ -191,7 +196,12 @@ public function testReverseTransformWithWrongInvertType()
$input = array(
'invert' => '1',
);
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(TransformationFailedException::class, 'The value of "invert" must be boolean');
if (method_exists($this, 'expectException')) {
$this->expectException(TransformationFailedException::class);
$this->expectExceptionMessage('The value of "invert" must be boolean');
} else {
$this->setExpectedException(TransformationFailedException::class, 'The value of "invert" must be boolean');
}
$transformer->reverseTransform($input);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ public function testProcessFailedExceptionThrowsException()
->method('isSuccessful')
->will($this->returnValue(true));

$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(
'\InvalidArgumentException',
'Expected a failed process, but the given process was successful.'
);
if (method_exists($this, 'expectException')) {
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Expected a failed process, but the given process was successful.');
} else {
$this->setExpectedException(\InvalidArgumentException::class, 'Expected a failed process, but the given process was successful.');
}

new ProcessFailedException($process);
}
Expand Down
0