public function testHasAssigned2RolePassAnObject() { $methodUserMock = $this->getMockBuilder('\\Magento\\Framework\\Model\\AbstractModel')->disableOriginalConstructor()->setMethods(['getUserId'])->getMock(); $returnData = [1, 2, 3]; $uid = 1234; $methodUserMock->expects($this->once())->method('getUserId')->willReturn($uid); $this->resourceMock->expects($this->once())->method('getConnection')->willReturn($this->dbAdapterMock); $this->dbAdapterMock->expects($this->once())->method('select')->willReturn($this->selectMock); $this->selectMock->expects($this->once())->method('from')->willReturn($this->selectMock); $this->selectMock->expects($this->atLeastOnce())->method('where')->willReturn($this->selectMock); $this->dbAdapterMock->expects($this->once())->method('fetchAll')->willReturn($returnData); $this->assertEquals($returnData, $this->model->hasAssigned2Role($methodUserMock)); }