Skip to content
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

Laravel-ACL doesn't work Codeception #206

Open
vjandrea opened this issue Mar 7, 2017 · 0 comments
Open

Laravel-ACL doesn't work Codeception #206

vjandrea opened this issue Mar 7, 2017 · 0 comments

Comments

@vjandrea
Copy link
Contributor

vjandrea commented Mar 7, 2017

Hello there,
i'm having trouble using Laravel-ACL's getRoles() in my Codeception tests. I can't figure out if it's a Laravel-ACL specific limit or it's related to the application handling in Codeception.
Here's the test i wrote:

$I = new FeatureTester($scenario);
$I->wantTo('see that Kodeine ACL works with Codeception');

// setup
$user = new User([
    'first_name' => 'Test', 
    'last_name' => 'User', 
    'email' => '[email protected]',
    'password' => 'reallysafe',
    ]);
$user->save();

$I->expect('that assignRole() works');
$user->assignRole('user');

$I->amGoingTo('verify if the role has been assigned in the db');
$user_role = Role::where('slug', 'user')->first();
$I->seeRecord('role_user', ['role_id' => $user_role->id, 'user_id' => $user->id]);

$I->expect('that getRoles returns "user"');
$I->assertEquals(['user'], $user->getRoles());

And this is the result

$ codecept run feature Kodeine_ACL_Cept.php
Codeception PHP Testing Framework v2.2.9
Powered by PHPUnit 5.7.14 by Sebastian Bergmann and contributors.

There was 1 failure:

1) Kodeine_ACL_Cept: See that kodeine acl works with codeception
 Test  tests/feature/Kodeine_ACL_Cept.php
 Step  Assert equals ["user"],[]
 Fail  Failed asserting that two arrays are equal.
- Expected | + Actual
@@ @@
Array (
-    0 => 'user'
)

Scenario Steps:

 5. $I->assertEquals(["user"],[]) at tests/feature/Kodeine_ACL_Cept.php:27
 4. // I expect that getRoles returns "user"
 3. $I->seeRecord("role_user",{"role_id":7,"user_id":49}) at tests/feature/Kodeine_ACL_Cept.php:24
 2. // I am going to verify if the role has been assigned in the db
 1. // I expect that assignRole() works

FAILURES!
Tests: 1, Assertions: 1, Failures: 1.

I am using the Laravel5 and Asserts helpers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant