Open Monograph Press  3.3.0
CachingConfigLoaderTest.php
1 <?php
2 
3 namespace Guzzle\Tests\Service;
4 
7 use Doctrine\Common\Cache\ArrayCache;
8 
13 {
14  public function testLoadsPhpFileIncludes()
15  {
16  $cache = new DoctrineCacheAdapter(new ArrayCache());
17  $loader = $this->getMockBuilder('Guzzle\Service\ConfigLoaderInterface')
18  ->setMethods(array('load'))
19  ->getMockForAbstractClass();
20  $data = array('foo' => 'bar');
21  $loader->expects($this->once())
22  ->method('load')
23  ->will($this->returnValue($data));
24  $cache = new CachingConfigLoader($loader, $cache);
25  $this->assertEquals($data, $cache->load('foo'));
26  $this->assertEquals($data, $cache->load('foo'));
27  }
28 
29  public function testDoesNotCacheArrays()
30  {
31  $cache = new DoctrineCacheAdapter(new ArrayCache());
32  $loader = $this->getMockBuilder('Guzzle\Service\ConfigLoaderInterface')
33  ->setMethods(array('load'))
34  ->getMockForAbstractClass();
35  $data = array('foo' => 'bar');
36  $loader->expects($this->exactly(2))
37  ->method('load')
38  ->will($this->returnValue($data));
39  $cache = new CachingConfigLoader($loader, $cache);
40  $this->assertEquals($data, $cache->load(array()));
41  $this->assertEquals($data, $cache->load(array()));
42  }
43 }
Guzzle\Tests\GuzzleTestCase
Definition: GuzzleTestCase.php:22
Guzzle\Tests\Service\CachingConfigLoaderTest\testLoadsPhpFileIncludes
testLoadsPhpFileIncludes()
Definition: CachingConfigLoaderTest.php:14
Guzzle\Cache\DoctrineCacheAdapter
Definition: DoctrineCacheAdapter.php:12
Guzzle\Service\CachingConfigLoader
Definition: CachingConfigLoader.php:10
Guzzle\Tests\Service\CachingConfigLoaderTest
Definition: CachingConfigLoaderTest.php:12
Guzzle\Tests\Service\CachingConfigLoaderTest\testDoesNotCacheArrays
testDoesNotCacheArrays()
Definition: CachingConfigLoaderTest.php:29
Guzzle\Tests\Service
Definition: AbstractConfigLoaderTest.php:3