當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。