selectMock = $this->createMock(\Magento\Framework\DB\Select::class); $this->selectMock->expects($this->any())->method('from')->will($this->returnValue($this->selectMock)); $this->selectMock->expects($this->any())->method('where')->will($this->returnValue($this->selectMock)); $this->connectionMock = $this->createMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class); $this->connectionMock->expects($this->any())->method('select')->willReturn($this->selectMock); $this->resourceMock = $this->createMock(\Magento\Framework\App\ResourceConnection::class); $this->resourceMock->expects($this->any())->method('getConnection')->willReturn($this->connectionMock); $this->contextMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\Context::class); $this->contextMock->expects($this->once())->method('getResources')->willReturn($this->resourceMock); $this->integrationResourceModel = new \Magento\Integration\Model\ResourceModel\Integration($this->contextMock); } public function testSelectActiveIntegrationByConsumerId() { $consumerId = 1; $this->connectionMock->expects($this->once())->method('fetchRow')->with($this->selectMock); $this->integrationResourceModel->selectActiveIntegrationByConsumerId($consumerId); } }