Пример #1
0
 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());
 }
Пример #2
0
 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());
 }
Пример #3
0
 /**
  * @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));
 }
Пример #4
0
 public function testLoad()
 {
     $token = 'testToken';
     $this->resourceMock->expects($this->once())->method('load');
     $actualToken = $this->tokenModel->loadByToken($token);
     $this->assertEquals($this->tokenModel, $actualToken);
 }
Пример #5
0
 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));
 }
Пример #6
0
 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);
 }
Пример #7
0
 public function testGetConsumerExpirationPeriodExpired()
 {
     $this->resourceMock->expects($this->once())->method('getTimeInSecondsSinceCreation')->will($this->returnValue(400));
     $this->consumerModel->setCreatedAt(time());
     $this->assertFalse($this->consumerModel->isValidForTokenExchange());
 }
Пример #8
0
 /**
  * Class constructor
  *
  * @param \Magento\Framework\Model\ModelResource\Db\Context $context
  * @param string $connectionName
  */
 public function __construct(\Magento\Framework\Model\ModelResource\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();
 }
Пример #9
0
 /**
  * @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;
         }
     }
 }