Got the same Question. There must be an Method to catch that Exception like $I->seeException(...)
I too am having issues with this, does anybody have any ideas?
Up!
Here a workaround... but it's not really perfect:
<php
$I = new FunctionalTester($scenario);
//...
$document = Document::first();
// NOTE: App::error() doesn't seem to work with Codeception
// So we need this try catch:
try {
$I->amOnPage("/documents/".$document->id);
} catch (Efficiently\AuthorityController\Exceptions\AccessDenied $e) {
$message = $e->getMessage();
Session::flash('error', $message);
$I->amOnPage('/');
}
$I->seeCurrentUrlEquals('/');
$I->seeSessionHasValues(['error' => 'You are not authorized to access this page.']);
If someone has a better solution, it'll be really helpful!
NB: I mention this issue in the Testing Authority-Controller rules wiki page: https://github.com/efficiently/authority-controller/wiki/Testing-Authority-rules#codeception-and-laravel-exceptions
There is also a closed issue on the Codeception Github page, but the issue still occurs...
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.