Example #1
0
 /**
  * @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->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());
     // 2, because of the admin role.
     $this->assertEquals(1, $role->users()->count());
     $this->assertContains('Role Name', $user->roles()->lists('name'));
     $this->assertEquals('User Name', $role->users()->first()->username);
 }