Exemple #1
0
 public function setUp()
 {
     parent::setUp();
     \Birdmin\Product::where('name', 'Test Product')->delete();
     Session::start();
     $this->be(User::find(1));
 }
 /**
  * Test basic user authorizations, with models.
  * This should deal directly with the ModelPolicy class.
  */
 public function test_basic_user_auth()
 {
     // User 2 has permission to do a couple things.
     $user = User::find(2);
     $this->assertTrue($user->hasRole(Role::getByName('Administrator')));
     // The models we'll test.
     $page = Page::find(1);
     $this->assertTrue($user->can('view', $page));
     $this->assertFalse($user->can('delete', $page));
     // User model is a managed class. The user doesn't have the manage permission.
     // So, They shouldn't be able to edit a user that doesn't belong to them.
     $testUser = User::find(1);
     $this->assertFalse($user->can('edit', $testUser));
     // But they can edit themselves.
     $this->assertTrue($user->can('edit', $user));
 }