/**
  * @param boolean $isRecordEnabled
  * @param array $expected
  * @dataProvider recordConditions
  */
 public function testGetRequestStatusDefinitionPermissions($isRecordEnabled, array $expected)
 {
     $this->record->expects($this->once())->method('getValue')->with('enabled')->willReturn($isRecordEnabled);
     $result = $this->actionPermissionProvider->getUserPermissions($this->record);
     $this->assertCount(count($this->actionsList), $result);
     foreach ($this->actionsList as $action) {
         $this->assertArrayHasKey($action, $result);
     }
     $this->assertEquals($expected, $result);
 }
 /**
  * @param array $inputData
  * @param array $expectedData
  *
  * @dataProvider getActionsProvider
  */
 public function testGetActions(array $inputData, array $expectedData)
 {
     $this->record->expects($this->any())->method('getValue')->with('id')->willReturn($inputData['record']['id']);
     $this->doctrine->expects($this->any())->method('getManagerForClass')->with($expectedData['class'])->willReturn($this->manager);
     $this->manager->expects($this->any())->method('getReference')->with($expectedData['class'], $expectedData['id'])->willReturn($inputData['object']);
     $this->securityFacade->expects($this->any())->method('isGranted')->willReturnCallback(function ($permission) use($inputData) {
         return $inputData['isGranted'][$permission];
     });
     $this->assertEquals($expectedData['actions'], $this->actionPermissionProvider->getActions($this->record, $inputData['config']));
 }
 /**
  * @param boolean  $isRolePredefined
  * @param boolean  $isGranted
  * @param array    $expected
  *
  * @dataProvider getAccountUserRolePermissionProvider
  */
 public function testGetAccountUserRolePermission($isRolePredefined, $isGranted, array $expected)
 {
     $this->record->expects($this->any())->method('getValue')->with($this->isType('string'))->willReturn($isRolePredefined);
     $this->securityFacade->expects($isRolePredefined ? $this->once() : $this->never())->method('isGranted')->with($this->isType('string'))->willReturn($isGranted);
     $result = $this->actionPermissionProvider->getAccountUserRolePermission($this->record);
     $this->assertCount(count($this->accountUserRoleActionList), $result);
     foreach ($this->accountUserRoleActionList as $action) {
         $this->assertArrayHasKey($action, $result);
     }
     $this->assertEquals($expected, $result);
 }
 /**
  * Test getRequestStatusDefinitionPermissions
  *
  * @dataProvider recordConditions
  * @param boolean $isRecordDeleted
  * @param string $name
  */
 public function testGetRequestStatusDefinitionPermissions($isRecordDeleted, $name)
 {
     $this->record->expects($this->at(0))->method('getValue')->with('deleted')->willReturn($isRecordDeleted);
     $this->record->expects($this->at(1))->method('getValue')->with('name')->willReturn($name);
     $result = $this->actionPermissionProvider->getRequestStatusDefinitionPermissions($this->record);
     $this->assertCount(count($this->actionsList), $result);
     foreach ($this->actionsList as $action) {
         $this->assertArrayHasKey($action, $result);
     }
     $isDefaultStatus = $name == self::CONFIG_DEFAULT_STATUS;
     $this->assertEquals($isRecordDeleted, $result['restore']);
     $this->assertEquals(!$isRecordDeleted && !$isDefaultStatus, $result['delete']);
     $this->assertTrue($result['view']);
 }