예제 #1
0
 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));
 }
예제 #2
0
 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']);
 }
예제 #3
0
 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']);
 }
 /**
  * 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());
 }
예제 #5
0
 /**
  * @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);
 }
예제 #6
0
 /**
  * @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));
 }
 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, []));
 }
예제 #8
0
 /**
  * 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.');
 }
예제 #9
0
 /**
  * @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);
 }
예제 #10
0
 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());
 }
예제 #11
0
 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());
 }
예제 #12
0
 /**
  * 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));
 }
예제 #13
0
 /**
  * @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);
 }
예제 #14
0
 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);
 }
예제 #15
0
 /**
  * cover positive case for getFaviconFile and checkIsFile
  */
 public function testGetFaviconFile()
 {
     $scopeConfigValue = 'path';
     $urlToMediaDir = 'http://magento.url/pub/media/';
     $expectedFile = ImageFavicon::UPLOAD_DIR . '/' . $scopeConfigValue;
     $expectedUrl = $urlToMediaDir . $expectedFile;
     $this->scopeManager->expects($this->once())->method('getValue')->with('design/head/shortcut_icon', ScopeInterface::SCOPE_STORE)->willReturn($scopeConfigValue);
     $this->store->expects($this->once())->method('getBaseUrl')->with(UrlInterface::URL_TYPE_MEDIA)->willReturn($urlToMediaDir);
     $this->fileStorageDatabase->expects($this->once())->method('checkDbUsage')->willReturn(true);
     $this->fileStorageDatabase->expects($this->once())->method('saveFileToFilesystem')->willReturn(true);
     $this->mediaDir->expects($this->at(0))->method('isFile')->with($expectedFile)->willReturn(false);
     $this->mediaDir->expects($this->at(1))->method('isFile')->with($expectedFile)->willReturn(true);
     $results = $this->object->getFaviconFile();
     $this->assertEquals($expectedUrl, $results);
     $this->assertNotFalse($results);
 }
예제 #16
0
 /**
  * @param string $email
  * @param string $templateIdentifier
  * @param string $sender
  * @param int $storeId
  * @param int $customerId
  * @param string $hash
  */
 protected function prepareInitiatePasswordReset($email, $templateIdentifier, $sender, $storeId, $customerId, $hash)
 {
     $websiteId = 1;
     $dateTime = date(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT);
     $customerData = ['key' => 'value'];
     $customerName = 'Customer Name';
     $this->store->expects($this->once())->method('getWebsiteId')->willReturn($websiteId);
     $this->store->expects($this->any())->method('getId')->willReturn($storeId);
     $this->storeManager->expects($this->any())->method('getStore')->willReturn($this->store);
     $customer = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\CustomerInterface')->getMock();
     $customer->expects($this->any())->method('getEmail')->willReturn($email);
     $customer->expects($this->any())->method('getId')->willReturn($customerId);
     $customer->expects($this->any())->method('getStoreId')->willReturn($storeId);
     $this->customerRepository->expects($this->once())->method('get')->with($email, $websiteId)->willReturn($customer);
     $this->customerRepository->expects($this->once())->method('save')->with($customer)->willReturnSelf();
     $this->random->expects($this->once())->method('getUniqueHash')->willReturn($hash);
     $this->customerViewHelper->expects($this->any())->method('getCustomerName')->with($customer)->willReturn($customerName);
     $this->customerSecure->expects($this->any())->method('setRpToken')->with($hash)->willReturnSelf();
     $this->customerSecure->expects($this->any())->method('setRpTokenCreatedAt')->with($dateTime)->willReturnSelf();
     $this->customerSecure->expects($this->any())->method('addData')->with($customerData)->willReturnSelf();
     $this->customerSecure->expects($this->any())->method('setData')->with('name', $customerName)->willReturnSelf();
     $this->customerRegistry->expects($this->any())->method('retrieveSecureData')->with($customerId)->willReturn($this->customerSecure);
     $this->dataObjectProcessor->expects($this->any())->method('buildOutputDataArray')->with($customer, '\\Magento\\Customer\\Api\\Data\\CustomerInterface')->willReturn($customerData);
     $this->prepareEmailSend($email, $templateIdentifier, $sender, $storeId, $customerName);
 }
예제 #17
0
 public function testGetCategoryWithAppliedId()
 {
     $storeId = 1234;
     $categoryId = 4321;
     $this->store->expects($this->once())->method('getId')->will($this->returnValue($storeId));
     $this->layer->expects($this->any())->method('getCurrentCategory')->will($this->returnValue($this->category));
     $this->category->expects($this->once())->method('setStoreId')->with($this->equalTo($storeId))->will($this->returnSelf());
     $this->category->expects($this->once())->method('load')->with($this->equalTo($categoryId))->will($this->returnSelf());
     $this->category->expects($this->any())->method('getId')->will($this->returnValue($categoryId));
     $this->category->expects($this->any())->method('getPathIds')->will($this->returnValue([20, 10]));
     $this->coreRegistry->expects($this->once())->method('register')->with($this->equalTo('current_category_filter'), $this->equalTo($this->category), $this->equalTo(true))->will($this->returnSelf());
     $this->target->setCategoryId($categoryId);
     $this->assertSame($this->category, $this->target->getCategory());
     $this->assertSame(20, $this->target->getResetValue());
     return $this->target;
 }
예제 #18
0
 /**
  * @param array $attributes
  * @param array $values
  * @param string $currentCurrencyCode
  * @param string $baseCurrencyCode
  * @dataProvider addFiltersDataProvider
  */
 public function testAddFiltersVerifyAddConditionsToRegistry(array $attributes, array $values, $currentCurrencyCode = 'GBP', $baseCurrencyCode = 'USD')
 {
     $registry = new \Magento\Framework\Registry();
     $this->collection->expects($this->any())->method('addAttributeToSelect')->will($this->returnSelf());
     $this->collection->expects($this->any())->method('setStore')->will($this->returnSelf());
     $this->collection->expects($this->any())->method('addMinimalPrice')->will($this->returnSelf());
     $this->collection->expects($this->any())->method('addTaxPercents')->will($this->returnSelf());
     $this->collection->expects($this->any())->method('addStoreFilter')->will($this->returnSelf());
     $this->collection->expects($this->any())->method('setVisibility')->will($this->returnSelf());
     $this->resource->expects($this->any())->method('prepareCondition')->will($this->returnValue(['like' => '%simple%']));
     $this->resource->expects($this->any())->method('getIdFieldName')->will($this->returnValue('entity_id'));
     $this->dataCollection->expects($this->any())->method('getIterator')->will($this->returnValue(new \ArrayIterator($attributes)));
     $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $advancedFactory = $this->getMockBuilder('Magento\\CatalogSearch\\Model\\ResourceModel\\AdvancedFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock();
     $advancedFactory->expects($this->once())->method('create')->willReturn($this->resource);
     $productCollectionFactory = $this->getMockBuilder('Magento\\Catalog\\Model\\ResourceModel\\Product\\CollectionFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock();
     $productCollectionFactory->expects($this->any())->method('create')->willReturn($this->collection);
     $this->store->expects($this->any())->method('getCurrentCurrencyCode')->willReturn($currentCurrencyCode);
     $this->store->expects($this->any())->method('getBaseCurrencyCode')->willReturn($baseCurrencyCode);
     $this->currency->expects($this->any())->method('getRate')->with($currentCurrencyCode)->willReturn(1.5);
     $currency = $this->getMockBuilder('Magento\\Directory\\Model\\Currency')->setMethods(['load', 'format'])->disableOriginalConstructor()->getMock();
     $currency->expects($this->any())->method('load')->willReturnSelf();
     $currency->expects($this->any())->method('format')->willReturnArgument(0);
     $currencyFactory = $this->getMockBuilder('Magento\\Directory\\Model\\CurrencyFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock();
     $currencyFactory->expects($this->any())->method('create')->willReturn($currency);
     /** @var \Magento\CatalogSearch\Model\Advanced $instance */
     $instance = $objectManager->getObject('Magento\\CatalogSearch\\Model\\Advanced', ['registry' => $registry, 'resourceProvider' => $this->resourceProvider, 'data' => ['attributes' => $this->dataCollection], 'advancedFactory' => $advancedFactory, 'productCollectionFactory' => $productCollectionFactory, 'storeManager' => $this->storeManager, 'currencyFactory' => $currencyFactory]);
     $instance->addFilters($values);
     $this->assertNotNull($registry->registry('advanced_search_conditions'));
 }
예제 #19
0
 public function testStop()
 {
     // Test data
     $initArea = 'initial area';
     $initTheme = 'initial design theme';
     $initLocale = 'initial locale code';
     $initialStore = 1;
     $initTranslateInline = false;
     $this->inlineTranslationMock->expects($this->once())->method('isEnabled')->willReturn($initTranslateInline);
     $this->viewDesignMock->expects($this->once())->method('getArea')->willReturn($initArea);
     $this->viewDesignMock->expects($this->once())->method('getDesignTheme')->willReturn($initTheme);
     $this->storeManagerMock->expects($this->any())->method('getStore')->willReturn($this->storeMock);
     $this->storeMock->expects($this->once())->method('getStoreId')->willReturn($initialStore);
     $this->localeResolverMock->expects($this->once())->method('getLocale')->willReturn($initLocale);
     $this->model->storeCurrentEnvironmentInfo();
     // Expectations
     $this->inlineTranslationMock->expects($this->once())->method('resume')->with($initTranslateInline);
     $this->viewDesignMock->expects($this->once())->method('setDesignTheme')->with($initTheme, $initArea);
     $this->storeManagerMock->expects($this->once())->method('setCurrentStore')->with($initialStore);
     $this->localeResolverMock->expects($this->once())->method('setLocale')->with($initLocale);
     $this->translateMock->expects($this->once())->method('setLocale')->with($initLocale);
     $this->translateMock->expects($this->once())->method('loadData')->with($initArea);
     // Test
     $this->model->stopEnvironmentEmulation();
 }
예제 #20
0
 public function testSave()
 {
     $this->orderMock->expects($this->exactly(3))->method('getId')->willReturn(null);
     $this->orderItemMock->expects($this->once())->method('getChildrenItems')->willReturn([]);
     $this->orderItemMock->expects($this->once())->method('getQuoteParentItemId')->willReturn(null);
     $this->orderMock->expects($this->once())->method('setTotalItemCount')->with(1);
     $this->storeGroupMock->expects($this->once())->method('getDefaultStoreId')->willReturn(1);
     $this->orderMock->expects($this->once())->method('getAllItems')->willReturn([$this->orderItemMock]);
     $this->orderMock->expects($this->once())->method('validateBeforeSave')->willReturnSelf();
     $this->orderMock->expects($this->once())->method('beforeSave')->willReturnSelf();
     $this->orderMock->expects($this->once())->method('isSaveAllowed')->willReturn(true);
     $this->orderMock->expects($this->once())->method('getEntityType')->willReturn('order');
     $this->orderMock->expects($this->exactly(2))->method('getStore')->willReturn($this->storeMock);
     $this->storeMock->expects($this->exactly(2))->method('getGroup')->willReturn($this->storeGroupMock);
     $this->storeMock->expects($this->once())->method('getWebsite')->willReturn($this->websiteMock);
     $this->storeGroupMock->expects($this->once())->method('getDefaultStoreId')->willReturn(1);
     $this->salesSequenceManagerMock->expects($this->once())->method('getSequence')->with('order', 1)->willReturn($this->salesSequenceMock);
     $this->salesSequenceMock->expects($this->once())->method('getNextValue')->willReturn('10000001');
     $this->orderMock->expects($this->once())->method('setIncrementId')->with('10000001')->willReturnSelf();
     $this->orderMock->expects($this->once())->method('getIncrementId')->willReturn(null);
     $this->orderMock->expects($this->once())->method('getData')->willReturn(['increment_id' => '10000001']);
     $this->objectRelationProcessorMock->expects($this->once())->method('validateDataIntegrity')->with(null, ['increment_id' => '10000001']);
     $this->relationCompositeMock->expects($this->once())->method('processRelations')->with($this->orderMock);
     $this->resourceMock->expects($this->any())->method('getConnection')->willReturn($this->adapterMock);
     $this->adapterMock->expects($this->any())->method('quoteInto');
     $this->adapterMock->expects($this->any())->method('describeTable')->will($this->returnValue([]));
     $this->adapterMock->expects($this->any())->method('update');
     $this->adapterMock->expects($this->any())->method('lastInsertId');
     $this->orderMock->expects($this->any())->method('getId')->will($this->returnValue(1));
     $this->entitySnapshotMock->expects($this->once())->method('isModified')->with($this->orderMock)->will($this->returnValue(true));
     $this->resource->save($this->orderMock);
 }
예제 #21
0
 public function testGetCurrentUrl()
 {
     $this->model->load('admin');
     $this->model->expects($this->any())->method('getUrl')->will($this->returnValue('http://localhost/index.php'));
     $this->assertStringEndsWith('default', $this->model->getCurrentUrl());
     $this->assertStringEndsNotWith('default', $this->model->getCurrentUrl(false));
 }
 /**
  * @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);
 }
예제 #23
0
 protected function setUp()
 {
     $this->objectManager = new ObjectManager($this);
     $this->assignedWebsites = [self::SECOND_WEBSITE_ID];
     $this->websiteMock = $this->getMockBuilder('Magento\\Store\\Model\\Website')->setMethods(['getId', 'getName'])->disableOriginalConstructor()->getMock();
     $this->secondWebsiteMock = $this->getMockBuilder('Magento\\Store\\Model\\Website')->setMethods(['getId', 'getName'])->disableOriginalConstructor()->getMock();
     $this->websiteRepositoryMock = $this->getMockBuilder('Magento\\Store\\Api\\WebsiteRepositoryInterface')->setMethods(['getList', 'getDefault'])->getMockForAbstractClass();
     $this->websiteRepositoryMock->expects($this->any())->method('getDefault')->willReturn($this->websiteMock);
     $this->websiteRepositoryMock->expects($this->any())->method('getList')->willReturn([$this->websiteMock, $this->secondWebsiteMock]);
     $this->groupRepositoryMock = $this->getMockBuilder('Magento\\Store\\Api\\GroupRepositoryInterface')->setMethods(['getList'])->getMockForAbstractClass();
     $this->storeRepositoryMock = $this->getMockBuilder('Magento\\Store\\Api\\StoreRepositoryInterface')->setMethods(['getList'])->getMockForAbstractClass();
     $this->locatorMock = $this->getMockBuilder('Magento\\Catalog\\Model\\Locator\\LocatorInterface')->setMethods(['getProduct', 'getWebsiteIds'])->getMockForAbstractClass();
     $this->productMock = $this->getMockBuilder('Magento\\Catalog\\Api\\Data\\ProductInterface')->setMethods(['getId'])->getMockForAbstractClass();
     $this->locatorMock->expects($this->any())->method('getProduct')->willReturn($this->productMock);
     $this->locatorMock->expects($this->any())->method('getWebsiteIds')->willReturn($this->assignedWebsites);
     $this->storeManagerMock = $this->getMockBuilder('Magento\\Store\\Model\\StoreManagerInterface')->setMethods(['isSingleStoreMode'])->getMockForAbstractClass();
     $this->storeManagerMock->expects($this->any())->method('isSingleStoreMode')->willReturn(false);
     $this->groupMock = $this->getMockBuilder('Magento\\Store\\Model\\ResourceModel\\Group\\Collection')->setMethods(['getId', 'getName', 'getWebsiteId'])->disableOriginalConstructor()->getMock();
     $this->groupMock->expects($this->any())->method('getWebsiteId')->willReturn(self::WEBSITE_ID);
     $this->groupMock->expects($this->any())->method('getId')->willReturn(self::GROUP_ID);
     $this->groupRepositoryMock->expects($this->any())->method('getList')->willReturn([$this->groupMock]);
     $this->storeViewMock = $this->getMockBuilder('Magento\\Store\\Model\\Store')->setMethods(['getName', 'getId', 'getStoreGroupId'])->disableOriginalConstructor()->getMock();
     $this->storeViewMock->expects($this->any())->method('getName')->willReturn(self::STORE_VIEW_NAME);
     $this->storeViewMock->expects($this->any())->method('getStoreGroupId')->willReturn(self::GROUP_ID);
     $this->storeViewMock->expects($this->any())->method('getId')->willReturn(self::STORE_VIEW_ID);
     $this->storeRepositoryMock->expects($this->any())->method('getList')->willReturn([$this->storeViewMock]);
     $this->productMock->expects($this->any())->method('getId')->willReturn(self::PRODUCT_ID);
     $this->secondWebsiteMock->expects($this->any())->method('getId')->willReturn($this->assignedWebsites[0]);
     $this->websiteMock->expects($this->any())->method('getId')->willReturn(self::WEBSITE_ID);
 }
예제 #24
0
 /**
  * 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));
 }
예제 #25
0
 protected function setUp()
 {
     $this->design = $this->getMockBuilder('Magento\\Framework\\View\\DesignInterface')->disableOriginalConstructor()->getMock();
     $this->registry = $this->getMockBuilder('Magento\\Framework\\Registry')->disableOriginalConstructor()->getMock();
     $this->appEmulation = $this->getMockBuilder('Magento\\Store\\Model\\App\\Emulation')->disableOriginalConstructor()->getMock();
     $this->storeManager = $this->getMockBuilder('Magento\\Store\\Model\\StoreManagerInterface')->disableOriginalConstructor()->getMock();
     $this->store = $this->getMockBuilder('Magento\\Store\\Model\\Store')->setMethods(['getFrontendName', 'getId'])->disableOriginalConstructor()->getMock();
     $this->store->expects($this->any())->method('getFrontendName')->will($this->returnValue('frontendName'));
     $this->store->expects($this->any())->method('getFrontendName')->will($this->returnValue('storeId'));
     $this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($this->store));
     $this->filesystem = $this->getMockBuilder('Magento\\Framework\\Filesystem')->disableOriginalConstructor()->getMock();
     $this->assetRepo = $this->getMockBuilder('Magento\\Framework\\View\\Asset\\Repository')->disableOriginalConstructor()->getMock();
     $this->scopeConfig = $this->getMockBuilder('Magento\\Framework\\App\\Config\\ScopeConfigInterface')->disableOriginalConstructor()->getMock();
     $this->emailConfig = $this->getMockBuilder('Magento\\Email\\Model\\Template\\Config')->disableOriginalConstructor()->getMock();
     $this->filterFactory = $this->getMockBuilder('Magento\\Email\\Model\\Template\\FilterFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock();
     $this->templateFactory = $this->getMockBuilder('Magento\\Email\\Model\\TemplateFactory')->disableOriginalConstructor()->getMock();
 }
예제 #26
0
 /**
  * @param string $baseUrl
  * @param bool $isUsingStaticUrls
  */
 protected function generalSettingsGetImageHtmlDeclaration($baseUrl, $isUsingStaticUrls)
 {
     $storeId = 1;
     $this->imagesHelper->setStoreId($storeId);
     $this->storeMock->expects($this->any())->method('getBaseUrl')->with(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA)->willReturn($baseUrl);
     $this->storeManagerMock->expects($this->any())->method('getStore')->willReturn($this->storeMock);
     $this->generalSettingsIsUsingStaticUrlsAllowed($isUsingStaticUrls);
 }
 public function testGetStoreId()
 {
     $this->model->setStoreId(3);
     $this->assertEquals(3, $this->model->getStoreId());
     $this->model->unsStoreId();
     $this->store->expects($this->once())->method('getId')->will($this->returnValue(5));
     $this->assertEquals(5, $this->model->getStoreId());
 }
예제 #28
0
 /**
  * @dataProvider currentCategoryProvider
  */
 public function testGetCurrentCategory($currentCategory)
 {
     $rootCategoryId = 333;
     $this->registry->expects($this->once())->method('registry')->with($this->equalTo('current_category'))->will($this->returnValue($currentCategory));
     $this->category->expects($this->any())->method('load')->with($this->equalTo($rootCategoryId))->will($this->returnValue($this->category));
     $this->store->expects($this->any())->method('getRootCategoryId')->will($this->returnValue($rootCategoryId));
     $result = $this->model->getCurrentCategory();
     $this->assertInstanceOf('\\Magento\\Catalog\\Model\\Category', $result);
 }
예제 #29
0
 protected function setUp()
 {
     $this->_storeManagerMock = $this->getMockBuilder('Magento\\Store\\Model\\StoreManager')->disableOriginalConstructor()->getMock();
     $this->_storeMock = $this->getMockBuilder('Magento\\Store\\Model\\Store')->disableOriginalConstructor()->getMock();
     $this->_storeMock->expects($this->any())->method('getBaseUrl')->will($this->returnValue('http://magento.com/'));
     $this->_storeMock->expects($this->any())->method('getCode')->will($this->returnValue('storeCode'));
     $this->_storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($this->_storeMock));
     $areaListMock = $this->getMock('Magento\\Framework\\App\\AreaList', [], [], '', false);
     $configScopeMock = $this->getMock('Magento\\Framework\\Config\\ScopeInterface');
     $areaListMock->expects($this->any())->method('getFrontName')->will($this->returnValue('soap'));
     $this->_requestMock = $this->getMockBuilder('Magento\\Framework\\Webapi\\Request')->disableOriginalConstructor()->getMock();
     $this->_soapServerFactory = $this->getMockBuilder('Magento\\Webapi\\Model\\Soap\\ServerFactory')->disableOriginalConstructor()->getMock();
     $this->_typeProcessor = $this->getMock('Magento\\Framework\\Reflection\\TypeProcessor', [], [], '', false);
     $this->_scopeConfig = $this->getMock('Magento\\Framework\\App\\Config\\ScopeConfigInterface');
     /** Init SUT. */
     $this->_soapServer = new \Magento\Webapi\Model\Soap\Server($areaListMock, $configScopeMock, $this->_requestMock, $this->_storeManagerMock, $this->_soapServerFactory, $this->_typeProcessor, $this->_scopeConfig);
     parent::setUp();
 }
예제 #30
0
 /**
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage Invalid store parameter.
  */
 public function testDispatchStoreParameterIsInvalidArray()
 {
     $this->storeMock->expects($this->never())->method('getDefaultCurrencyCode')->will($this->returnValue(self::CURRENCY_DEFAULT));
     $this->storeMock->expects($this->never())->method('getCode')->willReturn('default');
     $this->currentStoreMock->expects($this->never())->method('getCode')->willReturn('custom_store');
     $store = ['some' => ['code' => 500]];
     $this->httpRequestMock->expects($this->once())->method('getParam')->with($this->equalTo('___store'))->will($this->returnValue($store));
     $this->plugin->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock);
 }