Blame view

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