vendor/assetic/tests/Assetic/Test/Cache/ConfigCacheTest.php
changeset 0 7f95f8617b0b
equal deleted inserted replaced
-1:000000000000 0:7f95f8617b0b
       
     1 <?php
       
     2 
       
     3 /*
       
     4  * This file is part of the Assetic package, an OpenSky project.
       
     5  *
       
     6  * (c) 2010-2011 OpenSky Project Inc
       
     7  *
       
     8  * For the full copyright and license information, please view the LICENSE
       
     9  * file that was distributed with this source code.
       
    10  */
       
    11 
       
    12 namespace Assetic\Test\Cache;
       
    13 
       
    14 use Assetic\Cache\ConfigCache;
       
    15 
       
    16 class ConfigCacheTest extends \PHPUnit_Framework_TestCase
       
    17 {
       
    18     private $dir;
       
    19     private $cache;
       
    20 
       
    21     protected function setUp()
       
    22     {
       
    23         $this->dir = sys_get_temp_dir().'/assetic/tests/config_cache';
       
    24         $this->cache = new ConfigCache($this->dir);
       
    25     }
       
    26 
       
    27     protected function tearDown()
       
    28     {
       
    29         foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->dir, \FilesystemIterator::SKIP_DOTS)) as $file) {
       
    30             unlink($file->getPathname());
       
    31         }
       
    32     }
       
    33 
       
    34     public function testCache()
       
    35     {
       
    36         $this->cache->set('foo', array(1, 2, 3));
       
    37         $this->assertEquals(array(1, 2, 3), $this->cache->get('foo'), '->get() returns the ->set() value');
       
    38     }
       
    39 
       
    40     public function testTimestamp()
       
    41     {
       
    42         $this->cache->set('bar', array(4, 5, 6));
       
    43         $this->assertInternalType('integer', $time = $this->cache->getTimestamp('bar'), '->getTimestamp() returns an integer');
       
    44         $this->assertNotEmpty($time, '->getTimestamp() returns a non-empty number');
       
    45     }
       
    46 
       
    47     public function testInvalidValue()
       
    48     {
       
    49         $this->setExpectedException('RuntimeException');
       
    50         $this->cache->get('_invalid');
       
    51     }
       
    52 
       
    53     public function testInvalidTimestamp()
       
    54     {
       
    55         $this->setExpectedException('RuntimeException');
       
    56         $this->cache->getTimestamp('_invalid');
       
    57     }
       
    58 
       
    59     public function testHas()
       
    60     {
       
    61         $this->cache->set('foo', 'bar');
       
    62         $this->assertTrue($this->cache->has('foo'));
       
    63         $this->assertFalse($this->cache->has('_invalid'));
       
    64     }
       
    65 }