コード例 #1
0
 public function testToOptionArray()
 {
     $this->assertNotEmpty($this->_collection->toOptionArray());
     foreach ($this->_collection->toOptionArray() as $item) {
         $this->assertArrayHasKey('value', $item);
         $this->assertArrayHasKey('label', $item);
     }
 }
コード例 #2
0
 protected function setUp()
 {
     $this->_objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
     $userId = 'userId';
     $userType = 'userType';
     $this->userContext = $this->getMockBuilder('Magento\\Authorization\\Model\\CompositeUserContext')->disableOriginalConstructor()->setMethods(['getUserId', 'getUserType'])->getMock();
     $this->userContext->expects($this->once())->method('getUserId')->will($this->returnValue($userId));
     $this->userContext->expects($this->once())->method('getUserType')->will($this->returnValue($userType));
     $this->roleCollectionFactory = $this->getMockBuilder('Magento\\Authorization\\Model\\Resource\\Role\\CollectionFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->roleCollection = $this->getMockBuilder('Magento\\Authorization\\Model\\Resource\\Role\\Collection')->disableOriginalConstructor()->setMethods(['setUserFilter', 'getFirstItem'])->getMock();
     $this->roleCollectionFactory->expects($this->once())->method('create')->will($this->returnValue($this->roleCollection));
     $this->roleCollection->expects($this->once())->method('setUserFilter')->with($userId, $userType)->will($this->returnValue($this->roleCollection));
     $this->role = $this->getMockBuilder('Magento\\Authorization\\Model\\Role')->disableOriginalConstructor()->setMethods(['getId', '__wakeup'])->getMock();
     $this->roleCollection->expects($this->once())->method('getFirstItem')->will($this->returnValue($this->role));
     $this->locator = $this->_objectManager->getObject('Magento\\Webapi\\Model\\WebapiRoleLocator', ['userContext' => $this->userContext, 'roleCollectionFactory' => $this->roleCollectionFactory]);
 }
コード例 #3
0
 /**
  * Prepare select for load
  *
  * @return $this
  */
 protected function _initSelect()
 {
     parent::_initSelect();
     $this->addFieldToFilter('role_type', RoleGroup::ROLE_TYPE);
     return $this;
 }