Closed sdustinh closed 5 years ago
Do you guys think this is a safe thing to include in my test bootstrap? Would it make any of my tests unreliable from the framework perspective?
Yes it is safe. It shouldn't make tests unreliable.
If not, should this be something that is included in the skeleton test bootstrap?
It could. We could also change the error handlers to not be registered inside of an environment that is within phpunit.
I'm not sure that this is a real consideration or not but I just wanted to note it for any development on this issue. Once this change was done, if there were errors that existed in previously passing builds they will now cause your build to fail. So, if this is incorporated into the error handlers themselves it should probably be noted in the migration notes.
@sdustinh As this is the skeleton app and normally just the starting point of a new application ,the changes should be fine :)
@cleptric Affirm. @markstory just commented that this might be better suited in the error handler classes so I just wanted to note if that was the solution (which I'm :+1: for!) then there should be a note of the consequences on the migration guide.
Updating the app skeleton will certainly be easier than changing the error handlers.
Closing as the issue has gone stale.
I'm experiencing the very same problem, however the solution of adding restore_error_handler()
to tests/bootstrap.php
doesn't solve it. Should this issue be reopened or is creating a new one a better option?
Reopening the issue won't do any good if it's going to stay unresolved for months as earlier. It would be better if someone come's up with a solution and opens a pull request instead.
OK, sure. If I only manage to solve it, I'll send the PR :)
This is a (multiple allowed):
What you did
Ran unit tests with
vendor/bin/phpunit
. With the following action:What happened
What you expected to happen
So, this has been a problem for a while and I finally had a minute to track down what was causing it. Our CI would report a build as successful despite errors being triggered. I read up on the PHPUnit documentation about converting errors to exceptions so that the tests would fail as expected but I couldn't figure out exactly why a notice would be displayed and the tests would still be flagged as passing. I sifted through my
app.php
which lead me to the BaseErrorHandler.I was able to get the expected results by adding the following to my
tests/bootstrap.php
:restore_error_handler();
Do you guys think this is a safe thing to include in my test bootstrap? Would it make any of my tests unreliable from the framework perspective? If not, should this be something that is included in the skeleton test bootstrap?