|
0
|
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\FilesystemCache; |
|
|
15 |
|
|
|
16 |
class FilesystemCacheTest extends \PHPUnit_Framework_TestCase |
|
|
17 |
{ |
|
|
18 |
public function testCache() |
|
|
19 |
{ |
|
|
20 |
$cache = new FilesystemCache(sys_get_temp_dir()); |
|
|
21 |
|
|
|
22 |
$this->assertFalse($cache->has('foo')); |
|
|
23 |
|
|
|
24 |
$cache->set('foo', 'bar'); |
|
|
25 |
$this->assertEquals('bar', $cache->get('foo')); |
|
|
26 |
|
|
|
27 |
$this->assertTrue($cache->has('foo')); |
|
|
28 |
|
|
|
29 |
$cache->remove('foo'); |
|
|
30 |
$this->assertFalse($cache->has('foo')); |
|
|
31 |
} |
|
|
32 |
|
|
|
33 |
public function testSetCreatesDir() |
|
|
34 |
{ |
|
|
35 |
$dir = sys_get_temp_dir().'/assetic/fscachetest'; |
|
|
36 |
|
|
|
37 |
$tearDown = function() use($dir) |
|
|
38 |
{ |
|
|
39 |
array_map('unlink', glob($dir.'/*')); |
|
|
40 |
@rmdir($dir); |
|
|
41 |
}; |
|
|
42 |
|
|
|
43 |
$tearDown(); |
|
|
44 |
|
|
|
45 |
$cache = new FilesystemCache($dir); |
|
|
46 |
$cache->set('foo', 'bar'); |
|
|
47 |
|
|
|
48 |
$this->assertFileExists($dir.'/foo'); |
|
|
49 |
|
|
|
50 |
$tearDown(); |
|
|
51 |
} |
|
|
52 |
} |