Ejemplo n.º 1
0
 public function testGetRelayUrl()
 {
     $baseUrl = 'http://base.url/';
     $defaultStoreMock = $this->getMockBuilder('Magento\\Store\\Model\\Store')->disableOriginalConstructor()->getMock();
     $defaultStoreMock->expects($this->once())->method('getBaseUrl')->with(\Magento\Framework\UrlInterface::URL_TYPE_LINK)->willReturn($baseUrl);
     $this->storeManagerMock->expects($this->once())->method('getDefaultStoreView')->willReturn(null);
     $this->storeManagerMock->expects($this->once())->method('getStores')->willReturn([$defaultStoreMock]);
     $this->assertSame('http://base.url/authorizenet/directpost_payment/backendResponse', $this->dataHelper->getRelayUrl());
 }
Ejemplo n.º 2
0
 public function testGetPreviewImageUrl()
 {
     /** @var $theme \Magento\Theme\Model\Theme|\PHPUnit_Framework_MockObject_MockObject */
     $theme = $this->getMock('Magento\\Theme\\Model\\Theme', ['getPreviewImage', 'isPhysical', '__wakeup'], [], '', false);
     $theme->expects($this->any())->method('getPreviewImage')->will($this->returnValue('image.png'));
     $store = $this->getMock('Magento\\Store\\Model\\Store', [], [], '', false);
     $store->expects($this->any())->method('getBaseUrl')->will($this->returnValue('http://localhost/'));
     $this->_storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store));
     $this->assertEquals('http://localhost/theme/preview/image.png', $this->model->getPreviewImageUrl($theme));
 }
Ejemplo n.º 3
0
 /**
  * @dataProvider getStoreDataProvider
  * @param $websiteId
  * @param $websiteStoreId
  * @param $storeId
  * @param $result
  */
 public function testGetStoreId($websiteId, $websiteStoreId, $storeId, $result)
 {
     if ($websiteId * 1) {
         $this->_model->setWebsiteId($websiteId);
         $website = new \Magento\Framework\DataObject(['store_ids' => [$websiteStoreId]]);
         $this->_storeManager->expects($this->once())->method('getWebsite')->will($this->returnValue($website));
     } else {
         $this->_model->setStoreId($storeId);
         $this->_storeManager->expects($this->never())->method('getWebsite');
     }
     $this->assertEquals($result, $this->_model->getStoreId());
 }
Ejemplo n.º 4
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));
 }
Ejemplo n.º 5
0
 public function setUp()
 {
     $objectManager = new ObjectManager($this);
     $this->productRepository = $this->getMockBuilder('Magento\\Catalog\\Model\\ProductRepository')->setMethods(['get'])->disableOriginalConstructor()->getMock();
     $this->store = $this->getMockBuilder('Magento\\Store\\Model\\Store')->setMethods(['getId', '__wakeup'])->disableOriginalConstructor()->getMock();
     $this->storeManager = $this->getMockBuilder('Magento\\Store\\Model\\StoreManager')->setMethods(['getStore'])->disableOriginalConstructor()->getMock();
     $this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($this->store));
     $this->optionConverter = $this->getMockBuilder('Magento\\Bundle\\Service\\V1\\Data\\Product\\OptionConverter')->setMethods(['createModelFromData', 'createDataFromModel', 'getModelFromData'])->disableOriginalConstructor()->getMock();
     $this->productType = $this->getMockBuilder('Magento\\Bundle\\Model\\Product\\Type')->setMethods(['getOptionsCollection'])->disableOriginalConstructor()->getMock();
     $this->option = $this->getMockBuilder('Magento\\Bundle\\Service\\V1\\Data\\Product\\Option')->disableOriginalConstructor()->getMock();
     $this->product = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->setMethods(['__wakeup', 'getTypeId', 'getSku'])->disableOriginalConstructor()->getMock();
     $this->optionModel = $this->getMockBuilder('Magento\\Bundle\\Model\\Option')->setMethods(['__wakeup', 'getId', 'delete', 'setStoreId', 'save'])->disableOriginalConstructor()->getMock();
     $this->optionCollection = $this->getMockBuilder('Magento\\Bundle\\Model\\Resource\\Option\\Collection')->setMethods(['setIdFilter', 'getFirstItem'])->disableOriginalConstructor()->getMock();
     $this->model = $objectManager->getObject('Magento\\Bundle\\Service\\V1\\Product\\Option\\WriteService', ['productRepository' => $this->productRepository, 'type' => $this->productType, 'storeManager' => $this->storeManager, 'optionConverter' => $this->optionConverter]);
 }
Ejemplo n.º 6
0
 /**
  * @return void
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function setUp()
 {
     $this->_eavConfig = $this->getMock('Magento\\Eav\\Model\\Config', array('getEntityType', 'getEntityTypeId'), array(), '', false);
     $this->_eavConfig->expects($this->atLeastOnce())->method('getEntityType')->with($this->equalTo('catalog_product'))->will($this->returnSelf());
     $this->_eavConfig->expects($this->atLeastOnce())->method('getEntityTypeId')->will($this->returnValue('1'));
     $this->_optionModel = $this->getMock('\\Magento\\CatalogImportExport\\Model\\Import\\Product\\Option', array(), array(), '', false);
     $this->_optionFactory = $this->getMock('\\Magento\\CatalogImportExport\\Model\\Import\\Product\\OptionFactory', array('create'), array(), '', false);
     $this->_optionFactory->expects($this->atLeastOnce())->method('create')->will($this->returnValue($this->_optionModel));
     $this->_storeManager = $this->getMock('\\Magento\\Store\\Model\\StoreManager', array('getWebsites', 'getStores'), array(), '', false);
     $this->_storeManager->expects($this->atLeastOnce())->method('getWebsites')->will($this->returnValue(array()));
     $this->_storeManager->expects($this->atLeastOnce())->method('getStores')->will($this->returnValue(array()));
     $this->_setCol = $this->getMock('\\Magento\\Eav\\Model\\Resource\\Entity\\Attribute\\Set\\Collection', array('setEntityTypeFilter'), array(), '', false);
     $this->_setCol->expects($this->atLeastOnce())->method('setEntityTypeFilter')->with($this->equalTo('1'))->will($this->returnValue(array()));
     $this->_setColFactory = $this->getMock('\\Magento\\Eav\\Model\\Resource\\Entity\\Attribute\\Set\\CollectionFactory', array('create'), array(), '', false);
     $this->_setColFactory->expects($this->atLeastOnce())->method('create')->will($this->returnValue($this->_setCol));
     $this->_importConfig = $this->getMock('\\Magento\\ImportExport\\Model\\Import\\Config', array('getEntityTypes'), array(), '', false);
     $this->_importConfig->expects($this->atLeastOnce())->method('getEntityTypes')->with('catalog_product')->will($this->returnValue(array()));
     $this->_categoryCol = $this->getMock('\\Magento\\Catalog\\Model\\Resource\\Category\\Collection', array('addNameToResult'), array(), '', false);
     $this->_categoryCol->expects($this->atLeastOnce())->method('addNameToResult')->will($this->returnValue(array()));
     $this->_categoryColFactory = $this->getMock('\\Magento\\Catalog\\Model\\Resource\\Category\\CollectionFactory', array('create'), array(), '', false);
     $this->_categoryColFactory->expects($this->atLeastOnce())->method('create')->will($this->returnValue($this->_categoryCol));
     $this->_product = $this->getMock('\\Magento\\Catalog\\Model\\Product', array('getProductEntitiesInfo', '__wakeup'), array(), '', false);
     $this->_product->expects($this->atLeastOnce())->method('getProductEntitiesInfo')->with($this->equalTo(array('entity_id', 'type_id', 'attribute_set_id', 'sku')))->will($this->returnValue(array()));
     $this->_productFactory = $this->getMock('\\Magento\\Catalog\\Model\\ProductFactory', array('create'), array(), '', false);
     $this->_productFactory->expects($this->atLeastOnce())->method('create')->will($this->returnValue($this->_product));
     $this->_customerGroupService = $this->getMock('Magento\\Customer\\Service\\V1\\CustomerGroupService', array('getGroups'), array(), '', false);
     $this->_customerGroupService->expects($this->atLeastOnce())->method('getGroups')->will($this->returnValue(array()));
     $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
     $this->_model = $objectManager->getObject('\\Magento\\CatalogImportExport\\Model\\Import\\Product', array('config' => $this->_eavConfig, 'optionFactory' => $this->_optionFactory, 'storeManager' => $this->_storeManager, 'setColFactory' => $this->_setColFactory, 'importConfig' => $this->_importConfig, 'categoryColFactory' => $this->_categoryColFactory, 'productFactory' => $this->_productFactory, 'customerGroupService' => $this->_customerGroupService));
 }
Ejemplo n.º 7
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));
 }
Ejemplo n.º 8
0
 public function testGetSwatchMediaUrl()
 {
     $storeMock = $this->getMock('\\Magento\\Store\\Model\\Store', ['getBaseUrl'], [], '', false);
     $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($storeMock);
     $storeMock->expects($this->once())->method('getBaseUrl')->with('media')->willReturn('http://url/pub/media/');
     $result = $this->mediaHelperObject->getSwatchMediaUrl();
     $this->assertEquals($result, 'http://url/pub/media/attribute/swatch');
 }
Ejemplo n.º 9
0
 public function testBeforeDispatchNoStoreCookie()
 {
     $storeCode = null;
     $this->storeCookieManagerMock->expects($this->once())->method('getStoreCodeFromCookie')->willReturn($storeCode);
     $this->storeManagerMock->expects($this->never())->method('getDefaultStoreView')->willReturn($this->storeMock);
     $this->storeRepositoryMock->expects($this->never())->method('getActiveStoreByCode');
     $this->storeCookieManagerMock->expects($this->never())->method('deleteStoreCookie')->with($this->storeMock);
     $this->plugin->beforeDispatch($this->subjectMock, $this->requestMock);
 }
Ejemplo n.º 10
0
 public function testAroundDispatchNoStoreCookie()
 {
     $storeCode = null;
     $this->storeManagerMock->expects($this->once())->method('getDefaultStoreView')->willReturn($this->storeMock);
     $this->storeCookieManagerMock->expects($this->once())->method('getStoreCodeFromCookie')->willReturn($storeCode);
     $this->storeRepositoryMock->expects($this->never())->method('getActiveStoreByCode');
     $this->storeCookieManagerMock->expects($this->never())->method('deleteStoreCookie')->with($this->storeMock);
     $this->assertEquals('ExpectedValue', $this->plugin->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock));
 }
Ejemplo n.º 11
0
 public function testSendNewAccountEmailWithoutStoreId()
 {
     $store = $this->getMock('Magento\\Store\\Model\\Store', [], [], '', false);
     $website = $this->getMock('Magento\\Store\\Model\\Website', [], [], '', false);
     $website->expects($this->once())->method('getStoreIds')->will($this->returnValue([1, 2, 3, 4]));
     $this->_storeManager->expects($this->once())->method('getWebsite')->with(1)->will($this->returnValue($website));
     $this->_storeManager->expects($this->once())->method('getStore')->with(1)->will($this->returnValue($store));
     $this->_config->expects($this->exactly(3))->method('getAttribute')->will($this->returnValue($this->_attribute));
     $this->_attribute->expects($this->exactly(3))->method('getIsVisible')->will($this->returnValue(true));
     $methods = ['setTemplateIdentifier', 'setTemplateOptions', 'setTemplateVars', 'setFrom', 'addTo'];
     foreach ($methods as $method) {
         $this->_transportBuilderMock->expects($this->once())->method($method)->will($this->returnSelf());
     }
     $transportMock = $this->getMock('Magento\\Framework\\Mail\\TransportInterface', [], [], '', false);
     $transportMock->expects($this->once())->method('sendMessage')->will($this->returnSelf());
     $this->_transportBuilderMock->expects($this->once())->method('getTransport')->will($this->returnValue($transportMock));
     $this->_model->setData(['website_id' => 1, 'store_id' => 1, 'email' => '*****@*****.**', 'firstname' => 'FirstName', 'lastname' => 'LastName', 'middlename' => 'MiddleName', 'prefix' => 'Prefix']);
     $this->_model->sendNewAccountEmail('registered');
 }
Ejemplo n.º 12
0
 /**
  * Set up
  */
 public function setUp()
 {
     $this->saleableItemMock = $this->getMock('Magento\\Catalog\\Model\\Product', ['getId', '__wakeup', 'getPriceInfo'], [], '', false);
     $this->dataTimeMock = $this->getMockForAbstractClass('Magento\\Framework\\Stdlib\\DateTime\\TimezoneInterface', [], '', false, true, true, []);
     $this->coreStoreMock = $this->getMock('\\Magento\\Store\\Model\\Store', [], [], '', false);
     $this->storeManagerMock = $this->getMock('Magento\\Store\\Model\\StoreManager', [], [], '', false);
     $this->storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($this->coreStoreMock));
     $this->customerSessionMock = $this->getMock('Magento\\Customer\\Model\\Session', [], [], '', false);
     $this->priceInfoMock = $this->getMock('\\Magento\\Framework\\Pricing\\PriceInfo', ['getAdjustments'], [], '', false);
     $this->catalogRuleResourceFactoryMock = $this->getMock('\\Magento\\CatalogRule\\Model\\Resource\\RuleFactory', ['create'], [], '', false);
     $this->catalogRuleResourceMock = $this->getMock('\\Magento\\CatalogRule\\Model\\Resource\\Rule', [], [], '', false);
     $this->coreWebsiteMock = $this->getMock('\\Magento\\Core\\Model\\Website', [], [], '', false);
     $this->priceInfoMock->expects($this->any())->method('getAdjustments')->will($this->returnValue([]));
     $this->saleableItemMock->expects($this->any())->method('getPriceInfo')->will($this->returnValue($this->priceInfoMock));
     $this->catalogRuleResourceFactoryMock->expects($this->any())->method('create')->will($this->returnValue($this->catalogRuleResourceMock));
     $this->calculator = $this->getMockBuilder('Magento\\Framework\\Pricing\\Adjustment\\Calculator')->disableOriginalConstructor()->getMock();
     $qty = 1;
     $this->object = new CatalogRulePrice($this->saleableItemMock, $qty, $this->calculator, $this->dataTimeMock, $this->storeManagerMock, $this->customerSessionMock, $this->catalogRuleResourceFactoryMock);
 }
Ejemplo n.º 13
0
 /**
  * @dataProvider getExpiredImages
  */
 public function testDeleteExpiredImages($website, $isFile, $filename, $mTime, $timeout, $mustDelete)
 {
     $this->_storeManager->expects($this->once())->method('getWebsites')->will($this->returnValue(isset($website) ? [$website] : []));
     if (isset($website)) {
         $this->_helper->expects($this->once())->method('getConfig')->with($this->equalTo('timeout'), new \PHPUnit_Framework_Constraint_IsIdentical($website->getDefaultStore()))->will($this->returnValue($timeout));
     } else {
         $this->_helper->expects($this->never())->method('getConfig');
     }
     $this->_adminHelper->expects($this->once())->method('getConfig')->with($this->equalTo('timeout'), new \PHPUnit_Framework_Constraint_IsNull())->will($this->returnValue($timeout));
     $timesToCall = isset($website) ? 2 : 1;
     $this->_directory->expects($this->exactly($timesToCall))->method('read')->will($this->returnValue([$filename]));
     $this->_directory->expects($this->exactly($timesToCall))->method('isFile')->will($this->returnValue($isFile));
     $this->_directory->expects($this->any())->method('stat')->will($this->returnValue(['mtime' => $mTime]));
     if ($mustDelete) {
         $this->_directory->expects($this->exactly($timesToCall))->method('delete')->with($filename);
     } else {
         $this->_directory->expects($this->never())->method('delete');
     }
     $this->_model->deleteExpiredImages();
 }
Ejemplo n.º 14
0
 /**
  * Create mock object for context
  */
 private function initContextMock()
 {
     $this->store = $this->getMockBuilder(Store::class)->disableOriginalConstructor()->setMethods(['getId', '__wakeup'])->getMock();
     $this->storeManager = $this->getMockBuilder(StoreManager::class)->disableOriginalConstructor()->setMethods(['getStore', '__wakeup'])->getMock();
     $this->storeManager->expects(static::any())->method('getStore')->willReturn($this->store);
     $this->urlBuilder = $this->getMockBuilder('Magento\\Framework\\UrlInterface')->getMockForAbstractClass();
     $this->requestMock = $this->getMockBuilder('Magento\\Framework\\App\\RequestInterface')->getMockForAbstractClass();
     $this->context = $this->getMockBuilder('Magento\\Framework\\View\\Element\\Template\\Context')->disableOriginalConstructor()->getMock();
     $this->context->expects($this->any())->method('getRequest')->willReturn($this->requestMock);
     $this->context->expects($this->any())->method('getUrlBuilder')->willReturn($this->urlBuilder);
     $this->context->expects($this->any())->method('getStoreManager')->willReturn($this->storeManager);
 }
Ejemplo n.º 15
0
 public function testLoadAttributesCollection()
 {
     $entityType = 'entityType';
     $formCode = 'formCode';
     $store = $this->getMockBuilder('Magento\\Model\\Store')->disableOriginalConstructor()->getMock();
     $this->storeManager->expects($this->once())->method('getStore')->will($this->returnValue($store));
     $this->attrFormCollection->expects($this->once())->method('setStore')->with($store)->will($this->returnSelf());
     $this->attrFormCollection->expects($this->once())->method('setEntityType')->with($entityType)->will($this->returnSelf());
     $this->attrFormCollection->expects($this->once())->method('addFormCodeFilter')->with($formCode)->will($this->returnSelf());
     $this->attrFormCollection->expects($this->once())->method('setSortOrder')->will($this->returnSelf());
     $actualValue = $this->attributeMetadataProvider->loadAttributesCollection($entityType, $formCode);
     $this->assertEquals($this->attrFormCollection, $actualValue);
 }
Ejemplo n.º 16
0
 public function testDispatchStoreParameterIsArray()
 {
     $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');
     $store = ['_data' => ['code' => 500]];
     $this->httpRequestMock->expects($this->once())->method('getParam')->with($this->equalTo('___store'))->will($this->returnValue($store));
     $this->storeManager->expects($this->once())->method('getStore')->with('500')->willReturn($this->currentStoreMock);
     $this->httpContextMock->expects($this->at(0))->method('setValue')->with(StoreManagerInterface::CONTEXT_STORE, 'custom_store', 'default');
     /** Make sure that current currency is taken from current store if no value is provided in session */
     $this->httpContextMock->expects($this->at(1))->method('setValue')->with(Context::CONTEXT_CURRENCY, self::CURRENCY_CURRENT_STORE, self::CURRENCY_DEFAULT);
     $result = $this->plugin->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock);
     $this->assertEquals('ExpectedValue', $result);
 }
Ejemplo n.º 17
0
 /**
  * @param $customerId
  * @param $key
  * @param $backUrl
  * @param $successUrl
  * @param $resultUrl
  * @param $isSetFlag
  * @param $successMessage
  *
  * @dataProvider getSuccessRedirectDataProvider
  */
 public function testSuccessRedirect($customerId, $key, $backUrl, $successUrl, $resultUrl, $isSetFlag, $successMessage)
 {
     $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue(false));
     $this->requestMock->expects($this->any())->method('getParam')->willReturnMap([['id', false, $customerId], ['key', false, $key], ['back_url', false, $backUrl]]);
     $this->customerRepositoryMock->expects($this->any())->method('getById')->with($customerId)->will($this->returnValue($this->customerDataMock));
     $email = '*****@*****.**';
     $this->customerDataMock->expects($this->once())->method('getEmail')->will($this->returnValue($email));
     $this->customerAccountManagementMock->expects($this->once())->method('activate')->with($this->equalTo($email), $this->equalTo($key))->will($this->returnValue($this->customerDataMock));
     $this->customerSessionMock->expects($this->any())->method('setCustomerDataAsLoggedIn')->with($this->equalTo($this->customerDataMock))->willReturnSelf();
     $this->messageManagerMock->expects($this->any())->method('addSuccess')->with($this->stringContains($successMessage))->willReturnSelf();
     $this->storeMock->expects($this->any())->method('getFrontendName')->will($this->returnValue('frontend'));
     $this->storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($this->storeMock));
     $this->urlMock->expects($this->any())->method('getUrl')->with($this->equalTo('*/*/index'), ['_secure' => true])->will($this->returnValue($successUrl));
     $this->redirectMock->expects($this->never())->method('success')->with($this->equalTo($resultUrl))->willReturn($resultUrl);
     $this->scopeConfigMock->expects($this->never())->method('isSetFlag')->with(Url::XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD, ScopeInterface::SCOPE_STORE)->willReturn($isSetFlag);
     $this->model->execute();
 }
Ejemplo n.º 18
0
 /**
  * @param $customerId
  * @param $password
  * @param $confirmationStatus
  * @param $successUrl
  * @param $isSetFlag
  * @param $successMessage
  *
  * @dataProvider getSuccessRedirectDataProvider
  */
 public function testSuccessRedirect($customerId, $password, $confirmationStatus, $successUrl, $isSetFlag, $successMessage)
 {
     $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue(false));
     $this->registration->expects($this->once())->method('isAllowed')->will($this->returnValue(true));
     $this->customerSessionMock->expects($this->once())->method('regenerateId');
     $this->customerMock->expects($this->any())->method('getId')->will($this->returnValue($customerId));
     $this->customerExtractorMock->expects($this->any())->method('extract')->with($this->equalTo('customer_account_create'), $this->equalTo($this->requestMock))->will($this->returnValue($this->customerMock));
     $this->requestMock->expects($this->once())->method('isPost')->will($this->returnValue(true));
     $this->requestMock->expects($this->any())->method('getPost')->will($this->returnValue(false));
     $this->requestMock->expects($this->any())->method('getParam')->willReturnMap([['password', null, $password], ['password_confirmation', null, $password], ['is_subscribed', false, true]]);
     $this->customerMock->expects($this->once())->method('setAddresses')->with($this->equalTo([]))->will($this->returnSelf());
     $this->accountManagement->expects($this->once())->method('createAccount')->with($this->equalTo($this->customerDetailsMock), $this->equalTo($password), '')->will($this->returnValue($this->customerMock));
     $this->accountManagement->expects($this->once())->method('getConfirmationStatus')->with($this->equalTo($customerId))->will($this->returnValue($confirmationStatus));
     $this->subscriberMock->expects($this->once())->method('subscribeCustomerById')->with($this->equalTo($customerId));
     $this->messageManagerMock->expects($this->any())->method('addSuccess')->with($this->stringContains($successMessage))->will($this->returnSelf());
     $this->urlMock->expects($this->any())->method('getUrl')->willReturnMap([['*/*/index', ['_secure' => true], $successUrl], ['*/*/create', ['_secure' => true], $successUrl]]);
     $this->redirectMock->expects($this->once())->method('success')->with($this->equalTo($successUrl))->will($this->returnValue($successUrl));
     $this->scopeConfigMock->expects($this->once())->method('isSetFlag')->with($this->equalTo(Url::XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD), $this->equalTo(ScopeInterface::SCOPE_STORE))->will($this->returnValue($isSetFlag));
     $this->storeMock->expects($this->any())->method('getFrontendName')->will($this->returnValue('frontend'));
     $this->storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($this->storeMock));
     $this->model->execute();
 }