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
cannot expect empty exception message #2731
cannot expect empty exception message #2731
Comments
i can't reproduce them. This code work fine: <?php
class Example
{
public function foo()
{
throw new \Exception('');
}
}
class ExampleTest extends PHPUnit_Framework_TestCase
{
public function testFoo()
{
$this->expectExceptionMessage('');
(new \Example())->foo();
}
} But i find another error. <?php
class Example
{
public function foo()
{
throw new \Exception('One');
}
}
class ExampleTest extends PHPUnit_Framework_TestCase
{
public function testFoo()
{
$this->expectExceptionMessage('');
(new \Example())->foo();
}
} |
it's not throwing error because |
<?php
class Test extends PHPUnit\Framework\TestCase
{
public function testOne()
{
$this->expectExceptionMessage('message');
}
} Before 6727744 the above would result in
I found that confusing and have changed it to
now. |
I probably/subconsciously fixed this issue as part of 6727744. |
@sebastianbergmann is 5.x line closed? bug is there since 5.x |
I'll look into backporting this to PHPUnit 5.7 (which still gets bug fixes until February 2018). |
damn, it's hard to track changes when they are commited directly to branch... :( |
Notice that empty exception can be test without any change
This fix in 5.7 introduce a BC break in how See |
I do know it's an edge case, but today I wanted to ensure that exception was raised with empty message:
sadly, it's not working - it behaves like method is not called at all.
reason is here:
https://github.com/sebastianbergmann/phpunit/blob/5.7/src/Framework/TestCase.php#L1089
setting up the value with
null
and with empty string are treated the same way.IMO, only null shall be checked there
The text was updated successfully, but these errors were encountered: