Ejemplo n.º 1
0
 public function testCheckAccess()
 {
     $results = ['reader A' => ['createPost' => false, 'readPost' => true, 'updatePost' => false, 'updateOwnPost' => false, 'deletePost' => false], 'author B' => ['createPost' => true, 'readPost' => true, 'updatePost' => true, 'updateOwnPost' => true, 'deletePost' => false], 'editor C' => ['createPost' => false, 'readPost' => true, 'updatePost' => true, 'updateOwnPost' => false, 'deletePost' => false], 'admin D' => ['createPost' => true, 'readPost' => true, 'updatePost' => true, 'updateOwnPost' => false, 'deletePost' => true], 'reader E' => ['createPost' => false, 'readPost' => false, 'updatePost' => false, 'updateOwnPost' => false, 'deletePost' => false]];
     $params = ['authorID' => 'author B'];
     foreach (['reader A', 'author B', 'editor C', 'admin D'] as $user) {
         $params['userID'] = $user;
         foreach (['createPost', 'readPost', 'updatePost', 'updateOwnPost', 'deletePost'] as $operation) {
             $result = $this->auth->checkAccess($user, $operation, $params);
             $this->assertEquals($results[$user][$operation], $result);
         }
     }
 }