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


PHP Config::expects方法代码示例

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


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

示例1: testExecute

 /**
  * @param bool $cacheState
  * @param bool $varnishIsEnabled
  * @param bool $scopeIsPrivate
  * @param int|null $blockTtl
  * @param string $expectedOutput
  * @dataProvider processLayoutRenderDataProvider
  */
 public function testExecute($cacheState, $varnishIsEnabled, $scopeIsPrivate, $blockTtl, $expectedOutput)
 {
     $eventMock = $this->getMock('Magento\\Framework\\Event', ['getLayout', 'getElementName', 'getTransport'], [], '', false);
     $this->_observerMock->expects($this->once())->method('getEvent')->will($this->returnValue($eventMock));
     $eventMock->expects($this->once())->method('getLayout')->will($this->returnValue($this->_layoutMock));
     $this->_configMock->expects($this->any())->method('isEnabled')->will($this->returnValue($cacheState));
     if ($cacheState) {
         $eventMock->expects($this->once())->method('getElementName')->will($this->returnValue('blockName'));
         $eventMock->expects($this->once())->method('getTransport')->will($this->returnValue($this->_transport));
         $this->_layoutMock->expects($this->once())->method('isCacheable')->will($this->returnValue(true));
         $this->_layoutMock->expects($this->any())->method('getUpdate')->will($this->returnSelf());
         $this->_layoutMock->expects($this->any())->method('getHandles')->will($this->returnValue([]));
         $this->_layoutMock->expects($this->once())->method('getBlock')->will($this->returnValue($this->_blockMock));
         if ($varnishIsEnabled) {
             $this->_blockMock->expects($this->once())->method('getData')->with('ttl')->will($this->returnValue($blockTtl));
             $this->_blockMock->expects($this->any())->method('getUrl')->will($this->returnValue('page_cache/block/wrapesi/with/handles/and/other/stuff'));
         }
         if ($scopeIsPrivate) {
             $this->_blockMock->expects($this->once())->method('getNameInLayout')->will($this->returnValue('testBlockName'));
             $this->_blockMock->expects($this->once())->method('isScopePrivate')->will($this->returnValue($scopeIsPrivate));
         }
         $this->_configMock->expects($this->any())->method('getType')->will($this->returnValue($varnishIsEnabled));
     }
     $this->_model->execute($this->_observerMock);
     $this->assertEquals($expectedOutput, $this->_transport['output']);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:34,代码来源:ProcessLayoutRenderElementTest.php

示例2: testAfterExecuteInvalidate

 public function testAfterExecuteInvalidate()
 {
     $subject = $this->getMockBuilder('Magento\\Catalog\\Model\\Indexer\\Category\\Product\\AbstractAction')->disableOriginalConstructor()->getMockForAbstractClass();
     $result = $this->getMockBuilder('Magento\\Catalog\\Model\\Indexer\\Category\\Product\\AbstractAction')->disableOriginalConstructor()->getMockForAbstractClass();
     $this->config->expects($this->once())->method('isEnabled')->willReturn(true);
     $this->typeList->expects($this->once())->method('invalidate')->with('full_page');
     $this->assertEquals($result, $this->execute->afterExecute($subject, $result));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:8,代码来源:ExecuteTest.php

示例3: testAroundDispatchDisabled

 /**
  * @dataProvider dataProvider
  */
 public function testAroundDispatchDisabled($state)
 {
     $this->configMock->expects($this->any())->method('getType')->will($this->returnValue(null));
     $this->versionMock->expects($this->never())->method('process');
     $this->stateMock->expects($this->any())->method('getMode')->will($this->returnValue($state));
     $this->responseMock->expects($this->never())->method('setHeader');
     $this->plugin->aroundDispatch($this->frontControllerMock, $this->closure, $this->requestMock);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:11,代码来源:VarnishPluginTest.php

示例4: testExecute

 /**
  * @dataProvider invalidateCacheDataProvider
  * @param bool $cacheState
  */
 public function testExecute($cacheState)
 {
     $this->_configMock->expects($this->once())->method('isEnabled')->will($this->returnValue($cacheState));
     if ($cacheState) {
         $this->_typeListMock->expects($this->once())->method('invalidate')->with($this->equalTo('full_page'));
     }
     $this->_model->execute($this->observerMock);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:12,代码来源:InvalidateCacheTest.php

示例5: testExecuteNoChanged

 /**
  * @dataProvider invalidateCacheDataProvider
  * @param bool $cacheState
  */
 public function testExecuteNoChanged($cacheState)
 {
     $this->configMock->expects($this->once())->method('isEnabled')->will($this->returnValue($cacheState));
     $this->typeListMock->expects($this->never())->method('invalidate');
     if ($cacheState) {
         $this->objectMock->expects($this->once())->method('getIdentities')->will($this->returnValue([]));
     }
     $this->model->execute($this->observerMock);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:13,代码来源:InvalidateCacheIfChangedTest.php

示例6: testExportVarnishConfigAction

 public function testExportVarnishConfigAction()
 {
     $fileContent = 'some conetnt';
     $filename = 'varnish.vcl';
     $responseMock = $this->getMockBuilder('Magento\\Framework\\App\\ResponseInterface')->disableOriginalConstructor()->getMock();
     $this->configMock->expects($this->once())->method('getVclFile')->will($this->returnValue($fileContent));
     $this->fileFactoryMock->expects($this->once())->method('create')->with($this->equalTo($filename), $this->equalTo($fileContent), $this->equalTo(DirectoryList::VAR_DIR))->will($this->returnValue($responseMock));
     $result = $this->action->executeInternal();
     $this->assertInstanceOf('Magento\\Framework\\App\\ResponseInterface', $result);
 }
开发者ID:nblair,项目名称:magescotch,代码行数:10,代码来源:ExportVarnishConfigTest.php

示例7: testCheckIfDepersonalize

 /**
  * @param array $requestResult
  * @param bool $moduleManagerResult
  * @param bool $cacheConfigResult
  * @param bool $layoutResult
  * @param bool $can Depersonalize
  * @dataProvider checkIfDepersonalizeDataProvider
  */
 public function testCheckIfDepersonalize(array $requestResult, $moduleManagerResult, $cacheConfigResult, $layoutResult, $canDepersonalize)
 {
     $this->requestMock->expects($this->any())->method('isAjax')->willReturn($requestResult['ajax']);
     $this->requestMock->expects($this->any())->method('isGet')->willReturn($requestResult['get']);
     $this->requestMock->expects($this->any())->method('isHead')->willReturn($requestResult['head']);
     $this->moduleManagerMock->expects($this->any())->method('isEnabled')->with('Magento_PageCache')->willReturn($moduleManagerResult);
     $this->cacheConfigMock->expects($this->any())->method('isEnabled')->willReturn($cacheConfigResult);
     $layoutMock = $this->getMockForAbstractClass('Magento\\Framework\\View\\LayoutInterface', [], '', false);
     $layoutMock->expects($this->any())->method('isCacheable')->willReturn($layoutResult);
     $object = new DepersonalizeChecker($this->requestMock, $this->moduleManagerMock, $this->cacheConfigMock);
     $this->assertEquals($canDepersonalize, $object->checkIfDepersonalize($layoutMock));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:20,代码来源:DepersonalizeCheckerTest.php

示例8: testAroundSave

 public function testAroundSave()
 {
     $subject = $this->getMockBuilder('Magento\\Catalog\\Model\\ResourceModel\\Attribute')->disableOriginalConstructor()->getMock();
     $attribute = $this->getMockBuilder('Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute')->disableOriginalConstructor()->getMock();
     $self = $this;
     $proceed = function ($object) use($self, $attribute) {
         $self->assertEquals($object, $attribute);
     };
     $this->config->expects($this->once())->method('isEnabled')->willReturn(true);
     $this->typeList->expects($this->once())->method('invalidate')->with('full_page');
     $this->save->aroundSave($subject, $proceed, $attribute);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:12,代码来源:SaveTest.php

示例9: testExecuteWithEmptyTags

 public function testExecuteWithEmptyTags()
 {
     $this->_configMock->expects($this->any())->method('isEnabled')->will($this->returnValue(true));
     $observerObject = $this->getMock('Magento\\Framework\\Event\\Observer');
     $observedObject = $this->getMock('Magento\\Store\\Model\\Store', [], [], '', false);
     $tags = [];
     $eventMock = $this->getMock('Magento\\Framework\\Event', ['getObject'], [], '', false);
     $eventMock->expects($this->once())->method('getObject')->will($this->returnValue($observedObject));
     $observerObject->expects($this->once())->method('getEvent')->will($this->returnValue($eventMock));
     $this->_configMock->expects($this->once())->method('getType')->will($this->returnValue(\Magento\PageCache\Model\Config::BUILT_IN));
     $observedObject->expects($this->once())->method('getIdentities')->will($this->returnValue($tags));
     $this->_cacheMock->expects($this->never())->method('clean');
     $this->_model->execute($observerObject);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:14,代码来源:FlushCacheByTagsTest.php

示例10: testExecute

 /**
  * Test case for cache invalidation
  *
  * @dataProvider flushCacheByTagsDataProvider
  * @param $cacheState
  */
 public function testExecute($cacheState)
 {
     $this->_configMock->expects($this->any())->method('isEnabled')->will($this->returnValue($cacheState));
     $observerObject = $this->getMock('Magento\\Framework\\Event\\Observer');
     $observedObject = $this->getMock('Magento\\Store\\Model\\Store', [], [], '', false);
     if ($cacheState) {
         $tags = ['cache_1', 'cache_group'];
         $expectedTags = ['cache_1', 'cache_group', 'cache'];
         $eventMock = $this->getMock('Magento\\Framework\\Event', ['getObject'], [], '', false);
         $eventMock->expects($this->once())->method('getObject')->will($this->returnValue($observedObject));
         $observerObject->expects($this->once())->method('getEvent')->will($this->returnValue($eventMock));
         $this->_configMock->expects($this->once())->method('getType')->will($this->returnValue(\Magento\PageCache\Model\Config::BUILT_IN));
         $observedObject->expects($this->once())->method('getIdentities')->will($this->returnValue($tags));
         $this->_cacheMock->expects($this->once())->method('clean')->with($this->equalTo($expectedTags));
     }
     $this->_model->execute($observerObject);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:23,代码来源:FlushCacheByTagsTest.php

示例11: testAfterAddressSave

 public function testAfterAddressSave()
 {
     $this->moduleManagerMock->expects($this->once())->method('isEnabled')->with('Magento_PageCache')->willReturn(true);
     $this->cacheConfigMock->expects($this->once())->method('isEnabled')->willReturn(true);
     $this->taxHelperMock->expects($this->any())->method('isCatalogPriceDisplayAffectedByTax')->willReturn(true);
     $address = $this->objectManager->getObject('Magento\\Customer\\Model\\Address');
     $address->setIsDefaultShipping(true);
     $address->setIsDefaultBilling(true);
     $address->setIsPrimaryBilling(true);
     $address->setIsPrimaryShipping(true);
     $address->setCountryId(1);
     $address->setData('postcode', 11111);
     $this->customerSessionMock->expects($this->once())->method('setDefaultTaxBillingAddress')->with(['country_id' => 1, 'region_id' => null, 'postcode' => 11111]);
     $this->customerSessionMock->expects($this->once())->method('setDefaultTaxShippingAddress')->with(['country_id' => 1, 'region_id' => null, 'postcode' => 11111]);
     $this->observerMock->expects($this->once())->method('getCustomerAddress')->willReturn($address);
     $this->session->afterAddressSave($this->observerMock);
 }
开发者ID:kid17,项目名称:magento2,代码行数:17,代码来源:SessionTest.php

示例12: 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

示例13: testExecute

 public function testExecute()
 {
     $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->any())->method('isEnabled')->willReturn(true);
     $customerMock = $this->getMockBuilder('Magento\\Customer\\Model\\Data\\Customer')->disableOriginalConstructor()->getMock();
     $this->observerMock->expects($this->once())->method('getData')->with('customer')->willReturn($customerMock);
     $address = $this->objectManager->getObject('Magento\\Customer\\Model\\Data\\Address');
     $address->setIsDefaultShipping(true);
     $address->setIsDefaultBilling(true);
     $address->setCountryId(1);
     $address->setPostCode(11111);
     $addresses = [$address];
     $customerMock->expects($this->once())->method('getAddresses')->willReturn($addresses);
     $this->customerSessionMock->expects($this->once())->method('setDefaultTaxBillingAddress')->with(['country_id' => 1, 'region_id' => null, 'postcode' => 11111]);
     $this->customerSessionMock->expects($this->once())->method('setDefaultTaxShippingAddress')->with(['country_id' => 1, 'region_id' => null, 'postcode' => 11111]);
     $this->session->execute($this->observerMock);
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:18,代码来源:CustomerLoggedInTest.php

示例14: 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

示例15: testExecute

 /**
  * Test case for flushing all the cache
  */
 public function testExecute()
 {
     $this->_configMock->expects($this->once())->method('getType')->will($this->returnValue(\Magento\PageCache\Model\Config::BUILT_IN));
     $this->fullPageCacheMock->expects($this->once())->method('clean');
     $this->_model->execute($this->observerMock);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:9,代码来源:FlushAllCacheTest.php


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