本文整理汇总了PHP中Magento\Framework\App\CacheInterface::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP CacheInterface::expects方法的具体用法?PHP CacheInterface::expects怎么用?PHP CacheInterface::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\App\CacheInterface
的用法示例。
在下文中一共展示了CacheInterface::expects方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCheckUpdate
/**
* @dataProvider checkUpdateDataProvider
* @param bool $callInbox
* @param string $curlRequest
*/
public function testCheckUpdate($callInbox, $curlRequest)
{
$mockName = 'Test Product Name';
$mockVersion = '0.0.0';
$mockEdition = 'Test Edition';
$mockUrl = 'http://test-url';
$this->productMetadata->expects($this->once())->method('getName')->willReturn($mockName);
$this->productMetadata->expects($this->once())->method('getVersion')->willReturn($mockVersion);
$this->productMetadata->expects($this->once())->method('getEdition')->willReturn($mockEdition);
$this->urlBuilder->expects($this->once())->method('getUrl')->with('*/*/*')->willReturn($mockUrl);
$configValues = ['timeout' => 2, 'useragent' => $mockName . '/' . $mockVersion . ' (' . $mockEdition . ')', 'referer' => $mockUrl];
$lastUpdate = 0;
$this->cacheManager->expects($this->once())->method('load')->will($this->returnValue($lastUpdate));
$this->curlFactory->expects($this->at(0))->method('create')->will($this->returnValue($this->curl));
$this->curl->expects($this->once())->method('setConfig')->with($configValues)->willReturnSelf();
$this->curl->expects($this->once())->method('read')->will($this->returnValue($curlRequest));
$this->backendConfig->expects($this->at(0))->method('getValue')->will($this->returnValue('1'));
$this->backendConfig->expects($this->once())->method('isSetFlag')->will($this->returnValue(false));
$this->backendConfig->expects($this->at(1))->method('getValue')->will($this->returnValue('http://feed.magento.com'));
$this->deploymentConfig->expects($this->once())->method('get')->with(ConfigOptionsListConstants::CONFIG_PATH_INSTALL_DATE)->will($this->returnValue('Sat, 6 Sep 2014 16:46:11 UTC'));
if ($callInbox) {
$this->inboxFactory->expects($this->once())->method('create')->will($this->returnValue($this->inboxModel));
$this->inboxModel->expects($this->once())->method('parse')->will($this->returnSelf());
} else {
$this->inboxFactory->expects($this->never())->method('create');
$this->inboxModel->expects($this->never())->method('parse');
}
$this->feed->checkUpdate();
}
示例2: testGetStoreLabelsByAttributeIdWithCacheSave
public function testGetStoreLabelsByAttributeIdWithCacheSave()
{
$attributeId = 1;
$cacheId = \Magento\Eav\Plugin\Model\ResourceModel\Entity\Attribute::STORE_LABEL_ATTRIBUTE . $attributeId;
$this->cache->expects($this->any())->method('load')->with($cacheId)->willReturn(false);
$this->cache->expects($this->any())->method('save')->with(serialize([$attributeId]), $cacheId, [\Magento\Eav\Model\Cache\Type::CACHE_TAG, \Magento\Eav\Model\Entity\Attribute::CACHE_TAG]);
$this->assertEquals([$attributeId], $this->getAttribute(true)->aroundGetStoreLabelsByAttributeId($this->subject, $this->mockPluginProceed([$attributeId]), $attributeId));
}
示例3: testAfterUpdateMview
/**
* Test afterUpdateMview
*
* @return void
*/
public function testAfterUpdateMview()
{
$tags = ['tag_name1', 'tag_name2'];
$this->eventManagerMock->expects($this->once())->method('dispatch')->with($this->equalTo('clean_cache_after_reindex'), $this->equalTo(['object' => $this->contextMock]));
$this->contextMock->expects($this->atLeastOnce())->method('getIdentities')->willReturn($tags);
$this->cacheMock->expects($this->once())->method('clean')->with($tags);
$this->plugin->afterUpdateMview($this->subjectMock);
}
示例4: testGetFeedsWithCache
public function testGetFeedsWithCache()
{
$dataProvider = $this->getMock('Magento\\Framework\\App\\Rss\\DataProviderInterface');
$dataProvider->expects($this->any())->method('getCacheKey')->will($this->returnValue('cache_key'));
$dataProvider->expects($this->any())->method('getCacheLifetime')->will($this->returnValue(100));
$dataProvider->expects($this->never())->method('getRssData');
$this->rss->setDataProvider($dataProvider);
$this->cacheInterface->expects($this->once())->method('load')->will($this->returnValue(serialize($this->feedData)));
$this->cacheInterface->expects($this->never())->method('save');
$this->assertEquals($this->feedData, $this->rss->getFeeds());
}
示例5: testExecuteRandom
public function testExecuteRandom()
{
$newKey = 'RSASHA9000VERYSECURESUPERMANKEY';
$this->requestMock->expects($this->at(0))->method('getPost')->with($this->equalTo('generate_random'))->willReturn(1);
$this->changeMock->expects($this->once())->method('changeEncryptionKey')->willReturn($newKey);
$this->managerMock->expects($this->once())->method('addSuccessMessage');
$this->managerMock->expects($this->once())->method('addNoticeMessage');
$this->cacheMock->expects($this->once())->method('clean');
$this->responseMock->expects($this->once())->method('setRedirect');
$this->model->execute();
}
示例6: testGetAttributesUsedForSortByWithCacheSave
public function testGetAttributesUsedForSortByWithCacheSave()
{
$entityTypeId = 'type';
$storeId = 'store';
$attributes = ['attributes'];
$this->subject->expects($this->any())->method('getEntityTypeId')->willReturn($entityTypeId);
$this->subject->expects($this->any())->method('getStoreId')->willReturn($storeId);
$cacheId = \Magento\Catalog\Plugin\Model\ResourceModel\Config::PRODUCT_LISTING_SORT_BY_ATTRIBUTES_CACHE_ID . $entityTypeId . '_' . $storeId;
$this->cache->expects($this->any())->method('load')->with($cacheId)->willReturn(false);
$this->cache->expects($this->any())->method('save')->with(serialize($attributes), $cacheId, [\Magento\Eav\Model\Cache\Type::CACHE_TAG, \Magento\Eav\Model\Entity\Attribute::CACHE_TAG]);
$this->assertEquals($attributes, $this->getConfig(true)->aroundGetAttributesUsedForSortBy($this->subject, $this->mockPluginProceed($attributes)));
}
示例7: testToHtml
/**
* Run test toHtml method
*
* @param bool $customerId
* @return void
*
* @dataProvider dataProviderToHtml
*/
public function testToHtml($customerId)
{
$cacheData = false;
$idQueryParam = 'id-query-param';
$sessionId = 'session-id';
$this->additional->setData('cache_lifetime', 789);
$this->additional->setData('cache_key', 'cache-key');
$this->eventManagerMock->expects($this->once())->method('dispatch')->with('view_block_abstract_to_html_before', ['block' => $this->additional]);
$this->scopeConfigMock->expects($this->once())->method('getValue')->with('advanced/modules_disable_output/Magento_Persistent', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)->willReturn(false);
// get cache
$this->cacheStateMock->expects($this->at(0))->method('isEnabled')->with(\Magento\Persistent\Block\Header\Additional::CACHE_GROUP)->willReturn(true);
// save cache
$this->cacheStateMock->expects($this->at(1))->method('isEnabled')->with(\Magento\Persistent\Block\Header\Additional::CACHE_GROUP)->willReturn(false);
$this->cacheMock->expects($this->once())->method('load')->willReturn($cacheData);
$this->sidResolverMock->expects($this->never())->method('getSessionIdQueryParam')->with($this->sessionMock)->willReturn($idQueryParam);
$this->sessionMock->expects($this->never())->method('getSessionId')->willReturn($sessionId);
// call protected _toHtml method
$sessionMock = $this->getMock('Magento\\Persistent\\Model\\Session', ['getCustomerId'], [], '', false);
$this->persistentSessionHelperMock->expects($this->atLeastOnce())->method('getSession')->willReturn($sessionMock);
$sessionMock->expects($this->atLeastOnce())->method('getCustomerId')->willReturn($customerId);
if ($customerId) {
$this->assertEquals('<span><a >Not you?</a></span>', $this->additional->toHtml());
} else {
$this->assertEquals('', $this->additional->toHtml());
}
}
示例8: testLoadChangeFromCache
/**
* @test
* @return void
* @covers \Magento\Theme\Model\Design::loadChange
* @covers \Magento\Theme\Model\Design::__construct
* @covers \Magento\Theme\Model\Design::_construct
*/
public function testLoadChangeFromCache()
{
$storeId = 1;
$localDate = '2\\28\\2000';
$date = '28-02-2000';
$cacheId = 'design_change_' . md5($storeId . $date);
$this->localeDate->expects($this->once())->method('scopeTimeStamp')->with($storeId)->willReturn($localDate);
$this->dateTime->expects($this->once())->method('formatDate')->with($localDate, false)->willReturn($date);
$this->cacheManager->expects($this->once())->method('load')->with($cacheId)->willReturn(serialize(['test' => 'data']));
$this->assertInstanceOf(get_class($this->model), $this->model->loadChange($storeId));
}
示例9: testSave
public function testSave()
{
$this->quoteRepositoryMock->expects($this->any())->method('get')->willReturn($this->quoteMock);
$this->quoteMock->expects($this->once())->method('getItemsCount')->willReturn(1);
$this->quoteMock->expects($this->once())->method('getIsVirtual')->willReturn(false);
$customerMock = $this->getMock('Magento\\Customer\\Api\\Data\\CustomerInterface', [], [], '', false);
$this->quoteMock->expects($this->once())->method('getCustomer')->willReturn($customerMock);
$this->messageMock->expects($this->any())->method('setCustomerId');
$this->messageMock->expects($this->any())->method('setGiftMessageId');
$this->cacheMock->expects($this->once())->method('save');
$this->assertTrue($this->cartRepository->save($this->cartId, $this->messageMock));
}
示例10: testSave
public function testSave()
{
$this->quoteRepositoryMock->expects($this->any())->method('get')->willReturn($this->quoteMock);
$this->quoteItemMock->expects($this->once())->method('getItemId')->willReturn($this->itemId);
$this->quoteItemMock->expects($this->once())->method('getProductType')->willReturn(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE);
$customerMock = $this->getMock('Magento\\Customer\\Api\\Data\\CustomerInterface', [], [], '', false);
$this->quoteMock->expects($this->once())->method('getCustomer')->willReturn($customerMock);
$this->messageMock->expects($this->any())->method('setCustomerId');
$this->messageMock->expects($this->any())->method('setGiftMessageId');
$this->cacheMock->expects($this->once())->method('save');
$this->assertTrue($this->itemRepository->save($this->cartId, $this->messageMock, $this->itemId));
}
示例11: testClear
public function testClear()
{
$this->cacheMock->expects($this->once())->method('clean')->with($this->equalTo([\Magento\Eav\Model\Cache\Type::CACHE_TAG, \Magento\Eav\Model\Entity\Attribute::CACHE_TAG]));
$this->config->clear();
}