Example #1
0
 /**
  * testIsSuccess
  *
  * @covers \RcmUser\Result::isSuccess
  *
  * @return void
  */
 public function testIsSuccess()
 {
     $result = new Result(null, Result::CODE_SUCCESS, ['Test Message']);
     $data = 'SOMEDATA';
     $result->setCode(Result::CODE_SUCCESS);
     $this->assertTrue($result->isSuccess(), 'Success not returned.');
     $result->setCode(Result::CODE_FAIL);
     $this->assertFalse($result->isSuccess(), 'Success returned.');
 }
 /**
  * delete
  *
  * @param User  $user  user
  * @param array $roles roles
  *
  * @return Result
  */
 public function delete(User $user, $roles = [])
 {
     $failed = [];
     $result = new Result($failed, Result::CODE_SUCCESS);
     foreach ($roles as $key => $roleId) {
         $removeResult = $this->remove($user, $roleId);
         if (!$removeResult->isSuccess()) {
             $failed[] = $roleId;
             $result->setCode(Result::CODE_FAIL);
             $result->setMessage("Failed to remove role {$roleId} with error: " . $removeResult->getMessage());
             $result->setData($failed);
         } else {
             $result->setMessage("Removed role {$roleId}");
         }
     }
     return $result;
 }