public function testGetRssData() { $ruleData = ['to_date' => '12/12/14', 'from_date' => '12/12/14', 'coupon_code' => '1234567', 'description' => 'Rule Description', 'name' => 'Rule Name']; $rssData = ['title' => 'Frontend Name - Discounts and Coupons', 'description' => 'Frontend Name - Discounts and Coupons', 'link' => 'http://rss.magento.com/discount', 'charset' => 'UTF-8', 'language' => 'en_US', 'entries' => ['title' => 'Rule Name', 'link' => 'http://rss.magento.com', 'description' => ['description' => 'Rule Description', 'start_date' => '12/12/14', 'end_date' => '12/12/14', 'coupon_code' => '1234567']]]; $rssUrl = 'http://rss.magento.com/discount'; $url = 'http://rss.magento.com'; $ruleModel = $this->getMock('Magento\\SalesRule\\Model\\Rule', ['__wakeup', 'getCouponCode', 'getToDate', 'getFromDate', 'getDescription', 'getName'], [], '', false); $this->storeModel->expects($this->once())->method('getWebsiteId')->will($this->returnValue(1)); $this->storeModel->expects($this->never())->method('getName'); $this->storeModel->expects($this->atLeastOnce())->method('getFrontendName')->willReturn('Frontend Name'); $this->requestInterface->expects($this->any())->method('getParam')->will($this->returnValue(1)); $this->urlBuilderInterface->expects($this->any())->method('getUrl')->will($this->returnValue($url)); $this->rssBuilderInterface->expects($this->any())->method('getUrl')->will($this->returnValue($rssUrl)); $this->scopeConfigInterface->expects($this->any())->method('getValue')->will($this->returnValue('en_US')); $ruleModel->expects($this->any())->method('getCouponCode')->will($this->returnValue($ruleData['coupon_code'])); $ruleModel->expects($this->any())->method('getToDate')->will($this->returnValue($ruleData['to_date'])); $ruleModel->expects($this->once())->method('getFromDate')->will($this->returnValue($ruleData['from_date'])); $ruleModel->expects($this->once())->method('getDescription')->will($this->returnValue($ruleData['description'])); $ruleModel->expects($this->once())->method('getName')->will($this->returnValue($ruleData['name'])); $this->rssModel->expects($this->any())->method('getDiscountCollection')->will($this->returnValue([$ruleModel])); $this->timezoneInterface->expects($this->any())->method('formatDate')->will($this->returnValue('12/12/14')); $data = $this->block->getRssData(); $this->assertEquals($rssData['title'], $data['title']); $this->assertEquals($rssData['description'], $data['description']); $this->assertEquals($rssData['link'], $data['link']); $this->assertEquals($rssData['charset'], $data['charset']); $this->assertEquals($rssData['language'], $data['language']); $this->assertEquals($rssData['entries']['title'], $data['entries'][0]['title']); $this->assertEquals($rssData['entries']['link'], $data['entries'][0]['link']); $this->assertContains($rssData['entries']['description']['description'], $data['entries'][0]['description']); $this->assertContains($rssData['entries']['description']['start_date'], $data['entries'][0]['description']); $this->assertContains($rssData['entries']['description']['end_date'], $data['entries'][0]['description']); $this->assertContains($rssData['entries']['description']['coupon_code'], $data['entries'][0]['description']); }
public function testLoadValidOrderNotEmptyPost() { $post = ['oar_order_id' => 1, 'oar_type' => 'email', 'oar_billing_lastname' => 'oar_billing_lastname', 'oar_email' => 'oar_email', 'oar_zip' => 'oar_zip']; $storeId = '1'; $incrementId = $post['oar_order_id']; $protectedCode = 'protectedCode'; $this->sessionMock->expects($this->once())->method('isLoggedIn')->willReturn(false); $requestMock = $this->getMock('Magento\\Framework\\App\\Request\\Http', [], [], '', false); $requestMock->expects($this->once())->method('getPostValue')->willReturn($post); $this->storeManagerInterfaceMock->expects($this->once())->method('getStore')->willReturn($this->storeModelMock); $this->storeModelMock->expects($this->once())->method('getId')->willReturn($storeId); $this->orderFactoryMock->expects($this->once())->method('create')->willReturn($this->salesOrderMock); $this->salesOrderMock->expects($this->once())->method('loadByIncrementIdAndStoreId')->willReturnSelf(); $this->salesOrderMock->expects($this->any())->method('getId')->willReturn($incrementId); $billingAddressMock = $this->getMock('Magento\\Sales\\Model\\Order\\Address', ['getLastname', 'getEmail', '__wakeup'], [], '', false); $billingAddressMock->expects($this->once())->method('getLastname')->willReturn($post['oar_billing_lastname']); $billingAddressMock->expects($this->once())->method('getEmail')->willReturn($post['oar_email']); $this->salesOrderMock->expects($this->once())->method('getBillingAddress')->willReturn($billingAddressMock); $this->salesOrderMock->expects($this->once())->method('getProtectCode')->willReturn($protectedCode); $metaDataMock = $this->getMock('Magento\\Framework\\Stdlib\\Cookie\\PublicCookieMetadata', [], [], '', false); $metaDataMock->expects($this->once())->method('setPath')->with(Guest::COOKIE_PATH)->willReturnSelf(); $metaDataMock->expects($this->once())->method('setHttpOnly')->with(true)->willReturnSelf(); $this->cookieMetadataFactoryMock->expects($this->once())->method('createPublicCookieMetadata')->willReturn($metaDataMock); $this->cookieManagerMock->expects($this->once())->method('setPublicCookie')->with(Guest::COOKIE_NAME, $this->anything(), $metaDataMock); $this->assertTrue($this->guest->loadValidOrder($requestMock)); }
/** * @inheritdoc */ protected function getCollection(Store $store) { /** @var \Magento\Sales\Model\ResourceModel\Order\Collection $collection */ $collection = $this->_orderCollectionFactory->create(); $collection->addAttributeToFilter('store_id', ['eq' => $store->getId()]); return $collection; }
public function testGetTreeHasLevelField() { $rootId = \Magento\Catalog\Model\Category::TREE_ROOT_ID; $storeGroups = []; $storeId = 1; $rootLevel = 2; $level = 3; $this->collection->expects($this->any())->method('addAttributeToSelect')->willReturnMap([['url_key', false, $this->collection], ['is_anchor', false, $this->collection]]); $this->childNode->expects($this->atLeastOnce())->method('getLevel')->willReturn($level); $this->rootNode->expects($this->atLeastOnce())->method('getLevel')->willReturn($rootLevel); $this->rootNode->expects($this->once())->method('hasChildren')->willReturn(true); $this->rootNode->expects($this->once())->method('getChildren')->willReturn([$this->childNode]); $this->categoryTree->expects($this->once())->method('load')->with(null, 3)->willReturnSelf(); $this->categoryTree->expects($this->atLeastOnce())->method('addCollectionData')->with($this->collection)->willReturnSelf(); $this->categoryTree->expects($this->once())->method('getNodeById')->with($rootId)->willReturn($this->rootNode); $this->store->expects($this->atLeastOnce())->method('getId')->willReturn($storeId); $this->storeManager->expects($this->once())->method('getGroups')->willReturn($storeGroups); $this->storeManager->expects($this->atLeastOnce())->method('getStore')->willReturn($this->store); $this->context->expects($this->once())->method('getStoreManager')->willReturn($this->storeManager); $this->context->expects($this->once())->method('getRequest')->willReturn($this->request); $this->context->expects($this->once())->method('getEscaper')->willReturn($this->escaper); $this->context->expects($this->once())->method('getEventManager')->willReturn($this->eventManager); /** @var \Magento\Widget\Block\Adminhtml\Widget\Catalog\Category\Chooser $chooser */ $chooser = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject('Magento\\Widget\\Block\\Adminhtml\\Widget\\Catalog\\Category\\Chooser', ['categoryTree' => $this->categoryTree, 'context' => $this->context]); $chooser->setData('category_collection', $this->collection); $result = $chooser->getTree(); $this->assertEquals($level, $result[0]['level']); }
public function testTrimPathInfoForGetTargetStorePostData() { $this->request->expects($this->once())->method('getPathInfo')->willReturn('path/with/trim/'); $this->store->expects($this->once())->method('getId')->willReturn(1); $this->urlFinder->expects($this->once())->method('findOneByData')->with([\Magento\UrlRewrite\Service\V1\Data\UrlRewrite::TARGET_PATH => 'path/with/trim', \Magento\UrlRewrite\Service\V1\Data\UrlRewrite::STORE_ID => 1])->willReturn(null); $this->urlHelper->expects($this->never())->method('getEncodedUrl'); $this->assertEquals([$this->store, []], $this->unit->beforeGetTargetStorePostData($this->switcher, $this->store, [])); }
/** * @param \Magento\Store\Model\StoreFactory $storeFactory * @param \Magento\Store\Model\WebsiteFactory $websiteFactory * @param \Magento\Store\Model\GroupFactory $groupFactory */ public function __construct(\Magento\Store\Model\StoreFactory $storeFactory, \Magento\Store\Model\WebsiteFactory $websiteFactory, \Magento\Store\Model\GroupFactory $groupFactory) { $this->_store = $storeFactory->create(); $this->_store->setId(\Magento\Store\Model\Store::DISTRO_STORE_ID); $this->_store->setCode(\Magento\Store\Model\Store::DEFAULT_CODE); $this->_website = $websiteFactory->create(); $this->_group = $groupFactory->create(); }
/** * @param \Magento\Store\Model\Store $store * @return void */ private function clearIndex(\Magento\Store\Model\Store $store) { $dimensions = [$this->dimensionFactory->create(['name' => 'scope', 'value' => $store->getId()])]; $configData = $this->indexerConfig->getIndexer(FulltextIndexer::INDEXER_ID); /** @var \Magento\CatalogSearch\Model\Indexer\IndexerHandler $indexHandler */ $indexHandler = $this->indexerHandlerFactory->create(['data' => $configData]); $indexHandler->cleanIndex($dimensions); }
/** * Get logo image * * @param \Magento\Store\Model\Store $store * @return string|null */ public function getLogoImage($store) { $image = null; if (null !== $store) { $image = basename($this->_scopeConfig->getValue('design/header/logo_src', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store->getId())); } return $image; }
/** * Test for getAllOptions method * * @param $cachedDataSrl * @param $cachedDataUnsrl * * @dataProvider testGetAllOptionsDataProvider */ public function testGetAllOptions($cachedDataSrl, $cachedDataUnsrl) { $this->storeMock->expects($this->once())->method('getCode')->will($this->returnValue('store_code')); $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); $this->cacheConfig->expects($this->once())->method('load')->with($this->equalTo('COUNTRYOFMANUFACTURE_SELECT_STORE_store_code'))->will($this->returnValue($cachedDataSrl)); $countryOfManufacture = $this->objectManagerHelper->getObject('Magento\\Catalog\\Model\\Product\\Attribute\\Source\\Countryofmanufacture', ['storeManager' => $this->storeManagerMock, 'configCacheType' => $this->cacheConfig]); $this->assertEquals($cachedDataUnsrl, $countryOfManufacture->getAllOptions()); }
/** * Set redirect url for store view based on request path info * * @param \Magento\Store\Block\Switcher $switcher * @param \Magento\Store\Model\Store $store * @param array $data * @return array * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function beforeGetTargetStorePostData(\Magento\Store\Block\Switcher $switcher, \Magento\Store\Model\Store $store, $data = []) { $urlRewrite = $this->urlFinder->findOneByData([UrlRewrite::TARGET_PATH => $this->trimSlashInPath($this->request->getPathInfo()), UrlRewrite::STORE_ID => $store->getId()]); if ($urlRewrite) { $data[ActionInterface::PARAM_NAME_URL_ENCODED] = $this->urlHelper->getEncodedUrl($this->trimSlashInPath($this->urlBuilder->getUrl($urlRewrite->getRequestPath()))); } return [$store, $data]; }
/** * @param string $matcherMethod * @param bool $websiteChanged * @dataProvider storeGroupWebsiteDataProvider */ public function testChangedWebsiteBeforeSave($matcherMethod, $websiteChanged) { $this->processorMock->expects($this->{$matcherMethod}())->method('markIndexerAsInvalid'); $this->storeGroupMock->expects($this->once())->method('getId')->will($this->returnValue(1)); $this->storeGroupMock->expects($this->once())->method('dataHasChangedFor')->with('root_category_id')->will($this->returnValue($websiteChanged)); $model = new \Magento\Catalog\Model\Indexer\Product\Flat\Plugin\StoreGroup($this->processorMock); $model->beforeSave($this->subjectMock, $this->storeGroupMock); }
/** * @covers \Magento\Cms\Model\Template\Filter::mediaDirective */ public function testMediaDirective() { $baseMediaDir = 'pub/media'; $construction = ['{{media url="wysiwyg/image.jpg"}}', 'media', ' url="wysiwyg/image.jpg"']; $expectedResult = 'pub/media/wysiwyg/image.jpg'; $this->storeMock->expects($this->once())->method('getBaseMediaDir')->willReturn($baseMediaDir); $this->assertEquals($expectedResult, $this->filter->mediaDirective($construction)); }
/** * @inheritdoc */ protected function getCollection(Store $store) { /** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $collection */ $collection = $this->_productCollectionFactory->create(); $collection->setVisibility($this->_productVisibility->getVisibleInSiteIds()); $collection->addAttributeToFilter('status', ['eq' => '1']); $collection->addStoreFilter($store->getId()); return $collection; }
/** * Invalidate design config grid indexer on store creation * * @param StoreStore $subject * @param \Closure $proceed * @return StoreStore * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function aroundSave(StoreStore $subject, \Closure $proceed) { $isObjectNew = $subject->getId() == 0; $result = $proceed(); if ($isObjectNew) { $this->indexerRegistry->get(Config::DESIGN_CONFIG_GRID_INDEXER_ID)->invalidate(); } return $result; }
/** * Test SOAP server construction with WSDL cache disabling. * @SuppressWarnings(PHPMD.UnusedLocalVariable) */ public function testConstructDisableWsdlCache() { /** Mock getConfig method to return false. */ $this->_configMock->expects($this->once())->method('isSetFlag')->will($this->returnValue(false)); /** Create SOAP server object. */ $server = new \Magento\Webapi\Model\Soap\Server($this->_areaListMock, $this->_configScopeMock, $this->_requestMock, $this->_domDocumentFactory, $this->_storeManagerMock, $this->_soapServerFactory, $this->_typeProcessor, $this->_configMock); /** Assert that SOAP WSDL caching option was disabled after SOAP server initialization. */ $this->assertFalse((bool) ini_get('soap.wsdl_cache_enabled'), 'WSDL caching was not disabled.'); }
/** * @dataProvider dataForFullPath */ public function testGetSwatchAttributeImage($swatchType, $expectedResult) { $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($this->storeMock); $this->storeMock->expects($this->once())->method('getBaseUrl')->with('media')->willReturn('http://url/pub/media/'); $this->generateImageConfig(); $this->testGenerateSwatchVariations(); $result = $this->mediaHelperObject->getSwatchAttributeImage($swatchType, '/f/i/file.png'); $this->assertEquals($result, $expectedResult); }
public function testGetShippingPrice() { $shippingPrice = 5; $convertedPrice = "\$5"; $shippingRateMock = $this->getMockBuilder('\\Magento\\Sales\\Model\\Quote\\Address\\Rate')->disableOriginalConstructor()->setMethods(['getPrice', '__wakeup'])->getMock(); $shippingRateMock->expects($this->once())->method('getPrice')->will($this->returnValue($shippingPrice)); $this->store->expects($this->once())->method('convertPrice')->with($shippingPrice, true, true)->will($this->returnValue($convertedPrice)); $this->priceObj->setShippingRate($shippingRateMock); $this->assertEquals($convertedPrice, $this->priceObj->getShippingPrice()); }
/** * @param string $chunkId * @param string $storeId * @param string $processId * @param \Magento\Framework\App\Console\Response $response */ public function __construct($chunkId, $storeId, $processId, \Celebros\Celexport\Helper\Export $helper, \Magento\Store\Model\Store $store, \Celebros\Celexport\Model\Cache $cache, \Magento\Framework\App\State $state, \Magento\Framework\ObjectManagerInterface $objectManager) { $this->_chunkId = $chunkId; $this->_storeId = $storeId; $this->_store = $store->load($this->_storeId); $this->_cache = $cache; $this->_processId = $processId; $this->_state = $state; $this->_objectManager = $objectManager; $this->helper = $helper; }
public function testGetShippingPriceInclTax() { $shippingPrice = 5; $shippingPriceInclTax = 5.5; $convertedPrice = "\$5.50"; $shippingRateMock = $this->setupShippingRate($shippingPrice); $this->taxHelper->expects($this->once())->method('getShippingPrice')->will($this->returnValue($shippingPriceInclTax)); $this->store->expects($this->once())->method('convertPrice')->with($shippingPriceInclTax, true, true)->will($this->returnValue($convertedPrice)); $this->priceObj->setShippingRate($shippingRateMock); $this->assertEquals($convertedPrice, $this->priceObj->getShippingPriceExclTax()); }
/** * Retrieve layout updates by handle * * @param string $handle * @param \Magento\Framework\View\Design\ThemeInterface $theme * @param \Magento\Store\Model\Store $store * @return string */ public function fetchUpdatesByHandle($handle, \Magento\Framework\View\Design\ThemeInterface $theme, \Magento\Store\Model\Store $store) { $bind = ['layout_update_handle' => $handle, 'theme_id' => $theme->getId(), 'store_id' => $store->getId()]; $result = ''; $readAdapter = $this->_getReadAdapter(); if ($readAdapter) { $select = $this->_getFetchUpdatesByHandleSelect(); $result = join('', $readAdapter->fetchCol($select, $bind)); } return $result; }
/** * Tests that getWebsite returns the default site when defaults are passed in for id */ public function testGetWebsiteDefault() { $this->assertFalse($this->_model->getWebsite()); $website = Bootstrap::getObjectManager()->get('Magento\\Store\\Model\\StoreManagerInterface')->getWebsite(); $this->_model->setWebsite($website); // Empty string should get treated like no parameter $actualResult = $this->_model->getWebsite(''); $this->assertSame($website, $actualResult); // Null string should get treated like no parameter $actualResult = $this->_model->getWebsite(null); $this->assertSame($website, $actualResult); }
/** * Test aroundDispatch */ public function testAroundDispatch() { $this->storeManagerMock->expects($this->exactly(2))->method('getWebsite')->will($this->returnValue($this->websiteMock)); $this->websiteMock->expects($this->exactly(2))->method('getDefaultStore')->will($this->returnValue($this->storeMock)); $this->storeMock->expects($this->once())->method('getDefaultCurrency')->will($this->returnValue($this->currencyMock)); $this->storeMock->expects($this->once())->method('getStoreCodeFromCookie')->will($this->returnValue('storeCookie')); $this->currencyMock->expects($this->once())->method('getCode')->will($this->returnValue('UAH')); $this->sessionMock->expects($this->once())->method('getCurrencyCode')->will($this->returnValue('UAH')); $this->httpRequestMock->expects($this->once())->method('getParam')->with($this->equalTo('___store'))->will($this->returnValue('default')); $this->httpContextMock->expects($this->atLeastOnce())->method('setValue')->will($this->returnValueMap([[\Magento\Core\Helper\Data::CONTEXT_CURRENCY, 'UAH', 'UAH', $this->httpContextMock], [\Magento\Core\Helper\Data::CONTEXT_STORE, 'default', 'default', $this->httpContextMock]])); $this->assertEquals('ExpectedValue', $this->plugin->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock)); }
/** * @param Store $store * @return \NostoBilling */ public function build(Store $store) { $metaData = new \NostoBilling(); try { $country = $store->getConfig('general/country/default'); if (!empty($country)) { $metaData->setCountry(new \NostoCountryCode($country)); } } catch (\NostoException $e) { $this->_logger->error($e, ['exception' => $e]); } return $metaData; }
/** * @dataProvider getStoreValuesForFormDataProvider * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function testGetStoreValuesForForm($empty, $all, $storeId, $groupId, $websiteId, $storeName, $groupName, $websiteName, $storeGroupId, $groupWebsiteId, $expectedResult) { $this->websiteMock->expects($this->any())->method('getId')->willReturn($websiteId); $this->websiteMock->expects($this->any())->method('getName')->willReturn($websiteName); $this->groupMock->expects($this->any())->method('getId')->willReturn($groupId); $this->groupMock->expects($this->any())->method('getName')->willReturn($groupName); $this->groupMock->expects($this->any())->method('getWebsiteId')->willReturn($groupWebsiteId); $this->storeMock->expects($this->any())->method('getId')->willReturn($storeId); $this->storeMock->expects($this->any())->method('getName')->willReturn($storeName); $this->storeMock->expects($this->any())->method('getGroupId')->willReturn($storeGroupId); $this->model->setIsAdminScopeAllowed(true); $this->assertEquals($this->model->getStoreValuesForForm($empty, $all), $expectedResult); }
/** * Retrieve request_path using id_path and current store's id. * * @param string $idPath * @param int|\Magento\Store\Model\Store $store * @return string */ public function getRequestPathByIdPath($idPath, $store) { if ($store instanceof \Magento\Store\Model\Store) { $storeId = (int) $store->getId(); } else { $storeId = (int) $store; } $select = $this->_getReadAdapter()->select(); /** @var $select \Magento\Framework\DB\Select */ $select->from(array('main_table' => $this->getMainTable()), 'request_path')->where('main_table.store_id = :store_id')->where('main_table.id_path = :id_path')->limit(1); $bind = array('store_id' => $storeId, 'id_path' => $idPath); return $this->_getReadAdapter()->fetchOne($select, $bind); }
public function testCatalogProductViewVisitor() { $productId = 6; $visitorId = 88; $storeId = 1; $expectedViewedData = ['product_id' => $productId, 'visitor_id' => $visitorId]; $expectedEventData = ['event_type_id' => \Magento\Reports\Model\Event::EVENT_PRODUCT_VIEW, 'object_id' => $productId, 'subject_id' => $visitorId, 'subtype' => 1, 'store_id' => $storeId]; $this->storeMock->expects($this->any())->method('getId')->willReturn($storeId); $this->customerSessionMock->expects($this->any())->method('isLoggedIn')->willReturn(false); $this->customerVisitorMock->expects($this->any())->method('getId')->willReturn($visitorId); $this->prepareProductIndexMock($expectedViewedData); $this->prepareReportEventModel($expectedEventData); $eventObserver = $this->getObserverMock($productId); $this->observer->catalogProductView($eventObserver); }
/** * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function testNewAccount() { $customerId = 1; $customerStoreId = 2; $customerEmail = '*****@*****.**'; $customerData = ['key' => 'value']; $customerName = 'Customer Name'; $templateIdentifier = 'Template Identifier'; $sender = 'Sender'; $customer = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class, [], [], '', false); $customer->expects($this->any())->method('getStoreId')->willReturn($customerStoreId); $customer->expects($this->any())->method('getId')->willReturn($customerId); $customer->expects($this->any())->method('getEmail')->willReturn($customerEmail); $this->storeMock->expects($this->any())->method('getId')->willReturn($customerStoreId); $this->storeManagerMock->expects($this->once())->method('getStore')->with($customerStoreId)->willReturn($this->storeMock); $this->customerRegistryMock->expects($this->once())->method('retrieveSecureData')->with($customerId)->willReturn($this->customerSecureMock); $this->dataProcessorMock->expects($this->once())->method('buildOutputDataArray')->with($customer, \Magento\Customer\Api\Data\CustomerInterface::class)->willReturn($customerData); $this->customerViewHelperMock->expects($this->any())->method('getCustomerName')->with($customer)->willReturn($customerName); $this->customerSecureMock->expects($this->once())->method('addData')->with($customerData)->willReturnSelf(); $this->customerSecureMock->expects($this->once())->method('setData')->with('name', $customerName)->willReturnSelf(); $this->scopeConfigMock->expects($this->at(0))->method('getValue')->with(EmailNotification::XML_PATH_REGISTER_EMAIL_TEMPLATE, ScopeInterface::SCOPE_STORE, $customerStoreId)->willReturn($templateIdentifier); $this->scopeConfigMock->expects($this->at(1))->method('getValue')->with(EmailNotification::XML_PATH_REGISTER_EMAIL_IDENTITY, ScopeInterface::SCOPE_STORE, $customerStoreId)->willReturn($sender); $transport = $this->getMock(\Magento\Framework\Mail\TransportInterface::class, [], [], '', false); $this->transportBuilderMock->expects($this->once())->method('setTemplateIdentifier')->with($templateIdentifier)->willReturnSelf(); $this->transportBuilderMock->expects($this->once())->method('setTemplateOptions')->with(['area' => Area::AREA_FRONTEND, 'store' => $customerStoreId])->willReturnSelf(); $this->transportBuilderMock->expects($this->once())->method('setTemplateVars')->with(['customer' => $this->customerSecureMock, 'back_url' => '', 'store' => $this->storeMock])->willReturnSelf(); $this->transportBuilderMock->expects($this->once())->method('setFrom')->with($sender)->willReturnSelf(); $this->transportBuilderMock->expects($this->once())->method('addTo')->with($customerEmail, $customerName)->willReturnSelf(); $this->transportBuilderMock->expects($this->once())->method('getTransport')->willReturn($transport); $transport->expects($this->once())->method('sendMessage'); $this->model->newAccount($customer, EmailNotification::NEW_ACCOUNT_EMAIL_REGISTERED, '', $customerStoreId); }
/** * @param array $badStoreData * * @dataProvider saveValidationDataProvider * @magentoAppIsolation enabled * @magentoAppArea adminhtml * @magentoDbIsolation enabled * @expectedException \Magento\Framework\Exception\LocalizedException */ public function testSaveValidation($badStoreData) { $normalStoreData = ['code' => 'test', 'website_id' => 1, 'group_id' => 1, 'name' => 'test name', 'sort_order' => 0, 'is_active' => 1]; $data = array_merge($normalStoreData, $badStoreData); $this->model->setData($data); $this->model->save(); }
/** * Set up */ public function setUp() { $this->sessionMock = $this->getMock('Magento\\Framework\\Session\\Generic', ['getCurrencyCode'], [], '', false); $this->httpContextMock = $this->getMock('Magento\\Framework\\App\\Http\\Context', [], [], '', false); $this->httpRequestMock = $this->getMock('Magento\\Framework\\App\\Request\\Http', ['getParam'], [], '', false); $this->storeManager = $this->getMock('Magento\\Store\\Model\\StoreManagerInterface'); $this->storeCookieManager = $this->getMock('Magento\\Store\\Api\\StoreCookieManagerInterface'); $this->storeMock = $this->getMock('Magento\\Store\\Model\\Store', [], [], '', false); $this->currentStoreMock = $this->getMock('Magento\\Store\\Model\\Store', [], [], '', false); $this->websiteMock = $this->getMock('Magento\\Store\\Model\\Website', ['getDefaultStore', '__wakeup'], [], '', false); $this->closureMock = function () { return 'ExpectedValue'; }; $this->subjectMock = $this->getMock('Magento\\Framework\\App\\Action\\Action', [], [], '', false); $this->requestMock = $this->getMock('Magento\\Framework\\App\\RequestInterface'); $this->plugin = (new ObjectManager($this))->getObject('Magento\\Store\\App\\Action\\Plugin\\Context', ['session' => $this->sessionMock, 'httpContext' => $this->httpContextMock, 'httpRequest' => $this->httpRequestMock, 'storeManager' => $this->storeManager, 'storeCookieManager' => $this->storeCookieManager]); $this->storeManager->expects($this->once())->method('getWebsite')->will($this->returnValue($this->websiteMock)); $this->storeManager->method('getDefaultStoreView')->willReturn($this->storeMock); $this->storeManager->method('getStore')->willReturn($this->currentStoreMock); $this->websiteMock->expects($this->once())->method('getDefaultStore')->will($this->returnValue($this->storeMock)); $this->storeMock->expects($this->once())->method('getDefaultCurrencyCode')->will($this->returnValue(self::CURRENCY_DEFAULT)); $this->storeMock->expects($this->once())->method('getCode')->willReturn('default'); $this->currentStoreMock->expects($this->once())->method('getCode')->willReturn('custom_store'); $this->storeCookieManager->expects($this->once())->method('getStoreCodeFromCookie')->will($this->returnValue('storeCookie')); $this->httpRequestMock->expects($this->once())->method('getParam')->with($this->equalTo('___store'))->will($this->returnValue('default')); $this->currentStoreMock->expects($this->any())->method('getDefaultCurrencyCode')->will($this->returnValue(self::CURRENCY_CURRENT_STORE)); }
/** * @param \Magento\Store\Model\Group $subject * @param \Magento\Store\Model\Store $store * @return \Magento\Store\Model\Store */ public function afterGetDefaultStore(Group $subject, Store $store) { if ($this->generalConfig->isAvailable() && $this->storeSwitcher->isInitialized()) { $storeId = $this->storeSwitcher->getStoreId(); if ($store->getId() != $storeId && in_array($storeId, $subject->getStoreIds())) { $store = $this->storeRepository->getById($storeId); } } return $store; }