Esempio n. 1
0
 /**
  * Test method getRoleUsers()
  */
 public function testGetRoleUsers()
 {
     $this->_ruleResource->expects($this->once())->method('saveResources')->withAnyParameters()->will($this->returnSelf());
     $model = $this->_createModel($this->_ruleResource);
     $result = $model->saveResources();
     $this->assertInstanceOf('Mage_Webapi_Model_Acl_Rule', $result);
 }
Esempio n. 2
0
 /**
  * Test for Mage_Webapi_Model_Authorization_Loader_Rule::populateAcl without rules
  */
 public function testPopulateAclWithoutRules()
 {
     $this->_ruleResource->expects($this->once())->method('getRuleList')->will($this->returnValue(array()));
     $this->_acl->expects($this->never())->method('has');
     $this->_acl->expects($this->never())->method('hasRole');
     $this->_acl->expects($this->never())->method('allow');
     $this->_model->populateAcl($this->_acl);
 }
Esempio n. 3
0
 /**
  * Test isEverythingAllowed method
  *
  * @dataProvider isEverythingAllowedDataProvider
  * @param array $selectedResources
  * @param bool $expectedResult
  */
 public function testIsEverythingAllowed($selectedResources, $expectedResult)
 {
     $apiRole = new Varien_Object(array('role_id' => 1));
     $apiRole->setIdFieldName('role_id');
     $this->_block->setApiRole($apiRole);
     $this->_ruleResource->expects($this->once())->method('getResourceIdsByRole')->with($apiRole->getId())->will($this->returnValue($selectedResources));
     $this->assertEquals($expectedResult, $this->_block->isEverythingAllowed());
 }
Esempio n. 4
0
 /**
  * Test _prepareForm method
  *
  * @dataProvider prepareFormDataProvider
  * @param array $originResTree
  * @param array $selectedRes
  * @param array $expectedRes
  */
 public function testPrepareForm($originResTree, $selectedRes, $expectedRes)
 {
     // TODO Move to unit tests after MAGETWO-4015 complete
     $apiRole = new Varien_Object(array('role_id' => 1));
     $apiRole->setIdFieldName('role_id');
     $this->_block->setApiRole($apiRole);
     $this->_authorizationConfig->expects($this->once())->method('getAclResourcesAsArray')->with(false)->will($this->returnValue($originResTree));
     $this->_ruleResource->expects($this->once())->method('getResourceIdsByRole')->with($apiRole->getId())->will($this->returnValue($selectedRes));
     $this->_block->toHtml();
     $this->assertEquals($expectedRes, $this->_block->getResourcesTree());
 }