public function createService(ServiceLocatorInterface $createService)
 {
     $countryCache = new Cache();
     $countryCache->setServiceManager($createService);
     $countryCache->setPopulator(new Country());
     return $countryCache;
 }
Example #2
0
 public function testGettingExistingCacheEntity()
 {
     $mockConfig = array('phpug' => array('entity' => array('cache' => array('country' => array('cacheLifeTime' => 'P1M')))));
     $mockCache = M::mock('\\Phpug\\Entity\\Cache');
     $mockCache->shouldReceive('setType')->andReturn($mockCache);
     $mockCache->shouldReceive('getType')->andReturn('country');
     $mockCache->shouldReceive('setGroup')->andReturn($mockCache);
     $mockCache->shouldReceive('add');
     $mockCache->shouldReceive('getLastChangeDate')->andReturn(new \DateTime());
     $mockCache2 = M::mock('\\Phpug\\Entity\\Cache');
     $mockCache2->shouldReceive('getType')->andReturn('foo');
     $sm = M::mock('\\Zend\\ServiceManager\\ServiceManager');
     $sm->shouldReceive('get')->with('Phpug\\Entity\\Cache')->andReturn($mockCache);
     $sm->shouldReceive('get')->with('config')->andReturn($mockConfig);
     $ug = M::mock('\\Phpug\\Entity\\Usergroup', array('foo'))->shouldReceive('getCaches')->once()->andReturn(array($mockCache2, $mockCache))->mock();
     $country = new Country();
     $country->setUsergroup($ug);
     $this->assertSame($country, $country->setServiceManager($sm));
     $this->assertAttributeSame($sm, 'serviceManager', $country);
     $this->assertSame($mockCache, $country->getCache());
 }