I have inherited a large legacy app which has a laravel package written in Laravel 5.1. I am writing tests that use
$this->call('GET', 'my_route')
The tests execute fine but the exceptions being thrown in the tests are not being handled by the exception handler (which catches them and returns a JSON response). The exception handler is handling the exceptions correctly when using Postman.
The exception handler is being loaded in the base test file that my tests are extending using
$app->singleton(LaravelExceptionHandler::class, CustomExceptionHandler::class);
within the getEnvironmentSetUp
function. This is the same line of code being used in another packages service provider that is using this same exception handler in the same app. (again Postman requests work fine)
This same setup is working nicely in an unrelated non-legacy Laravel 5.1 project so I am thinking there is either another package interfering or there is some laravel function that is messing up the testing/console environment such as
set_error_handler();
set_exception_handler();
Im trying to locate the functions / env variables that can interfere with testing and the test environment as they could have been tampered with.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire