Initial commit with Symfony 2.1+Vendors
Signed-off-by: Gergely POLONKAI (W00d5t0ck) <polesz@w00d5t0ck.info>
This commit is contained in:
42
vendor/kriswallsmith/assetic/tests/Assetic/Test/Cache/ApcCacheTest.php
vendored
Normal file
42
vendor/kriswallsmith/assetic/tests/Assetic/Test/Cache/ApcCacheTest.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Assetic package, an OpenSky project.
|
||||
*
|
||||
* (c) 2010-2012 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\ApcCache;
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
*/
|
||||
class ApcCacheTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
if (!extension_loaded('apc') || !ini_get('apc.enable_cli')) {
|
||||
$this->markTestSkipped('APC must be installed and enabled.');
|
||||
}
|
||||
}
|
||||
|
||||
public function testCache()
|
||||
{
|
||||
$cache = new ApcCache();
|
||||
|
||||
$this->assertFalse($cache->has('foo'));
|
||||
|
||||
$cache->set('foo', 'bar');
|
||||
$this->assertEquals('bar', $cache->get('foo'));
|
||||
|
||||
$this->assertTrue($cache->has('foo'));
|
||||
|
||||
$cache->remove('foo');
|
||||
$this->assertFalse($cache->has('foo'));
|
||||
}
|
||||
}
|
65
vendor/kriswallsmith/assetic/tests/Assetic/Test/Cache/ConfigCacheTest.php
vendored
Normal file
65
vendor/kriswallsmith/assetic/tests/Assetic/Test/Cache/ConfigCacheTest.php
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Assetic package, an OpenSky project.
|
||||
*
|
||||
* (c) 2010-2012 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'));
|
||||
}
|
||||
}
|
111
vendor/kriswallsmith/assetic/tests/Assetic/Test/Cache/ExpiringCacheTest.php
vendored
Normal file
111
vendor/kriswallsmith/assetic/tests/Assetic/Test/Cache/ExpiringCacheTest.php
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Assetic package, an OpenSky project.
|
||||
*
|
||||
* (c) 2010-2012 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\ExpiringCache;
|
||||
|
||||
class ExpiringCacheTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $inner;
|
||||
private $lifetime;
|
||||
private $cache;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->inner = $this->getMock('Assetic\\Cache\\CacheInterface');
|
||||
$this->lifetime = 3600;
|
||||
$this->cache = new ExpiringCache($this->inner, $this->lifetime);
|
||||
}
|
||||
|
||||
public function testHasExpired()
|
||||
{
|
||||
$key = 'asdf';
|
||||
$expiresKey = 'asdf.expires';
|
||||
$thePast = 0;
|
||||
|
||||
$this->inner->expects($this->once())
|
||||
->method('has')
|
||||
->with($key)
|
||||
->will($this->returnValue(true));
|
||||
$this->inner->expects($this->once())
|
||||
->method('get')
|
||||
->with($expiresKey)
|
||||
->will($this->returnValue($thePast));
|
||||
$this->inner->expects($this->at(2))
|
||||
->method('remove')
|
||||
->with($expiresKey);
|
||||
$this->inner->expects($this->at(3))
|
||||
->method('remove')
|
||||
->with($key);
|
||||
|
||||
$this->assertFalse($this->cache->has($key), '->has() returns false if an expired value exists');
|
||||
}
|
||||
|
||||
public function testHasNotExpired()
|
||||
{
|
||||
$key = 'asdf';
|
||||
$expiresKey = 'asdf.expires';
|
||||
$theFuture = time() * 2;
|
||||
|
||||
$this->inner->expects($this->once())
|
||||
->method('has')
|
||||
->with($key)
|
||||
->will($this->returnValue(true));
|
||||
$this->inner->expects($this->once())
|
||||
->method('get')
|
||||
->with($expiresKey)
|
||||
->will($this->returnValue($theFuture));
|
||||
|
||||
$this->assertTrue($this->cache->has($key), '->has() returns true if a value the not expired');
|
||||
}
|
||||
|
||||
public function testSetLifetime()
|
||||
{
|
||||
$key = 'asdf';
|
||||
$expiresKey = 'asdf.expires';
|
||||
$value = 'qwerty';
|
||||
|
||||
$this->inner->expects($this->at(0))
|
||||
->method('set')
|
||||
->with($expiresKey, $this->greaterThanOrEqual(time() + $this->lifetime));
|
||||
$this->inner->expects($this->at(1))
|
||||
->method('set')
|
||||
->with($key, $value);
|
||||
|
||||
$this->cache->set($key, $value);
|
||||
}
|
||||
|
||||
public function testRemove()
|
||||
{
|
||||
$key = 'asdf';
|
||||
$expiresKey = 'asdf.expires';
|
||||
|
||||
$this->inner->expects($this->at(0))
|
||||
->method('remove')
|
||||
->with($expiresKey);
|
||||
$this->inner->expects($this->at(1))
|
||||
->method('remove')
|
||||
->with($key);
|
||||
|
||||
$this->cache->remove($key);
|
||||
}
|
||||
|
||||
public function testGet()
|
||||
{
|
||||
$this->inner->expects($this->once())
|
||||
->method('get')
|
||||
->with('foo')
|
||||
->will($this->returnValue('bar'));
|
||||
|
||||
$this->assertEquals('bar', $this->cache->get('foo'), '->get() returns the cached value');
|
||||
}
|
||||
}
|
52
vendor/kriswallsmith/assetic/tests/Assetic/Test/Cache/FilesystemCacheTest.php
vendored
Normal file
52
vendor/kriswallsmith/assetic/tests/Assetic/Test/Cache/FilesystemCacheTest.php
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Assetic package, an OpenSky project.
|
||||
*
|
||||
* (c) 2010-2012 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\FilesystemCache;
|
||||
|
||||
class FilesystemCacheTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testCache()
|
||||
{
|
||||
$cache = new FilesystemCache(sys_get_temp_dir());
|
||||
|
||||
$this->assertFalse($cache->has('foo'));
|
||||
|
||||
$cache->set('foo', 'bar');
|
||||
$this->assertEquals('bar', $cache->get('foo'));
|
||||
|
||||
$this->assertTrue($cache->has('foo'));
|
||||
|
||||
$cache->remove('foo');
|
||||
$this->assertFalse($cache->has('foo'));
|
||||
}
|
||||
|
||||
public function testSetCreatesDir()
|
||||
{
|
||||
$dir = sys_get_temp_dir().'/assetic/fscachetest';
|
||||
|
||||
$tearDown = function() use($dir)
|
||||
{
|
||||
array_map('unlink', glob($dir.'/*'));
|
||||
@rmdir($dir);
|
||||
};
|
||||
|
||||
$tearDown();
|
||||
|
||||
$cache = new FilesystemCache($dir);
|
||||
$cache->set('foo', 'bar');
|
||||
|
||||
$this->assertFileExists($dir.'/foo');
|
||||
|
||||
$tearDown();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user