tests/UsersTest.php
/**
     * @testdox Users can have Roles, which we use to determine what they can do in the application.
     * @test
     */
@testdox Users can have Roles, which we use to determine what they can do in the application.
@test
@testdox Users can have Roles which we use to determine what they can do in the application . @test
public function roles()
    {
        $user = new User();
        $user->username = 'User Name';
        $user->save();
        $role = new \Ormic\Model\Role();
        $role->setUser($this->getTestUser());
        $role->name = 'Role Name';
        $role->save();
        $user->roles()->attach($role->id);
        $this->assertEquals(2, $user->roles()->count()); 
        $this->assertEquals(1, $role->users()->count());
        $this->assertContains('Role Name', $user->roles()->lists('name'));
        $this->assertEquals('User Name', $role->users()->first()->username);
    }
public function roles ( ) { $ user = new User ( ) ; $ user -> username = 'User Name' ; $ user -> save ( ) ; $ role = new \ Ormic \ Model \ Role ( ) ; $ role -> setUser ( $ this -> getTestUser ( ) ) ; $ role -> name = 'Role Name' ; $ role -> save ( ) ; $ user -> roles ( ) -> attach ( $ role -> id ) ; $ this -> assertEquals ( 2 , $ user -> roles ( ) -> count ( ) ) ; $ this -> assertEquals ( 1 , $ role -> users ( ) -> count ( ) ) ; $ this -> assertContains ( 'Role Name' , $ user -> roles ( ) -> lists ( 'name' ) ) ; $ this -> assertEquals ( 'User Name' , $ role -> users ( ) -> first ( ) -> username ) ; }
@testdox Users can have Roles, which we use to determine what they can do in the application.
@testdox Users can have Roles which we use to determine what they can do in the application .
// 2, because of the admin role.