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


PHP CacheProvider::expects方法代码示例

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


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

示例1: setUp

 protected function setUp()
 {
     $this->cache = $this->getMockForAbstractClass('Doctrine\\Common\\Cache\\CacheProvider');
     $this->cache->expects($this->any())->method('fetch')->will($this->returnValue(false));
     $this->cache->expects($this->any())->method('save');
     $this->ownershipMetadataProvider = $this->getMockBuilder('OroB2B\\Bundle\\CustomerBundle\\Owner\\Metadata\\FrontendOwnershipMetadataProvider')->disableOriginalConstructor()->getMock();
     $this->managerRegistry = $this->getMock('Doctrine\\Common\\Persistence\\ManagerRegistry');
     $this->securityFacade = $this->getMockBuilder('Oro\\Bundle\\SecurityBundle\\SecurityFacade')->disableOriginalConstructor()->getMock();
     $this->container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
     $this->container->expects($this->any())->method('get')->willReturnMap([['orob2b_customer.owner.frontend_ownership_tree_provider.cache', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $this->cache], ['orob2b_customer.owner.frontend_ownership_metadata_provider', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $this->ownershipMetadataProvider], ['doctrine', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $this->managerRegistry], ['oro_security.security_facade', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $this->securityFacade]]);
     $this->treeProvider = new FrontendOwnerTreeProvider();
     $this->treeProvider->setContainer($this->container);
 }
开发者ID:hafeez3000,项目名称:orocommerce,代码行数:13,代码来源:FrontendOwnerTreeProviderTest.php

示例2: setUp

 protected function setUp()
 {
     $this->em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
     $managerRegistry = $this->getMock('Doctrine\\Common\\Persistence\\ManagerRegistry');
     $managerRegistry->expects($this->any())->method('getManagerForClass')->willReturn($this->em);
     $this->cache = $this->getMockForAbstractClass('Doctrine\\Common\\Cache\\CacheProvider');
     $this->cache->expects($this->any())->method('fetch')->will($this->returnValue(false));
     $this->cache->expects($this->any())->method('save');
     $this->securityFacade = $this->getMockBuilder('Oro\\Bundle\\SecurityBundle\\SecurityFacade')->disableOriginalConstructor()->getMock();
     $this->container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
     $this->container->expects($this->any())->method('get')->will($this->returnValueMap([['oro_security.ownership_tree_provider.cache', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $this->cache], ['oro_security.owner.ownership_metadata_provider', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, new OwnershipMetadataProviderStub($this, ['user' => 'Oro\\Bundle\\UserBundle\\Entity\\User', 'business_unit' => 'Oro\\Bundle\\OrganizationBundle\\Entity\\BusinessUnit'])], ['doctrine', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $managerRegistry], ['oro_security.security_facade', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $this->securityFacade]]));
     $this->treeProvider = new OwnerTreeProvider($this->em, $this->cache);
     $this->treeProvider->setContainer($this->container);
 }
开发者ID:northdakota,项目名称:platform,代码行数:14,代码来源:OwnerTreeProviderTest.php

示例3: testWarmUpCacheWithClassName

 public function testWarmUpCacheWithClassName()
 {
     $this->configProvider->expects($this->once())->method('hasConfig')->with(self::SOME_CLASS)->willReturn(true);
     $this->configProvider->expects($this->once())->method('getConfig')->with(self::SOME_CLASS)->willReturn($this->config);
     $this->cache->expects($this->once())->method('fetch')->with(self::SOME_CLASS)->willReturn(false);
     $this->cache->expects($this->once())->method('save')->with(self::SOME_CLASS);
     $this->provider->warmUpCache(self::SOME_CLASS);
 }
开发者ID:Maksold,项目名称:platform,代码行数:8,代码来源:AbstractMetadataProviderTest.php

示例4: testFullCache

 /**
  * Test load from cache cache
  */
 public function testFullCache()
 {
     $node = new Node();
     $node->setSubnodes(new ArrayCollection())->setId(1);
     $menu = new Menu();
     $menu->setSubnodes(new ArrayCollection())->addSubnode($node);
     $this->menuRepository->expects($this->any())->method('findOneBy');
     $this->cacheProvider->expects($this->once())->method('fetch')->will($this->returnValue('{"1":{"id":1,"name":null,"url":null,"subnodes":[]}}'));
     $this->cacheProvider->expects($this->any())->method('save');
     /**
      * Data is required twice to test how many times data is fetched from
      * cache provider, and to test than both times, returned data is the
      * same
      */
     $this->assertEquals($this->menuManager->loadMenuByCode('admin'), [1 => ['id' => 1, 'name' => null, 'url' => null, 'subnodes' => []]]);
     $this->assertEquals($this->menuManager->loadMenuByCode('admin'), [1 => ['id' => 1, 'name' => null, 'url' => null, 'subnodes' => []]]);
 }
开发者ID:hd-deman,项目名称:elcodi,代码行数:20,代码来源:MenuManagerTest.php

示例5: testWarmUpCacheFilterConfigsByScope

 public function testWarmUpCacheFilterConfigsByScope()
 {
     $config1 = new Config(new EntityConfigId('ownership', 'AcmeBundle\\Entity\\User'));
     $config2 = new Config(new EntityConfigId('ownership', 'AcmeBundle\\Entity\\Account'));
     $this->configProvider->expects($this->once())->method('getConfigs')->willReturn([$config1, $config2]);
     $this->securityConfigProvider->expects($this->atLeastOnce())->method('hasConfig')->willReturn(true);
     $securityConfig1 = $this->getMock('Oro\\Bundle\\EntityConfigBundle\\Config\\ConfigInterface');
     $securityConfig1->expects($this->once())->method('get')->with('group_name')->willReturn('');
     $securityConfig2 = $this->getMock('Oro\\Bundle\\EntityConfigBundle\\Config\\ConfigInterface');
     $securityConfig2->expects($this->once())->method('get')->with('group_name')->willReturn('commerce');
     $this->securityConfigProvider->expects($this->atLeastOnce())->method('getConfig')->will($this->onConsecutiveCalls($securityConfig1, $securityConfig2));
     $this->cache->expects($this->once())->method('fetch')->with($this->equalTo('AcmeBundle\\Entity\\Account'));
     $this->provider->warmUpCache();
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:14,代码来源:FrontendOwnershipMetadataProviderTest.php

示例6: testSaveDeferredAndCommit_SecondSaveFails

 public function testSaveDeferredAndCommit_SecondSaveFails()
 {
     $otherCacheItem = $this->getMock('Psr\\Cache\\CacheItemInterface');
     $this->cacheItem->expects($this->once())->method('getExpiration')->willReturn(new \DateTime('now +30 seconds'));
     $this->cacheItem->expects($this->any())->method('getKey')->willReturn($this->cacheKey);
     $otherCacheKey = 'cache-key-2';
     $otherCacheItem->expects($this->once())->method('getExpiration')->willReturn(new \DateTime('now +30 seconds'));
     $otherCacheItem->expects($this->any())->method('getKey')->willReturn($otherCacheKey);
     $cacheItemPool = $this->adapter->saveDeferred($this->cacheItem);
     $this->assertSame($this->adapter, $cacheItemPool);
     $cacheItemPool = $this->adapter->saveDeferred($otherCacheItem);
     $this->assertSame($this->adapter, $cacheItemPool);
     $this->cacheProvider->expects($this->at(0))->method('save')->willReturn(true);
     $this->cacheProvider->expects($this->at(1))->method('save')->willReturn(false);
     $this->assertFalse($this->adapter->commit());
 }
开发者ID:shieldo,项目名称:Cache,代码行数:16,代码来源:DoctrineCacheAdapterTest.php

示例7: testGetMetadataUndefinedClassWithCache

 public function testGetMetadataUndefinedClassWithCache()
 {
     $this->configProvider->expects($this->once())->method('hasConfig')->with($this->equalTo('UndefinedClass'))->will($this->returnValue(false));
     $this->configProvider->expects($this->never())->method('getConfig');
     $this->cache->expects($this->at(0))->method('fetch')->with($this->equalTo('UndefinedClass'))->will($this->returnValue(false));
     $this->cache->expects($this->at(2))->method('fetch')->with($this->equalTo('UndefinedClass'))->will($this->returnValue(true));
     $this->cache->expects($this->once())->method('save')->with($this->equalTo('UndefinedClass'), $this->equalTo(true));
     $this->entityClassResolver = null;
     $providerWithCleanLocalCache = clone $this->provider;
     $metadata = new OwnershipMetadata();
     // no cache
     $this->assertEquals($metadata, $this->provider->getMetadata('UndefinedClass'));
     // local cache
     $this->assertEquals($metadata, $this->provider->getMetadata('UndefinedClass'));
     // cache
     $this->assertEquals($metadata, $providerWithCleanLocalCache->getMetadata('UndefinedClass'));
 }
开发者ID:Maksold,项目名称:platform,代码行数:17,代码来源:OwnershipMetadataProviderTest.php


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