-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Implement getOriginalException #2678
Conversation
src/Framework/ExceptionWrapper.php
Outdated
*/ | ||
public function getOriginalException() | ||
{ | ||
return $this->originalException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whitespace found at end of line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this is why you don't use github to edit files. Fixing now.
@sebastianbergmann I'm not sure what here could have caused those tests to fail, since no regressions should have been introduced with this. Is this a widespread issue, or have I inadvertently done something bad? |
Example usecase: public function run(TestResult $result = null)
{
parent::run($result);
if ($result->errorCount() > 0) {
/**
* @var $error PHPUnit_Framework_TestFailure
*/
foreach ($result->errors() as $error) {
$exception = $error->thrownException();
if ($exception->getClassname() == ApiException::class) {
$exception = $exception->getOriginalException();
dump($exception->getErrors());
}
}
}
} This still causes phpunit to fail with the same exceptions, but instead of just saying:
it now says:
|
@sebastianbergmann Any chance I can get some feedback on this, and why it may have failed the tests? |
PHPUnit 6.2-ge79069e by Sebastian Bergmann and contributors. Runtime: PHP 7.1.5 with Xdebug 2.5.4 Configuration: /usr/local/src/phpunit/phpunit.xml ............................................................. 61 / 1543 ( 3%) ............................................................. 122 / 1543 ( 7%) ............................................................. 183 / 1543 ( 11%) ............................................................. 244 / 1543 ( 15%) ............................................................. 305 / 1543 ( 19%) ............................................................. 366 / 1543 ( 23%) ............................................................. 427 / 1543 ( 27%) ............................................................. 488 / 1543 ( 31%) ............................................................. 549 / 1543 ( 35%) ............................................................. 610 / 1543 ( 39%) ............................................................. 671 / 1543 ( 43%) ............................................................. 732 / 1543 ( 47%) ............................................................. 793 / 1543 ( 51%) ............................................................. 854 / 1543 ( 55%) ............................................................. 915 / 1543 ( 59%) ............................................................. 976 / 1543 ( 63%) ............................................................. 1037 / 1543 ( 67%) ............................................................. 1098 / 1543 ( 71%) ............................................................. 1159 / 1543 ( 75%) ............................................................. 1220 / 1543 ( 79%) ............................................................. 1281 / 1543 ( 83%) ............................................................. 1342 / 1543 ( 86%) ............................................................. 1403 / 1543 ( 90%) ............................................................. 1464 / 1543 ( 94%) ........................................F.................... 1525 / 1543 ( 98%) .................. 1543 / 1543 (100%) Time: 8.11 seconds, Memory: 14.00MB There was 1 failure: 1) /usr/local/src/phpunit/tests/Regression/GitHub/1351.phpt Failed asserting that string matches format description. --- Expected +++ Actual @@ @@ PHPUnit 6.2-ge79069e by Sebastian Bergmann and contributors. -F.E.E 5 / 5 (100%) +F.EFE 5 / 5 (100%) @@ @@ +/usr/local/src/phpunit/tests/Regression/GitHub/1351/Issue1351Test.php:32 + Caused by LogicException: Expected exception. -Caused by +/usr/local/src/phpunit/tests/Regression/GitHub/1351/Issue1351Test.php:30 + 2) Issue1351Test::testPhpCoreLanguageException PDOException: SQLSTATE[HY000]: General error: 1 no such table: php_wtf +/usr/local/src/phpunit/tests/Regression/GitHub/1351/Issue1351Test.php:48 -- -There was 1 failure: +There were 2 failures: 1) Issue1351Test::testFailurePre Expected failure. -There were 2 failures: +Failed asserting that true is false. + +/usr/local/src/phpunit/tests/Regression/GitHub/1351/Issue1351Test.php:14 + +2) Issue1351Test::testExceptionPost +ChildProcessClass1351 is not loaded. +Failed asserting that true is false. + +/usr/local/src/phpunit/tests/Regression/GitHub/1351/Issue1351Test.php:39 + ERRORS! -Tests: 5, Assertions: 5, Errors: 2, Failures: 1. +Tests: 5, Assertions: 5, Errors: 2, Failures: 2. /usr/local/src/phpunit/src/Framework/Constraint/Constraint.php:117 /usr/local/src/phpunit/src/Framework/Constraint/Constraint.php:62 /usr/local/src/phpunit/src/Framework/Assert.php:2116 /usr/local/src/phpunit/src/Framework/Assert.php:1768 /usr/local/src/phpunit/src/Runner/PhptTestCase.php:126 /usr/local/src/phpunit/src/Runner/PhptTestCase.php:204 /usr/local/src/phpunit/src/Framework/TestSuite.php:746 /usr/local/src/phpunit/src/Framework/TestSuite.php:746 /usr/local/src/phpunit/src/TextUI/TestRunner.php:541 /usr/local/src/phpunit/src/TextUI/Command.php:210 /usr/local/src/phpunit/src/TextUI/Command.php:141 FAILURES! Tests: 1543, Assertions: 2796, Failures: 1.
@alexbowers Please send a new pull request that fixes the test failure. |
@sebastianbergmann Is there a guide anywhere on how to run the tests locally? I get the following error:
|
You need to install PHPUnit's dependencies first. Have a look at https://github.com/sebastianbergmann/phpunit/blob/master/.github/CONTRIBUTING.md#running-phpunits-own-test-suite |
@sebastianbergmann That is the steps I followed, I still get the same error:
|
Ah. I have found the cause. On my machine, I have a folder The It has the autoload.php, it autoloads it all in, but what it is loading is the incorrect vendor folder. Is the order of these files here important, or should it not be If this package gets pulled into a different package, then it would not have its own vendor, which will cause it to not be found anyway. |
@sebastianbergmann I have looked, and can't see how the tests are failing. Is there any chance somebody with more knowledge of phpunits internals could have a look at them? |
@sebastianbergmann Any chance I could get assistance with fixing the issues this had? |
@sebastianbergmann Any chance I could get your assistance on this? Its a useful feature for us, and we have to currently use a fork since I couldn't resolve the issues you experienced. |
Is there anything we can do to implement it? |
@sebastianbergmann |
No description provided.