Ejemplo n.º 1
0
 protected function setUp()
 {
     $objectManager = new ObjectManager($this);
     $this->connection = $this->getMockBuilder('\\Magento\\Framework\\DB\\Adapter\\AdapterInterface')->disableOriginalConstructor()->getMock();
     $this->connection->expects($this->any())->method('quoteInto')->willReturnCallback(function ($query, $expression) {
         return str_replace('?', $expression, $query);
     });
     $this->resource = $this->getMockBuilder('\\Magento\\Framework\\App\\ResourceConnection')->disableOriginalConstructor()->getMock();
     $this->resource->method('getTableName')->willReturnCallback(function ($table) {
         return 'prefix_' . $table;
     });
     $this->resource->expects($this->any())->method('getConnection')->willReturn($this->connection);
     $this->website = $this->getMockBuilder('\\Magento\\Store\\Api\\Data\\WebsiteInterface')->disableOriginalConstructor()->getMockForAbstractClass();
     $this->website->expects($this->any())->method('getId')->willReturn(self::WEBSITE_ID);
     $this->store = $this->getMockBuilder('\\Magento\\Store\\Api\\Data\\StoreInterface')->disableOriginalConstructor()->getMockForAbstractClass();
     $this->store->expects($this->any())->method('getId')->willReturn(self::STORE_ID);
     $this->storeManager = $this->getMockBuilder('\\Magento\\Store\\Model\\StoreManagerInterface')->disableOriginalConstructor()->getMock();
     $this->storeManager->expects($this->any())->method('getWebsite')->willReturn($this->website);
     $this->storeManager->expects($this->any())->method('getStore')->willReturn($this->store);
     $this->attributeCollection = $this->getMockBuilder('\\Magento\\Catalog\\Model\\ResourceModel\\Product\\Attribute\\Collection')->disableOriginalConstructor()->getMock();
     $attributeCollectionFactory = $this->getMockBuilder('\\Magento\\Catalog\\Model\\ResourceModel\\Product\\Attribute\\CollectionFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock();
     $attributeCollectionFactory->expects($this->once())->method('create')->willReturn($this->attributeCollection);
     $this->target = $objectManager->getObject('\\Magento\\CatalogSearch\\Model\\Search\\TableMapper', ['resource' => $this->resource, 'storeManager' => $this->storeManager, 'attributeCollectionFactory' => $attributeCollectionFactory]);
     $this->select = $this->getMockBuilder('\\Magento\\Framework\\DB\\Select')->disableOriginalConstructor()->getMock();
     $this->request = $this->getMockBuilder('\\Magento\\Framework\\Search\\RequestInterface')->disableOriginalConstructor()->getMock();
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function getCatalogPrice(\Magento\Catalog\Model\Product $product, \Magento\Store\Api\Data\StoreInterface $store = null, $inclTax = false)
 {
     // Workaround to avoid loading stock status by admin's website
     if ($store instanceof \Magento\Store\Api\Data\StoreInterface) {
         $currentStore = $this->storeManager->getStore();
         $this->storeManager->setCurrentStore($store->getId());
     }
     $subProducts = $product->getTypeInstance()->getAssociatedProducts($product);
     if ($store instanceof \Magento\Store\Api\Data\StoreInterface) {
         $this->storeManager->setCurrentStore($currentStore->getId());
     }
     if (!$subProducts) {
         return null;
     }
     $minPrice = null;
     foreach ($subProducts as $subProduct) {
         $subProduct->setWebsiteId($product->getWebsiteId())->setCustomerGroupId($product->getCustomerGroupId());
         if ($subProduct->isSalable()) {
             if ($this->commonPriceModel->getCatalogPrice($subProduct) < $minPrice || $minPrice === null) {
                 $minPrice = $this->commonPriceModel->getCatalogPrice($subProduct);
                 $product->setTaxClassId($subProduct->getTaxClassId());
             }
         }
     }
     return $minPrice;
 }
 /**
  * @param \Magento\Store\Api\Data\StoreInterface $store
  * @return $this
  */
 public function setOriginStore(StoreInterface $store)
 {
     if (null === $this->originStoreId) {
         $this->originStoreId = $store->getId();
         $this->originWebsiteId = $store->getWebsiteId();
     }
     return $this;
 }
Ejemplo n.º 4
0
 /**
  * @param StoreInterface $store
  * @param array $typedParams
  * @return array
  */
 private function getParamValues(StoreInterface $store, array $typedParams)
 {
     $paramValues = $this->storeConfigPaths;
     foreach ($paramValues as $name => $path) {
         $value = $this->scopeConfig->getValue(ScopeInterface::SCOPE_STORE, $store->getCode());
         $paramValues[$name] = $value;
     }
     $paramValues = $typedParams + $paramValues;
     return $paramValues;
 }
 public function testGetConfig()
 {
     $loginUrl = 'http://base-url.test/customer/login';
     $baseUrl = 'http://base-url.test';
     $this->urlBuilder->expects($this->exactly(2))->method('getUrl')->with(Url::ROUTE_ACCOUNT_LOGIN)->willReturn($loginUrl);
     $this->storeManager->expects($this->once())->method('getStore')->willReturn($this->store);
     $this->store->expects($this->once())->method('getBaseUrl')->willReturn($baseUrl);
     $this->scopeConfig->expects($this->once())->method('getValue')->with(Form::XML_PATH_ENABLE_AUTOCOMPLETE, ScopeInterface::SCOPE_STORE)->willReturn(0);
     $this->assertEquals(['customerLoginUrl' => $loginUrl, 'isRedirectRequired' => false, 'autocomplete' => 'off'], $this->provider->getConfig());
 }
 protected function setUp()
 {
     parent::setUp();
     $this->productOptionsConfigMock = $this->getMockBuilder(ConfigInterface::class)->getMockForAbstractClass();
     $this->productOptionsPriceMock = $this->getMockBuilder(ProductOptionsPrice::class)->disableOriginalConstructor()->getMock();
     $this->storeManagerMock = $this->getMockBuilder(StoreManagerInterface::class)->getMockForAbstractClass();
     $this->storeMock = $this->getMockBuilder(StoreInterface::class)->setMethods(['getBaseCurrency'])->getMockForAbstractClass();
     $this->priceCurrency = $this->getMockBuilder(PriceCurrencyInterface::class)->disableOriginalConstructor()->getMock();
     $this->storeManagerMock->expects($this->any())->method('getStore')->willReturn($this->storeMock);
     $this->storeMock->expects($this->any())->method('getBaseCurrency')->willReturn($this->priceCurrency);
 }
Ejemplo n.º 7
0
 /**
  * @param Result $result
  * @param StoreInterface $store
  * @param string $baseUrl setting
  */
 protected function checkSettings(Result $result, StoreInterface $store, $baseUrl)
 {
     $errorMessage = 'Wrong hostname configured. <info>Hostname must contain a dot</info>';
     $host = parse_url($baseUrl, PHP_URL_HOST);
     $isValid = (bool) strstr($host, '.');
     $result->setStatus($isValid);
     if ($isValid) {
         $result->setMessage('<info>' . ucfirst($this->class) . ' BaseURL: <comment>' . $baseUrl . '</comment> of Store: <comment>' . $store->getCode() . '</comment> - OK');
     } else {
         $result->setMessage('<error>Invalid ' . ucfirst($this->class) . ' BaseURL: <comment>' . $baseUrl . '</comment> of Store: <comment>' . $store->getCode() . '</comment> ' . $errorMessage . '</error>');
     }
 }
 /**
  * @param int $customerId
  * @param bool $vaultEnabled
  * @dataProvider customerIdProvider
  */
 public function testGetConfig($customerId, $vaultEnabled)
 {
     $storeId = 1;
     $vaultPaymentCode = 'vault_payment';
     $expectedConfiguration = ['vault' => [$vaultPaymentCode => ['is_enabled' => $vaultEnabled]]];
     $this->session->expects(static::once())->method('getCustomerId')->willReturn($customerId);
     $this->storeManager->expects(static::exactly(2))->method('getStore')->willReturn($this->store);
     $this->store->expects(static::exactly(2))->method('getId')->willReturn($storeId);
     $this->paymentDataHelper->expects(static::once())->method('getStoreMethods')->with($storeId)->willReturn([$this->vaultPayment]);
     $this->vaultPayment->expects(static::once())->method('getCode')->willReturn($vaultPaymentCode);
     $this->vaultPayment->expects($customerId !== null ? static::once() : static::never())->method('isActive')->with($storeId)->willReturn($vaultEnabled);
     static::assertEquals($expectedConfiguration, $this->vaultConfigProvider->getConfig());
 }
Ejemplo n.º 9
0
 /**
  * {@inheritdoc}
  */
 public function getCatalogPrice(\Magento\Catalog\Model\Product $product, \Magento\Store\Api\Data\StoreInterface $store = null, $inclTax = false)
 {
     if ($store instanceof \Magento\Store\Api\Data\StoreInterface) {
         $currentStore = $this->storeManager->getStore();
         $this->storeManager->setCurrentStore($store->getId());
     }
     $this->coreRegistry->unregister('rule_data');
     $this->coreRegistry->register('rule_data', new \Magento\Framework\DataObject(['store_id' => $product->getStoreId(), 'website_id' => $product->getWebsiteId(), 'customer_group_id' => $product->getCustomerGroupId()]));
     $minPrice = $product->getPriceModel()->getTotalPrices($product, 'min', $inclTax);
     if ($store instanceof \Magento\Store\Api\Data\StoreInterface) {
         $this->storeManager->setCurrentStore($currentStore->getId());
     }
     return $minPrice;
 }
 /**
  * @param Result $result
  * @param StoreInterface $store
  * @param string $baseUrl setting
  * @param string $cookieDomain setting
  */
 protected function checkSettings(Result $result, StoreInterface $store, $baseUrl, $cookieDomain)
 {
     $errorMessage = 'cookie-domain and ' . $this->class . ' base-URL do not match';
     if (strlen($cookieDomain)) {
         $isValid = $this->validateCookieDomainAgainstUrl($cookieDomain, $baseUrl);
         $result->setStatus($isValid);
         if ($isValid) {
             $result->setMessage('<info>Cookie Domain (' . $this->class . '): <comment>' . $cookieDomain . '</comment>' . ' of Store: <comment>' . $store->getCode() . '</comment> - OK</info>');
         } else {
             $result->setMessage('<error>Cookie Domain (' . $this->class . '): <comment>' . $cookieDomain . '</comment>' . ' of Store: <comment>' . $store->getCode() . '</comment> - ERROR: ' . $errorMessage . '</error>');
         }
     } else {
         $result->setMessage('<info>Empty cookie Domain (' . $this->class . ') of Store: <comment>' . $store->getCode() . '</comment> - OK</info>');
     }
 }
 public function testGetCustomerSessionTokens()
 {
     $customerId = 1;
     $providerCode = 'vault_provider';
     $storeId = 1;
     $token = $this->getMock(PaymentTokenInterface::class);
     $expectation = [$token];
     $this->customerSessionMock->expects(self::once())->method('getCustomerId')->willReturn($customerId);
     $this->storeManager->expects(static::once())->method('getStore')->with(null)->willReturn($this->store);
     $this->store->expects(static::once())->method('getId')->willReturn($storeId);
     $this->vaultPayment->expects(static::once())->method('isActive')->with($storeId)->willReturn(true);
     $this->vaultPayment->expects(static::once())->method('getProviderCode')->with($storeId)->willReturn($providerCode);
     $this->paymentTokenManagementMock->expects(static::once())->method('getVisibleAvailableTokens')->with($customerId, $providerCode)->willReturn($expectation);
     static::assertEquals($expectation, $this->tokenManagement->getCustomerSessionTokens());
 }
 /**
  * Create mock object for store
  */
 private function initStoreMock()
 {
     $storeId = 1;
     $this->store = $this->getMock(StoreInterface::class);
     $this->store->expects(static::once())->method('getId')->willReturn($storeId);
     $this->storeManager = $this->getMock(StoreManagerInterface::class);
     $this->storeManager->expects(static::once())->method('getStore')->with(null)->willReturn($this->store);
 }
Ejemplo n.º 13
0
 public function testPrepareDataSource()
 {
     $fieldName = 'special_field';
     $baseCurrencyCode = 'USD';
     $currencySymbol = '$';
     $dataSource = ['data' => ['items' => [['id' => '1', $fieldName => 3], ['id' => '2'], ['id' => '3', $fieldName => 4.55]]]];
     $result = ['data' => ['items' => [['id' => '1', $fieldName => '3.00$', 'price_number' => '3.00', 'price_currency' => $currencySymbol], ['id' => '2'], ['id' => '3', $fieldName => '4.55$', 'price_number' => '4.55', 'price_currency' => $currencySymbol]]]];
     $this->contextMock->expects($this->any())->method('getFilterParam')->with('store_id', Store::DEFAULT_STORE_ID)->willReturn(Store::DEFAULT_STORE_ID);
     $this->storeManagerMock->expects($this->any())->method('getStore')->with(Store::DEFAULT_STORE_ID)->willReturn($this->storeMock);
     $this->storeMock->expects($this->any())->method('getBaseCurrencyCode')->willReturn($baseCurrencyCode);
     $this->localeCurrencyMock->expects($this->any())->method('getCurrency')->with($baseCurrencyCode)->willReturn($this->currencyMock);
     $this->currencyMock->expects($this->any())->method('toCurrency')->willReturnMap([['3.000000', ['display' => false], '3.00'], ['4.550000', ['display' => false], '4.55'], ['3.000000', [], '3.00$'], ['4.550000', [], '4.55$']]);
     $this->storeMock->expects($this->any())->method('getBaseCurrency')->willReturn($this->currencyModelMock);
     $this->currencyModelMock->expects($this->any())->method('getCurrencySymbol')->willReturn($currencySymbol);
     $this->priceColumn->setData('name', $fieldName);
     $this->assertSame($result, $this->priceColumn->prepareDataSource($dataSource));
 }
Ejemplo n.º 14
0
 public function testExtract()
 {
     $customerData = ['firstname' => 'firstname', 'lastname' => 'firstname', 'email' => 'email.example.com'];
     $this->formFactory->expects($this->once())->method('create')->with('customer', 'form-code')->willReturn($this->customerForm);
     $this->customerForm->expects($this->once())->method('extractData')->with($this->request)->willReturn($customerData);
     $this->customerForm->expects($this->once())->method('getAllowedAttributes')->willReturn(['group_id' => 'attribute object']);
     $this->customerFactory->expects($this->once())->method('create')->willReturn($this->customerData);
     $this->dataObjectHelper->expects($this->once())->method('populateWithArray')->with($this->customerData, $customerData, '\\Magento\\Customer\\Api\\Data\\CustomerInterface')->willReturn($this->customerData);
     $this->storeManager->expects($this->once())->method('getStore')->willReturn($this->store);
     $this->store->expects($this->exactly(2))->method('getId')->willReturn(1);
     $this->customerGroupManagement->expects($this->once())->method('getDefaultGroup')->with(1)->willReturn($this->customerGroup);
     $this->customerGroup->expects($this->once())->method('getId')->willReturn(1);
     $this->customerData->expects($this->once())->method('setGroupId')->with(1);
     $this->store->expects($this->once())->method('getWebsiteId')->willReturn(1);
     $this->customerData->expects($this->once())->method('setWebsiteId')->with(1);
     $this->customerData->expects($this->once())->method('setStoreId')->with(1);
     $this->assertSame($this->customerData, $this->customerExtractor->extract('form-code', $this->request));
 }
 /**
  * @param TextTable      $table
  * @param StoreInterface $store
  * @param                $message
  * @param bool|false     $appendIfUnregistered
  * @return bool
  */
 private function addToTable(TextTable $table, StoreInterface $store, $message, $appendIfUnregistered = false)
 {
     $springbotStoreId = $this->storeConfig->getSpringbotStoreId($store->getId());
     $springbotGuid = strtolower($this->storeConfig->getGuid($store->getId()));
     if ($springbotStoreId && $springbotGuid || $appendIfUnregistered) {
         $table->appendRow([substr($store->getName(), 0, 23), $store->getId(), $springbotStoreId, $message]);
         return true;
     }
     return false;
 }
Ejemplo n.º 16
0
 public function testSaveToTmp()
 {
     $path = 'design/header/logo_src';
     $fieldCode = 'header_logo_src';
     $metadata = [$fieldCode => ['path' => $path, 'backend_model' => 'Magento\\Theme\\Model\\Design\\Backend\\File']];
     $this->storeManager->expects($this->once())->method('getStore')->willReturn($this->store);
     $this->store->expects($this->once())->method('getBaseUrl')->with(UrlInterface::URL_TYPE_MEDIA)->willReturn('http://magento2.com/pub/media/');
     $this->directoryWrite->expects($this->once())->method('getAbsolutePath')->with('tmp/' . FileProcessor::FILE_DIR)->willReturn('absolute/path/to/tmp/media');
     $this->metadataProvider->expects($this->once())->method('get')->willReturn($metadata);
     $this->backendModelFactory->expects($this->once())->method('createByPath')->with($path)->willReturn($this->backendModel);
     $this->uploaderFactory->expects($this->once())->method('create')->with(['fileId' => $fieldCode])->willReturn($this->uploader);
     $this->uploader->expects($this->once())->method('setAllowRenameFiles')->with(true);
     $this->uploader->expects($this->once())->method('setFilesDispersion')->with(false);
     $this->backendModel->expects($this->once())->method('getAllowedExtensions')->willReturn(['png', 'jpg']);
     $this->uploader->expects($this->once())->method('setAllowedExtensions')->with(['png', 'jpg']);
     $this->uploader->expects($this->once())->method('addValidateCallback')->with('size', $this->backendModel, 'validateMaxSize');
     $this->uploader->expects($this->once())->method('save')->with('absolute/path/to/tmp/media')->willReturn(['file' => 'file.jpg', 'size' => '234234']);
     $this->assertEquals(['file' => 'file.jpg', 'size' => '234234', 'url' => 'http://magento2.com/pub/media/tmp/' . FileProcessor::FILE_DIR . '/file.jpg'], $this->fileProcessor->saveToTmp($fieldCode));
 }
 public function testGetConfig()
 {
     $storeId = 1;
     $vaultProviderCode = 'vault_provider_code';
     $expectedConfig = ['payment' => [VaultPaymentInterface::CODE => [VaultPaymentInterface::CODE . '_item_' . '0' => ['config' => ['token_code' => 'code'], 'component' => 'Vendor_Module/js/vault_component']]]];
     $tokenMock = $this->getMockBuilder(PaymentTokenInterface::class)->getMockForAbstractClass();
     $tokenUiComponentProvider = $this->getMock(TokenUiComponentProviderInterface::class);
     $tokenUiComponent = $this->getMock(TokenUiComponentInterface::class);
     $this->vaultPayment->expects(static::once())->method('getProviderCode')->with($storeId)->willReturn($vaultProviderCode);
     $this->storeManager->expects(static::once())->method('getStore')->with(null)->willReturn($this->store);
     $this->store->expects(static::once())->method('getId')->willReturn($storeId);
     $this->vaultPayment->expects(static::once())->method('isActive')->with($storeId)->willReturn(true);
     $this->customerTokenManagement->expects(self::once())->method('getCustomerSessionTokens')->willReturn([$tokenMock]);
     $tokenUiComponentProvider->expects(static::once())->method('getComponentForToken')->with($tokenMock)->willReturn($tokenUiComponent);
     $tokenUiComponent->expects(static::once())->method('getConfig')->willReturn(['token_code' => 'code']);
     $tokenUiComponent->expects(static::once())->method('getName')->willReturn('Vendor_Module/js/vault_component');
     $configProvider = new TokensConfigProvider($this->storeManager, $this->vaultPayment, $this->customerTokenManagement, [$vaultProviderCode => $tokenUiComponentProvider]);
     static::assertEquals($expectedConfig, $configProvider->getConfig());
 }
 public function testGetConfig()
 {
     $storeId = 1;
     $vaultProviderCode = 'vault_provider_code';
     $expectedConfig = ['payment' => ['vault' => [$vaultProviderCode . '_item_' . '0' => ['config' => ['token_code' => 'code'], 'component' => 'Vendor_Module/js/vault_component']]]];
     $token = $this->getMockForAbstractClass(PaymentTokenInterface::class);
     $tokenUiComponentProvider = $this->getMockForAbstractClass(TokenUiComponentProviderInterface::class);
     $tokenUiComponent = $this->getMockForAbstractClass(TokenUiComponentInterface::class);
     $this->storeManager->expects(static::once())->method('getStore')->willReturn($this->store);
     $this->store->expects(static::once())->method('getId')->willReturn($storeId);
     $this->paymentDataHelper->expects(static::once())->method('getStoreMethods')->with($storeId)->willReturn([$this->vaultPayment]);
     $this->vaultPayment->expects(static::once())->method('isActive')->with($storeId)->willReturn(true);
     $this->vaultPayment->expects(static::once())->method('getProviderCode')->willReturn($vaultProviderCode);
     $this->customerTokenManagement->expects(static::once())->method('getCustomerSessionTokens')->willReturn([$token]);
     $token->expects(static::once())->method('getPaymentMethodCode')->willReturn($vaultProviderCode);
     $tokenUiComponentProvider->expects(static::once())->method('getComponentForToken')->with($token)->willReturn($tokenUiComponent);
     $tokenUiComponent->expects(static::once())->method('getConfig')->willReturn(['token_code' => 'code']);
     $tokenUiComponent->expects(static::once())->method('getName')->willReturn('Vendor_Module/js/vault_component');
     $configProvider = new TokensConfigProvider($this->storeManager, $this->customerTokenManagement, [$vaultProviderCode => $tokenUiComponentProvider]);
     $this->objectManager->setBackwardCompatibleProperty($configProvider, 'paymentDataHelper', $this->paymentDataHelper);
     static::assertEquals($expectedConfig, $configProvider->getConfig());
 }
 public function testGetConfigNoActiveVaultProvider()
 {
     $customerId = 1;
     $storeId = 1;
     $this->customerSessionMock->expects(self::once())->method('getCustomerId')->willReturn($customerId);
     $this->storeManager->expects(static::once())->method('getStore')->with(null)->willReturn($this->store);
     $this->store->expects(static::once())->method('getId')->willReturn($storeId);
     $this->vaultPayment->expects(static::once())->method('isActive')->with($storeId)->willReturn(false);
     $this->paymentTokenRepositoryMock->expects(self::never())->method('getList');
     $configProvider = new TokensConfigProvider($this->customerSessionMock, $this->paymentTokenRepositoryMock, $this->filterBuilderMock, $this->searchCriteriaBuilderMock, $this->storeManager, $this->vaultPayment);
     $config = $configProvider->getConfig();
     self::assertEmpty($config);
 }
Ejemplo n.º 20
0
 /**
  * @covers \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper::initialize
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testInitialize()
 {
     $this->websiteMock->expects($this->once())->method('getId')->willReturn($this->websiteId);
     $this->storeMock->expects($this->once())->method('getWebsite')->willReturn($this->websiteMock);
     $this->storeManagerMock->expects($this->once())->method('getStore')->with(true)->willReturn($this->storeMock);
     $this->customOptionMock->expects($this->once())->method('setProductSku');
     $this->customOptionMock->expects($this->once())->method('setOptionId');
     $optionsData = ['option1' => ['is_delete' => true, 'name' => 'name1', 'price' => 'price1'], 'option2' => ['is_delete' => false, 'name' => 'name1', 'price' => 'price1']];
     $productData = ['stock_data' => ['stock_data'], 'options' => $optionsData];
     $attributeNonDate = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class)->disableOriginalConstructor()->getMock();
     $attributeDate = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class)->disableOriginalConstructor()->getMock();
     $attributeNonDateBackEnd = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\Backend\DefaultBackend::class)->disableOriginalConstructor()->getMock();
     $attributeDateBackEnd = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\Backend\Datetime::class)->disableOriginalConstructor()->getMock();
     $attributeNonDate->expects($this->any())->method('getBackend')->willReturn($attributeNonDateBackEnd);
     $attributeDate->expects($this->any())->method('getBackend')->willReturn($attributeDateBackEnd);
     $this->productMock->expects($this->any())->method('getProductLinks')->willReturn([]);
     $attributeNonDateBackEnd->expects($this->any())->method('getType')->willReturn('non-datetime');
     $attributeDateBackEnd->expects($this->any())->method('getType')->willReturn('datetime');
     $attributesArray = [$attributeNonDate, $attributeDate];
     $useDefaults = ['attributeCode1', 'attributeCode2'];
     $this->requestMock->expects($this->at(0))->method('getPost')->with('product')->willReturn($productData);
     $this->requestMock->expects($this->at(1))->method('getPost')->with('use_default')->willReturn($useDefaults);
     $this->linkResolverMock->expects($this->once())->method('getLinks')->willReturn([]);
     $this->stockFilterMock->expects($this->once())->method('filter')->with(['stock_data'])->willReturn(['stock_data']);
     $this->storeManagerMock->expects($this->once())->method('hasSingleStore')->willReturn(true);
     $this->productMock->expects($this->once())->method('isLockedAttribute')->with('media')->willReturn(true);
     $this->productMock->expects($this->once())->method('unlockAttribute')->with('media');
     $this->productMock->expects($this->any())->method('getProductLinks')->willReturn([]);
     $this->productMock->expects($this->once())->method('lockAttribute')->with('media');
     $this->productMock->expects($this->once())->method('getAttributes')->willReturn($attributesArray);
     $productData['category_ids'] = [];
     $productData['website_ids'] = [];
     unset($productData['options']);
     $this->productMock->expects($this->once())->method('addData')->with($productData);
     $this->productMock->expects($this->once())->method('getSku')->willReturn('sku');
     $this->productMock->expects($this->once())->method('setWebsiteIds')->with([$this->websiteId]);
     $this->productMock->expects($this->any())->method('getOptionsReadOnly')->willReturn(false);
     $this->customOptionFactoryMock->expects($this->any())->method('create')->with(['data' => $optionsData['option2']])->willReturn($this->customOptionMock);
     $this->productMock->expects($this->once())->method('setOptions')->with([$this->customOptionMock]);
     $this->assertEquals($this->productMock, $this->helper->initialize($this->productMock));
 }
Ejemplo n.º 21
0
 public function testModifyData()
 {
     $sourceData = ['1' => ['product' => [ProductAttributeInterface::CODE_PRICE => '19.99']]];
     $this->locatorMock->expects($this->any())->method('getProduct')->willReturn($this->productMock);
     $this->productMock->expects($this->any())->method('getId')->willReturn(1);
     $this->productMock->expects($this->once())->method('getAttributeSetId')->willReturn(4);
     $this->productMock->expects($this->once())->method('getData')->with(ProductAttributeInterface::CODE_PRICE)->willReturn('19.9900');
     $this->searchCriteriaBuilderMock->expects($this->any())->method('addFilter')->willReturnSelf();
     $this->searchCriteriaBuilderMock->expects($this->any())->method('create')->willReturn($this->searchCriteriaMock);
     $this->attributeGroupRepositoryMock->expects($this->any())->method('getList')->willReturn($this->searchCriteriaMock);
     $this->searchCriteriaMock->expects($this->once())->method('getItems')->willReturn([$this->attributeGroupMock]);
     $this->sortOrderBuilderMock->expects($this->once())->method('setField')->willReturnSelf();
     $this->sortOrderBuilderMock->expects($this->once())->method('setAscendingDirection')->willReturnSelf();
     $dataObjectMock = $this->getMock('\\Magento\\Framework\\Api\\AbstractSimpleObject', [], [], '', false);
     $this->sortOrderBuilderMock->expects($this->once())->method('create')->willReturn($dataObjectMock);
     $this->searchCriteriaBuilderMock->expects($this->any())->method('addFilter')->willReturnSelf();
     $this->searchCriteriaBuilderMock->expects($this->once())->method('addSortOrder')->willReturnSelf();
     $this->searchCriteriaBuilderMock->expects($this->any())->method('create')->willReturn($this->searchCriteriaMock);
     $this->attributeRepositoryMock->expects($this->once())->method('getList')->with($this->searchCriteriaMock)->willReturn($this->searchResultsMock);
     $this->eavAttributeMock->expects($this->any())->method('getAttributeGroupCode')->willReturn('product-details');
     $this->eavAttributeMock->expects($this->once())->method('getApplyTo')->willReturn([]);
     $this->eavAttributeMock->expects($this->once())->method('getFrontendInput')->willReturn('price');
     $this->eavAttributeMock->expects($this->any())->method('getAttributeCode')->willReturn(ProductAttributeInterface::CODE_PRICE);
     $this->searchResultsMock->expects($this->once())->method('getItems')->willReturn([$this->eavAttributeMock]);
     $this->storeMock->expects($this->once())->method('getBaseCurrencyCode')->willReturn('en_US');
     $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($this->storeMock);
     $this->currencyMock->expects($this->once())->method('toCurrency')->willReturn('19.99');
     $this->currencyLocaleMock->expects($this->once())->method('getCurrency')->willReturn($this->currencyMock);
     $this->assertEquals($sourceData, $this->eav->modifyData([]));
 }
 /**
  * {@inheritdoc}
  */
 public function deleteStoreCookie(StoreInterface $store)
 {
     $cookieMetadata = $this->cookieMetadataFactory->createPublicCookieMetadata()->setPath($store->getStorePath());
     $this->cookieManager->deleteCookie(self::COOKIE_NAME, $cookieMetadata);
 }
 /**
  * @param StoreInterface $store
  * @return string
  */
 private function getFrontendStoreUrl(StoreInterface $store)
 {
     return $store->getBaseUrl(FrontendUrlInterface::URL_TYPE_LINK) . '?___store=' . $store->getCode();
 }
Ejemplo n.º 24
0
 /**
  * Get details for GetTaxRequest
  *
  * @param \Magento\Store\Api\Data\StoreInterface $store
  * @param $address \Magento\Quote\Api\Data\AddressInterface|\Magento\Sales\Api\Data\OrderAddressInterface
  * @param \Magento\Quote\Api\Data\CartInterface|\Magento\Sales\Api\Data\OrderInterface $object
  * @return array
  * @throws LocalizedException
  */
 protected function retrieveGetTaxRequestFields(StoreInterface $store, $address, $object)
 {
     $customerId = $object->getCustomerId();
     $customer = $this->getCustomerById($customerId);
     $storeId = $store->getId();
     if ($this->config->getLiveMode() == Config::API_PROFILE_NAME_PROD) {
         $companyCode = $this->config->getCompanyCode($storeId);
     } else {
         $companyCode = $this->config->getDevelopmentCompanyCode($storeId);
     }
     $businessIdentificationNumber = $this->getBusinessIdentificationNumber($store, $address, $customer);
     $locationCode = $this->config->getLocationCode($store);
     return ['BusinessIdentificationNo' => $businessIdentificationNumber, 'CompanyCode' => $companyCode, 'LocationCode' => $locationCode, 'OriginAddress' => $this->address->getAddress($this->config->getOriginAddress($storeId))];
 }