当前位置: 首页>>代码示例>>PHP>>正文


PHP Context::expects方法代码示例

本文整理汇总了PHP中Magento\Framework\App\Http\Context::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP Context::expects方法的具体用法?PHP Context::expects怎么用?PHP Context::expects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\App\Http\Context的用法示例。


在下文中一共展示了Context::expects方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testAroundDispatch

 /**
  * Test aroundDispatch
  */
 public function testAroundDispatch()
 {
     $this->customerSessionMock->expects($this->once())->method('getCustomerGroupId')->will($this->returnValue(1));
     $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue(true));
     $this->httpContextMock->expects($this->atLeastOnce())->method('setValue')->will($this->returnValueMap([[Context::CONTEXT_GROUP, 'UAH', $this->httpContextMock], [Context::CONTEXT_AUTH, 0, $this->httpContextMock]]));
     $this->assertEquals('ExpectedValue', $this->plugin->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:10,代码来源:ContextPluginTest.php

示例2: testGetCacheKeyInfo

 public function testGetCacheKeyInfo()
 {
     $store = $this->getMockBuilder('\\Magento\\Store\\Model\\Store')->disableOriginalConstructor()->setMethods(['getId'])->getMock();
     $store->expects($this->once())->method('getId')->willReturn(1);
     $this->storeManager->expects($this->once())->method('getStore')->willReturn($store);
     $theme = $this->getMock('\\Magento\\Framework\\View\\Design\\ThemeInterface');
     $theme->expects($this->once())->method('getId')->willReturn('blank');
     $this->design->expects($this->once())->method('getDesignTheme')->willReturn($theme);
     $this->httpContext->expects($this->once())->method('getValue')->willReturn('context_group');
     $this->productsList->setData('conditions', 'some_serialized_conditions');
     $this->request->expects($this->once())->method('getParam')->with('np')->willReturn(1);
     $cacheKey = ['CATALOG_PRODUCTS_LIST_WIDGET', 1, 'blank', 'context_group', 1, 5, 'some_serialized_conditions'];
     $this->assertEquals($cacheKey, $this->productsList->getCacheKeyInfo());
 }
开发者ID:nja78,项目名称:magento2,代码行数:14,代码来源:ProductsListTest.php

示例3: testGetCacheKeyInfo

 public function testGetCacheKeyInfo()
 {
     $store = $this->getMock('Magento\\Store\\Model\\Store', [], [], '', false);
     $store->expects($this->atLeastOnce())->method('getId')->willReturn(55);
     $store->expects($this->atLeastOnce())->method('getRootCategoryId')->willReturn(60);
     $this->storeManager->expects($this->atLeastOnce())->method('getStore')->willReturn($store);
     $theme = $this->getMock('\\Magento\\Framework\\View\\Design\\ThemeInterface');
     $theme->expects($this->atLeastOnce())->method('getId')->willReturn(65);
     $this->design->expects($this->atLeastOnce())->method('getDesignTheme')->willReturn($theme);
     $this->httpContext->expects($this->atLeastOnce())->method('getValue')->with(\Magento\Customer\Model\Context::CONTEXT_GROUP)->willReturn(70);
     $this->block->setTemplate('block_template');
     $this->block->setNameInLayout('block_name');
     $expectedResult = ['CATALOG_NAVIGATION', 55, 65, 70, 'template' => 'block_template', 'name' => 'block_name', 60, 'category_path' => 60, 'short_cache_id' => 'c3de6d1160d1e7730b04d6cad409a2b4'];
     $this->assertEquals($expectedResult, $this->block->getCacheKeyInfo());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:NavigationTest.php

示例4: testDispatchCurrentStoreCurrency

 public function testDispatchCurrentStoreCurrency()
 {
     $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);
     $this->assertEquals('ExpectedValue', $this->plugin->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:7,代码来源:ContextTest.php

示例5: testAroundDispatch

 public function testAroundDispatch()
 {
     $this->moduleManagerMock->expects($this->any())->method('isEnabled')->with('Magento_PageCache')->willReturn(true);
     $this->cacheConfigMock->expects($this->any())->method('isEnabled')->willReturn(true);
     $this->taxHelperMock->expects($this->any())->method('isCatalogPriceDisplayAffectedByTax')->willReturn(true);
     $this->customerSessionMock->expects($this->once())->method('getDefaultTaxBillingAddress')->willReturn(['country_id' => 1, 'region_id' => null, 'postcode' => 11111]);
     $this->customerSessionMock->expects($this->once())->method('getDefaultTaxShippingAddress')->willReturn(['country_id' => 1, 'region_id' => null, 'postcode' => 11111]);
     $this->customerSessionMock->expects($this->once())->method('getCustomerTaxClassId')->willReturn(1);
     $this->taxCalculationMock->expects($this->once())->method('getTaxRates')->with(['country_id' => 1, 'region_id' => null, 'postcode' => 11111], ['country_id' => 1, 'region_id' => null, 'postcode' => 11111], 1)->willReturn([]);
     $this->httpContextMock->expects($this->once())->method('setValue')->with('tax_rates', [], 0);
     $action = $this->objectManager->getObject('Magento\\Framework\\App\\Action\\Action');
     $request = $this->getMock('\\Magento\\Framework\\App\\Request\\Http', ['getActionName'], [], '', false);
     $expectedResult = 'expectedResult';
     $proceed = function ($request) use($expectedResult) {
         return $expectedResult;
     };
     $this->contextPlugin->aroundDispatch($action, $proceed, $request);
 }
开发者ID:kid17,项目名称:magento2,代码行数:18,代码来源:ContextPluginTest.php

示例6: testAroundDispatch

 /**
  * 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));
 }
开发者ID:buskamuza,项目名称:magento2-skeleton,代码行数:15,代码来源:ContextTest.php

示例7: testSetNoCacheHeaders

 /**
  * Test setting public cache headers
  */
 public function testSetNoCacheHeaders()
 {
     $timestamp = 1000000;
     $pragma = 'no-cache';
     $cacheControl = 'max-age=0, must-revalidate, no-cache, no-store';
     $expiresResult = 'Thu, 01 Jan 1970 00:00:00 GMT';
     $this->dateTimeMock->expects($this->once())->method('strToTime')->with('-1 year')->willReturn($timestamp);
     $this->dateTimeMock->expects($this->once())->method('gmDate')->with(Http::EXPIRATION_TIMESTAMP_FORMAT, $timestamp)->willReturn($expiresResult);
     $this->model->setNoCacheHeaders();
     $this->assertEquals($pragma, $this->model->getHeader('Pragma')->getFieldValue());
     $this->assertEquals($cacheControl, $this->model->getHeader('Cache-Control')->getFieldValue());
     $this->assertEquals($expiresResult, $this->model->getHeader('Expires')->getFieldValue());
 }
开发者ID:nja78,项目名称:magento2,代码行数:16,代码来源:HttpTest.php

示例8: testDispatchStoreParameterIsArray

 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);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:14,代码来源:ContextTest.php

示例9: testInitOrders

 public function testInitOrders()
 {
     $customerId = 25;
     $attribute = ['customer_id', 'status'];
     $this->httpContext->expects($this->once())->method('getValue')->with($this->equalTo(Context::CONTEXT_AUTH))->will($this->returnValue(true));
     $this->customerSession->expects($this->once())->method('getCustomerId')->will($this->returnValue($customerId));
     $statuses = ['pending', 'processing', 'complete'];
     $this->orderConfig->expects($this->once())->method('getVisibleOnFrontStatuses')->will($this->returnValue($statuses));
     $this->orderCollection->expects($this->at(0))->method('addAttributeToFilter')->with($attribute[0], $this->equalTo($customerId))->will($this->returnSelf());
     $this->orderCollection->expects($this->at(1))->method('addAttributeToFilter')->with($attribute[1], $this->equalTo(['in' => $statuses]))->will($this->returnSelf());
     $this->orderCollection->expects($this->at(2))->method('addAttributeToSort')->with('created_at', 'desc')->will($this->returnSelf());
     $this->orderCollection->expects($this->at(3))->method('setPage')->with($this->equalTo(1), $this->equalTo(1))->will($this->returnSelf());
     $this->orderCollectionFactory->expects($this->atLeastOnce())->method('create')->will($this->returnValue($this->orderCollection));
     $this->createBlockObject();
     $this->assertEquals($this->orderCollection, $this->block->getOrders());
 }
开发者ID:nja78,项目名称:magento2,代码行数:16,代码来源:SidebarTest.php

示例10: testGetFromRequest

 /**
  * @covers \Magento\Store\Model\StorageFactory::_checkRequestStore
  * @covers \Magento\Store\Model\StorageFactory::getActiveStoreByCode
  * @covers \Magento\Store\Model\StorageFactory::setCurrentStore
  *
  * @dataProvider getFromRequestDataProvider
  *
  * @param bool $isActiveStore
  * @param bool $isDefault
  */
 public function testGetFromRequest($isActiveStore, $isDefault)
 {
     $this->_appStateMock->expects($this->once())->method('isInstalled')->will($this->returnValue(true));
     $storeDefault = $this->getMock('Magento\\Store\\Model\\Store', array(), array(), '', false);
     if (!$isDefault) {
         $storeDefault->expects($this->atLeastOnce())->method('getId')->will($this->returnValue(22));
         $this->_httpContext->expects($this->once())->method('setValue')->with(\Magento\Store\Model\Store::ENTITY, 'store1', \Magento\Store\Model\Store::DEFAULT_CODE)->will($this->returnSelf());
     }
     $this->website->expects($this->any())->method('getDefaultStore')->will($this->returnValue(!$isDefault ? $storeDefault : $this->store));
     $this->website->expects($this->atLeastOnce())->method('getDefaultGroupId')->will($this->returnValue(11));
     $this->group->expects($this->any())->method('getDefaultStoreId')->will($this->returnValue(21));
     $this->store->expects($this->atLeastOnce())->method('getId')->will($this->returnValue(21));
     $this->store->expects($this->once())->method('getIsActive')->will($this->returnValue($isActiveStore));
     $this->store->expects($this->any())->method('getWebsite')->will($this->returnValue($this->website));
     $this->storage->expects($this->any())->method('setCurrentStore')->with('store1');
     $this->_objectManagerMock->expects($this->once())->method('create')->will($this->returnValue($this->storage));
     $this->request->expects($this->atLeastOnce())->method('getParam')->with('___store')->will($this->returnValue('store1'));
     $this->assertEquals($this->storage, $this->_model->get($this->_arguments));
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:29,代码来源:StorageFactoryTest.php

示例11: testAroundDispatchBasedOnShipping

 public function testAroundDispatchBasedOnShipping()
 {
     $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->willReturn(true);
     $this->moduleManagerMock->expects($this->once())->method('isEnabled')->with('Magento_PageCache')->willReturn(true);
     $this->cacheConfigMock->expects($this->once())->method('isEnabled')->willReturn(true);
     $this->weeeHelperMock->expects($this->once())->method('isEnabled')->willReturn(true);
     $this->taxHelperMock->expects($this->once())->method('getTaxBasedOn')->willReturn('shipping');
     $storeMock = $this->getMockBuilder('Magento\\Store\\Model\\Store')->disableOriginalConstructor()->getMock();
     $storeMock->expects($this->once())->method('getWebsiteId')->willReturn(1);
     $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($storeMock);
     $this->scopeConfigMock->expects($this->at(0))->method('getValue')->with(\Magento\Tax\Model\Config::CONFIG_XML_PATH_DEFAULT_COUNTRY, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, null)->willReturn('US');
     $this->scopeConfigMock->expects($this->at(1))->method('getValue')->with(\Magento\Tax\Model\Config::CONFIG_XML_PATH_DEFAULT_REGION, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, null)->willReturn(0);
     $this->customerSessionMock->expects($this->once())->method('getDefaultTaxShippingAddress')->willReturn(['country_id' => 'US', 'region_id' => 1]);
     $this->weeeTaxMock->expects($this->once())->method('isWeeeInLocation')->with('US', 1, 1)->willReturn(true);
     $this->httpContextMock->expects($this->once())->method('setValue')->with('weee_tax_region', ['countryId' => 'US', 'regionId' => 1], 0);
     $action = $this->objectManager->getObject('Magento\\Framework\\App\\Test\\Unit\\Action\\Stub\\ActionStub');
     $request = $this->getMock('\\Magento\\Framework\\App\\Request\\Http', ['getActionName'], [], '', false);
     $expectedResult = 'expectedResult';
     $proceed = function ($request) use($expectedResult) {
         return $expectedResult;
     };
     $this->contextPlugin->aroundDispatch($action, $proceed, $request);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:23,代码来源:ContextPluginTest.php

示例12: testVaryStringSource

 /**
  * @param $cookieExists
  *
  * @dataProvider trueFalseDataProvider
  */
 public function testVaryStringSource($cookieExists)
 {
     $this->requestMock->method('get')->willReturn($cookieExists ? 'vary-string-from-cookie' : null);
     $this->contextMock->expects($cookieExists ? $this->never() : $this->once())->method('getVaryString');
     $this->model->getValue();
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:11,代码来源:IdentifierTest.php


注:本文中的Magento\Framework\App\Http\Context::expects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。