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()); }
/** * @covers \Magento\Cms\Model\Page::checkIdentifier */ public function testCheckIdentifier() { $identifier = 1; $storeId = 2; $fetchOneResult = 'some result'; $this->resourcesMock->expects($this->atLeastOnce())->method('checkIdentifier')->with($identifier, $storeId)->willReturn($fetchOneResult); $this->assertInternalType('string', $this->model->checkIdentifier($identifier, $storeId)); }
public function testGetAttributes() { $typeId = 1; $linkAttributes = ['link_type_id' => 1, 'product_link_attribute_code' => 1, 'data_type' => 'int', 'id' => 1]; $this->resource->expects($this->any())->method('getAttributesByType')->with($typeId)->will($this->returnValue($linkAttributes)); $this->model->setData('link_type_id', $typeId); $this->assertEquals($linkAttributes, $this->model->getAttributes()); }
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); }
/** * Class constructor * * @param \Magento\Framework\Model\ResourceModel\Db\Context $context * @param string $connectionName */ public function __construct(\Magento\Framework\Model\ResourceModel\Db\Context $context, $connectionName = null) { $this->transactionManager = $context->getTransactionManager(); $this->_resources = $context->getResources(); $this->objectRelationProcessor = $context->getObjectRelationProcessor(); if ($connectionName !== null) { $this->connectionName = $connectionName; } parent::__construct(); }
/** * @param Context $context * @param array $data */ public function __construct(Context $context, $data = []) { $this->_eavConfig = $context->getEavConfig(); $this->_resource = $context->getResource(); $this->_attrSetEntity = $context->getAttributeSetEntity(); $this->_localeFormat = $context->getLocaleFormat(); $this->_resourceHelper = $context->getResourceHelper(); $this->_universalFactory = $context->getUniversalFactory(); $this->transactionManager = $context->getTransactionManager(); $this->objectRelationProcessor = $context->getObjectRelationProcessor(); parent::__construct(); $properties = get_object_vars($this); foreach ($data as $key => $value) { if (array_key_exists('_' . $key, $properties)) { $this->{'_' . $key} = $value; } } }
public function testGetConsumerExpirationPeriodExpired() { $this->resourceMock->expects($this->once())->method('getTimeInSecondsSinceCreation')->will($this->returnValue(400)); $this->consumerModel->setCreatedAt(time()); $this->assertFalse($this->consumerModel->isValidForTokenExchange()); }
/** * @param DataObject $object * @param string $field * @param null $defaultValue */ public function _unserializeField(DataObject $object, $field, $defaultValue = null) { parent::_unserializeField($object, $field, $defaultValue); }