public function testLoadActiveIntegrationByConsumerId() { $consumerId = 1; $integrationData = ['integration_id' => 1, 'name' => 'Test Integration']; $this->resourceMock->expects($this->once())->method('selectActiveIntegrationByConsumerId')->with($consumerId)->will($this->returnValue($integrationData)); $this->integrationModel->loadActiveIntegrationByConsumerId($consumerId); $this->assertEquals($integrationData, $this->integrationModel->getData()); }
public function testLoadByCompositeKey() { $expectedData = ['testData']; $nonce = 'testNonce'; $consumerId = 1; $this->resourceMock->expects($this->once())->method('selectByCompositeKey')->with($nonce, $consumerId)->will($this->returnValue($expectedData)); $this->nonceModel->loadByCompositeKey($nonce, $consumerId); $this->assertEquals($expectedData, $this->nonceModel->getData()); }
/** * @test * @return void * @covers \Magento\Theme\Model\Design::loadChange */ public function testLoadChange() { $storeId = 1; $localDate = '2\\28\\2000'; $date = '28-02-2000'; $cacheId = 'design_change_' . md5($storeId . $date); $this->localeDate->expects($this->once())->method('scopeTimeStamp')->with($storeId)->willReturn($localDate); $this->dateTime->expects($this->once())->method('formatDate')->with($localDate, false)->willReturn($date); $this->cacheManager->expects($this->once())->method('load')->with($cacheId)->willReturn(false); $this->resource->expects($this->once())->method('loadChange')->with($storeId, $date)->willReturn(false); $this->cacheManager->expects($this->once())->method('save')->with(serialize([]), $cacheId, [Design::CACHE_TAG], 86400)->willReturnSelf(); $this->assertInstanceOf(get_class($this->model), $this->model->loadChange($storeId)); }
public function testLoad() { $token = 'testToken'; $this->resourceMock->expects($this->once())->method('load'); $actualToken = $this->tokenModel->loadByToken($token); $this->assertEquals($this->tokenModel, $actualToken); }
public function testGetSearchableData() { $productId = 15; $storeId = 1; $data = 'data'; $this->resource->expects($this->any())->method('getSearchableData')->with($productId, $storeId)->will($this->returnValue($data)); $this->assertEquals($data, $this->model->getSearchableData($productId, $storeId)); }
public function testSaveProductRelations() { $data = [1]; $typeId = 1; $this->model->setData('link_type_id', $typeId); $product = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->setMethods(['getRelatedLinkData', 'getUpSellLinkData', 'getCrossSellLinkData', '__wakeup'])->getMock(); $product->expects($this->any())->method('getRelatedLinkData')->will($this->returnValue($data)); $product->expects($this->any())->method('getUpSellLinkData')->will($this->returnValue($data)); $product->expects($this->any())->method('getCrossSellLinkData')->will($this->returnValue($data)); $map = [[$product, $data, Link::LINK_TYPE_RELATED, $this->resource], [$product, $data, Link::LINK_TYPE_UPSELL, $this->resource], [$product, $data, Link::LINK_TYPE_CROSSSELL, $this->resource]]; $this->resource->expects($this->any())->method('saveProductLinks')->will($this->returnValueMap($map)); $this->model->saveProductRelations($product); }
public function testGetConsumerExpirationPeriodExpired() { $this->resourceMock->expects($this->once())->method('getTimeInSecondsSinceCreation')->will($this->returnValue(400)); $this->consumerModel->setCreatedAt(time()); $this->assertFalse($this->consumerModel->isValidForTokenExchange()); }