Esempio n. 1
0
 public function testRoleUserExists()
 {
     $methodUserMock = $this->getMockBuilder('\\Magento\\Framework\\Model\\AbstractModel')->disableOriginalConstructor()->setMethods(['getUserId', 'getRoleId'])->getMock();
     $uid = 1234;
     $roleId = 44;
     $returnData = [1, 2, 3];
     $methodUserMock->expects($this->atLeastOnce())->method('getUserId')->willReturn($uid);
     $this->resourceMock->expects($this->atLeastOnce())->method('getConnection')->willReturn($this->dbAdapterMock);
     $methodUserMock->expects($this->once())->method('getRoleId')->willReturn($roleId);
     $this->dbAdapterMock->expects($this->once())->method('select')->willReturn($this->selectMock);
     $this->selectMock->expects($this->atLeastOnce())->method('from')->willReturn($this->selectMock);
     $this->selectMock->expects($this->atLeastOnce())->method('where')->willReturn($this->selectMock);
     $this->dbAdapterMock->expects($this->once())->method('fetchCol')->willReturn($returnData);
     $this->assertEquals($returnData, $this->model->roleUserExists($methodUserMock));
     $this->assertEquals([], $this->model->roleUserExists($this->userMock));
 }