Support the ongoing development of Laravel.io →
posted 10 years ago
Testing
Last updated 2 years ago.
0

Someone got any thoughts on this?

Last updated 2 years ago.
0

Got the same Question. There must be an Method to catch that Exception like $I->seeException(...)

Last updated 2 years ago.
0

I too am having issues with this, does anybody have any ideas?

Last updated 2 years ago.
0

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...

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

KarlPi karlpi Joined 20 Mar 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.