contextMock = $this->createPartialMock(Context::class, ['getEventDispatcher']); $eventManagerMock = $this->getMockForAbstractClass( ManagerInterface::class, [], '', false, true, true, ['dispatch'] ); $this->contextMock->expects($this->once()) ->method('getEventDispatcher') ->willReturn($eventManagerMock); $this->registryMock = $this->createMock(Registry::class); $this->resourceMock = $this->getMockForAbstractClass( AbstractResource::class, [], '', false, true, true, ['getIdFieldName', 'load', 'selectActiveIntegrationByConsumerId'] ); $this->resourceCollectionMock = $this->createMock(AbstractDb::class); $this->integrationModel = new Integration( $this->contextMock, $this->registryMock, $this->resourceMock, $this->resourceCollectionMock ); } public function testLoadByConsumerId() { $consumerId = 1; $this->resourceMock->expects($this->once()) ->method('load') ->with($this->integrationModel, $consumerId, Integration::CONSUMER_ID); $this->integrationModel->loadByConsumerId($consumerId); $this->assertFalse($this->integrationModel->hasDataChanges()); } public function testLoadActiveIntegrationByConsumerId() { $consumerId = 1; $integrationData = [ 'integration_id' => 1, 'name' => 'Test Integration' ]; $this->resourceMock->expects($this->once()) ->method('selectActiveIntegrationByConsumerId') ->with($consumerId) ->willReturn($integrationData); $this->integrationModel->loadActiveIntegrationByConsumerId($consumerId); $this->assertEquals($integrationData, $this->integrationModel->getData()); } public function testGetStatus() { $this->integrationModel->setStatus(1); $this->assertEquals(1, $this->integrationModel->getStatus()); } }