Initial commit with Symfony 2.1+Vendors
Signed-off-by: Gergely POLONKAI (W00d5t0ck) <polesz@w00d5t0ck.info>
This commit is contained in:
175
vendor/kriswallsmith/assetic/tests/Assetic/Test/Asset/AssetCacheTest.php
vendored
Normal file
175
vendor/kriswallsmith/assetic/tests/Assetic/Test/Asset/AssetCacheTest.php
vendored
Normal file
@@ -0,0 +1,175 @@
|
||||
<?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\Asset;
|
||||
|
||||
use Assetic\Asset\AssetCache;
|
||||
|
||||
class AssetCacheTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $inner;
|
||||
private $cache;
|
||||
private $asset;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->inner = $this->getMock('Assetic\\Asset\\AssetInterface');
|
||||
$this->cache = $this->getMock('Assetic\\Cache\\CacheInterface');
|
||||
|
||||
$this->asset = new AssetCache($this->inner, $this->cache);
|
||||
}
|
||||
|
||||
public function testLoadFromCache()
|
||||
{
|
||||
$content = 'asdf';
|
||||
$filter = $this->getMock('Assetic\\Filter\\FilterInterface');
|
||||
|
||||
$this->inner->expects($this->once())
|
||||
->method('getFilters')
|
||||
->will($this->returnValue(array($filter)));
|
||||
$this->cache->expects($this->once())
|
||||
->method('has')
|
||||
->with($this->isType('string'))
|
||||
->will($this->returnValue(true));
|
||||
$this->cache->expects($this->once())
|
||||
->method('get')
|
||||
->with($this->isType('string'))
|
||||
->will($this->returnValue($content));
|
||||
$this->inner->expects($this->once())
|
||||
->method('setContent')
|
||||
->with($content);
|
||||
|
||||
$this->asset->load($filter);
|
||||
}
|
||||
|
||||
public function testLoadToCache()
|
||||
{
|
||||
$content = 'asdf';
|
||||
|
||||
$this->inner->expects($this->once())
|
||||
->method('getFilters')
|
||||
->will($this->returnValue(array()));
|
||||
$this->cache->expects($this->once())
|
||||
->method('has')
|
||||
->with($this->isType('string'))
|
||||
->will($this->returnValue(false));
|
||||
$this->inner->expects($this->once())->method('load');
|
||||
$this->inner->expects($this->once())
|
||||
->method('getContent')
|
||||
->will($this->returnValue($content));
|
||||
$this->cache->expects($this->once())
|
||||
->method('set')
|
||||
->with($this->isType('string'), $content);
|
||||
|
||||
$this->asset->load();
|
||||
}
|
||||
|
||||
public function testDumpFromCache()
|
||||
{
|
||||
$content = 'asdf';
|
||||
|
||||
$this->inner->expects($this->once())
|
||||
->method('getFilters')
|
||||
->will($this->returnValue(array()));
|
||||
$this->cache->expects($this->once())
|
||||
->method('has')
|
||||
->with($this->isType('string'))
|
||||
->will($this->returnValue(true));
|
||||
$this->cache->expects($this->once())
|
||||
->method('get')
|
||||
->with($this->isType('string'))
|
||||
->will($this->returnValue($content));
|
||||
|
||||
$this->assertEquals($content, $this->asset->dump(), '->dump() returns the cached value');
|
||||
}
|
||||
|
||||
public function testDumpToCache()
|
||||
{
|
||||
$content = 'asdf';
|
||||
|
||||
$this->inner->expects($this->once())
|
||||
->method('getFilters')
|
||||
->will($this->returnValue(array()));
|
||||
$this->cache->expects($this->once())
|
||||
->method('has')
|
||||
->with($this->isType('string'))
|
||||
->will($this->returnValue(false));
|
||||
$this->inner->expects($this->once())
|
||||
->method('dump')
|
||||
->will($this->returnValue($content));
|
||||
$this->cache->expects($this->once())
|
||||
->method('set')
|
||||
->with($this->isType('string'), $content);
|
||||
|
||||
$this->assertEquals($content, $this->asset->dump(), '->dump() returns the dumped value');
|
||||
}
|
||||
|
||||
public function testEnsureFilter()
|
||||
{
|
||||
$filter = $this->getMock('Assetic\\Filter\\FilterInterface');
|
||||
$this->inner->expects($this->once())->method('ensureFilter');
|
||||
$this->asset->ensureFilter($filter);
|
||||
}
|
||||
|
||||
public function testGetFilters()
|
||||
{
|
||||
$this->inner->expects($this->once())
|
||||
->method('getFilters')
|
||||
->will($this->returnValue(array()));
|
||||
|
||||
$this->assertInternalType('array', $this->asset->getFilters(), '->getFilters() returns the inner asset filters');
|
||||
}
|
||||
|
||||
public function testGetContent()
|
||||
{
|
||||
$this->inner->expects($this->once())
|
||||
->method('getContent')
|
||||
->will($this->returnValue('asdf'));
|
||||
|
||||
$this->assertEquals('asdf', $this->asset->getContent(), '->getContent() returns the inner asset content');
|
||||
}
|
||||
|
||||
public function testSetContent()
|
||||
{
|
||||
$this->inner->expects($this->once())
|
||||
->method('setContent')
|
||||
->with('asdf');
|
||||
|
||||
$this->asset->setContent('asdf');
|
||||
}
|
||||
|
||||
public function testGetSourceRoot()
|
||||
{
|
||||
$this->inner->expects($this->once())
|
||||
->method('getSourceRoot')
|
||||
->will($this->returnValue('asdf'));
|
||||
|
||||
$this->assertEquals('asdf', $this->asset->getSourceRoot(), '->getSourceRoot() returns the inner asset source root');
|
||||
}
|
||||
|
||||
public function testGetSourcePath()
|
||||
{
|
||||
$this->inner->expects($this->once())
|
||||
->method('getSourcePath')
|
||||
->will($this->returnValue('asdf'));
|
||||
|
||||
$this->assertEquals('asdf', $this->asset->getSourcePath(), '->getSourcePath() returns the inner asset source path');
|
||||
}
|
||||
|
||||
public function testGetLastModified()
|
||||
{
|
||||
$this->inner->expects($this->once())
|
||||
->method('getLastModified')
|
||||
->will($this->returnValue(123));
|
||||
|
||||
$this->assertEquals(123, $this->asset->getLastModified(), '->getLastModified() returns the inner asset last modified');
|
||||
}
|
||||
}
|
318
vendor/kriswallsmith/assetic/tests/Assetic/Test/Asset/AssetCollectionTest.php
vendored
Normal file
318
vendor/kriswallsmith/assetic/tests/Assetic/Test/Asset/AssetCollectionTest.php
vendored
Normal file
@@ -0,0 +1,318 @@
|
||||
<?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\Asset;
|
||||
|
||||
use Assetic\Asset\StringAsset;
|
||||
use Assetic\Asset\AssetCollection;
|
||||
use Assetic\Filter\CallablesFilter;
|
||||
|
||||
class AssetCollectionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testInterface()
|
||||
{
|
||||
$coll = new AssetCollection();
|
||||
$this->assertInstanceOf('Assetic\\Asset\\AssetInterface', $coll, 'AssetCollection implements AssetInterface');
|
||||
}
|
||||
|
||||
public function testLoadFilter()
|
||||
{
|
||||
$filter = $this->getMock('Assetic\\Filter\\FilterInterface');
|
||||
$filter->expects($this->once())->method('filterLoad');
|
||||
|
||||
$coll = new AssetCollection(array(new StringAsset('')), array($filter));
|
||||
$coll->load();
|
||||
}
|
||||
|
||||
public function testDumpFilter()
|
||||
{
|
||||
$filter = $this->getMock('Assetic\\Filter\\FilterInterface');
|
||||
$filter->expects($this->once())->method('filterDump');
|
||||
|
||||
$coll = new AssetCollection(array(new StringAsset('')), array($filter));
|
||||
$coll->dump();
|
||||
}
|
||||
|
||||
public function testNestedCollectionLoad()
|
||||
{
|
||||
$content = 'foobar';
|
||||
|
||||
$count = 0;
|
||||
$matches = array();
|
||||
$filter = new CallablesFilter(function($asset) use ($content, & $matches, & $count)
|
||||
{
|
||||
++$count;
|
||||
if ($content == $asset->getContent()) {
|
||||
$matches[] = $asset;
|
||||
}
|
||||
});
|
||||
|
||||
$innerColl = new AssetCollection(array(new StringAsset($content)));
|
||||
$outerColl = new AssetCollection(array($innerColl), array($filter));
|
||||
$outerColl->load();
|
||||
|
||||
$this->assertEquals(1, count($matches), '->load() applies filters to leaves');
|
||||
$this->assertEquals(1, $count, '->load() applies filters to leaves only');
|
||||
}
|
||||
|
||||
public function testMixedIteration()
|
||||
{
|
||||
$asset = new StringAsset('asset');
|
||||
$nestedAsset = new StringAsset('nested');
|
||||
$innerColl = new AssetCollection(array($nestedAsset));
|
||||
|
||||
$contents = array();
|
||||
$filter = new CallablesFilter(function($asset) use(& $contents)
|
||||
{
|
||||
$contents[] = $asset->getContent();
|
||||
});
|
||||
|
||||
$coll = new AssetCollection(array($asset, $innerColl), array($filter));
|
||||
$coll->load();
|
||||
|
||||
$this->assertEquals(array('asset', 'nested'), $contents, '->load() iterates over multiple levels');
|
||||
}
|
||||
|
||||
public function testLoadDedupBySourceUrl()
|
||||
{
|
||||
$asset1 = new StringAsset('asset', array(), '/some/dir', 'foo.bar');
|
||||
$asset2 = new StringAsset('asset', array(), '/some/dir', 'foo.bar');
|
||||
|
||||
$coll = new AssetCollection(array($asset1, $asset2));
|
||||
$coll->load();
|
||||
|
||||
$this->assertEquals('asset', $coll->getContent(), '->load() detects duplicate assets based on source URL');
|
||||
}
|
||||
|
||||
public function testLoadDedupByStrictEquality()
|
||||
{
|
||||
$asset = new StringAsset('foo');
|
||||
|
||||
$coll = new AssetCollection(array($asset, $asset));
|
||||
$coll->load();
|
||||
|
||||
$this->assertEquals('foo', $coll->getContent(), '->load() detects duplicate assets based on strict equality');
|
||||
}
|
||||
|
||||
public function testDumpDedupBySourceUrl()
|
||||
{
|
||||
$asset1 = new StringAsset('asset', array(), '/some/dir', 'foo.bar');
|
||||
$asset2 = new StringAsset('asset', array(), '/some/dir', 'foo.bar');
|
||||
|
||||
$coll = new AssetCollection(array($asset1, $asset2));
|
||||
$coll->load();
|
||||
|
||||
$this->assertEquals('asset', $coll->dump(), '->dump() detects duplicate assets based on source URL');
|
||||
}
|
||||
|
||||
public function testDumpDedupByStrictEquality()
|
||||
{
|
||||
$asset = new StringAsset('foo');
|
||||
|
||||
$coll = new AssetCollection(array($asset, $asset));
|
||||
$coll->load();
|
||||
|
||||
$this->assertEquals('foo', $coll->dump(), '->dump() detects duplicate assets based on strict equality');
|
||||
}
|
||||
|
||||
public function testIterationFilters()
|
||||
{
|
||||
$count = 0;
|
||||
$filter = new CallablesFilter(function() use(&$count) { ++$count; });
|
||||
|
||||
$coll = new AssetCollection();
|
||||
$coll->add(new StringAsset(''));
|
||||
$coll->ensureFilter($filter);
|
||||
|
||||
foreach ($coll as $asset) {
|
||||
$asset->dump();
|
||||
}
|
||||
|
||||
$this->assertEquals(1, $count, 'collection filters are called when child assets are iterated over');
|
||||
}
|
||||
|
||||
public function testSetContent()
|
||||
{
|
||||
$coll = new AssetCollection();
|
||||
$coll->setContent('asdf');
|
||||
|
||||
$this->assertEquals('asdf', $coll->getContent(), '->setContent() sets the content');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTimestampsAndExpected
|
||||
*/
|
||||
public function testGetLastModified($timestamps, $expected)
|
||||
{
|
||||
$asset = $this->getMock('Assetic\\Asset\\AssetInterface');
|
||||
|
||||
for ($i = 0; $i < count($timestamps); $i++) {
|
||||
$asset->expects($this->at($i))
|
||||
->method('getLastModified')
|
||||
->will($this->returnValue($timestamps[$i]));
|
||||
}
|
||||
|
||||
$coll = new AssetCollection(array_fill(0, count($timestamps), $asset));
|
||||
|
||||
$this->assertEquals($expected, $coll->getLastModified(), '->getLastModifed() returns the highest last modified');
|
||||
}
|
||||
|
||||
public function getTimestampsAndExpected()
|
||||
{
|
||||
return array(
|
||||
array(array(1, 2, 3), 3),
|
||||
array(array(5, 4, 3), 5),
|
||||
array(array(3, 8, 5), 8),
|
||||
array(array(3, 8, null), 8),
|
||||
);
|
||||
}
|
||||
|
||||
public function testRecursiveIteration()
|
||||
{
|
||||
$asset1 = $this->getMock('Assetic\\Asset\\AssetInterface');
|
||||
$asset2 = $this->getMock('Assetic\\Asset\\AssetInterface');
|
||||
$asset3 = $this->getMock('Assetic\\Asset\\AssetInterface');
|
||||
$asset4 = $this->getMock('Assetic\\Asset\\AssetInterface');
|
||||
|
||||
$coll3 = new AssetCollection(array($asset1, $asset2));
|
||||
$coll2 = new AssetCollection(array($asset3, $coll3));
|
||||
$coll1 = new AssetCollection(array($asset4, $coll2));
|
||||
|
||||
$i = 0;
|
||||
foreach ($coll1 as $a) {
|
||||
$i++;
|
||||
}
|
||||
|
||||
$this->assertEquals(4, $i, 'iteration with a recursive iterator is recursive');
|
||||
}
|
||||
|
||||
public function testRecursiveDeduplication()
|
||||
{
|
||||
$asset = $this->getMock('Assetic\\Asset\\AssetInterface');
|
||||
|
||||
$coll3 = new AssetCollection(array($asset, $asset));
|
||||
$coll2 = new AssetCollection(array($asset, $coll3));
|
||||
$coll1 = new AssetCollection(array($asset, $coll2));
|
||||
|
||||
$i = 0;
|
||||
foreach ($coll1 as $a) {
|
||||
$i++;
|
||||
}
|
||||
|
||||
$this->assertEquals(1, $i, 'deduplication is performed recursively');
|
||||
}
|
||||
|
||||
public function testIteration()
|
||||
{
|
||||
$asset1 = new StringAsset('asset1', array(), '/some/dir', 'foo.css');
|
||||
$asset2 = new StringAsset('asset2', array(), '/some/dir', 'foo.css');
|
||||
$asset3 = new StringAsset('asset3', array(), '/some/dir', 'bar.css');
|
||||
|
||||
$coll = new AssetCollection(array($asset1, $asset2, $asset3));
|
||||
|
||||
$count = 0;
|
||||
foreach ($coll as $a) {
|
||||
++$count;
|
||||
}
|
||||
|
||||
$this->assertEquals(2, $count, 'iterator filters duplicates based on url');
|
||||
}
|
||||
|
||||
public function testBasenameCollision()
|
||||
{
|
||||
$asset1 = new StringAsset('asset1', array(), '/some/dir', 'foo/foo.css');
|
||||
$asset2 = new StringAsset('asset2', array(), '/some/dir', 'bar/foo.css');
|
||||
|
||||
$coll = new AssetCollection(array($asset1, $asset2));
|
||||
|
||||
$urls = array();
|
||||
foreach ($coll as $leaf) {
|
||||
$urls[] = $leaf->getTargetPath();
|
||||
}
|
||||
|
||||
$this->assertEquals(2, count(array_unique($urls)), 'iterator prevents basename collisions');
|
||||
}
|
||||
|
||||
public function testEmptyMtime()
|
||||
{
|
||||
$coll = new AssetCollection();
|
||||
$this->assertNull($coll->getLastModified(), '->getLastModified() returns null on empty collection');
|
||||
}
|
||||
|
||||
public function testLeafManipulation()
|
||||
{
|
||||
$coll = new AssetCollection(array(new StringAsset('asdf')));
|
||||
|
||||
foreach ($coll as $leaf) {
|
||||
$leaf->setTargetPath('asdf');
|
||||
}
|
||||
|
||||
foreach ($coll as $leaf) {
|
||||
$this->assertEquals('asdf', $leaf->getTargetPath(), 'leaf changes persist between iterations');
|
||||
}
|
||||
}
|
||||
|
||||
public function testRemoveLeaf()
|
||||
{
|
||||
$coll = new AssetCollection(array(
|
||||
$leaf = new StringAsset('asdf'),
|
||||
));
|
||||
|
||||
$this->assertTrue($coll->removeLeaf($leaf));
|
||||
}
|
||||
|
||||
public function testRemoveRecursiveLeaf()
|
||||
{
|
||||
$coll = new AssetCollection(array(
|
||||
new AssetCollection(array(
|
||||
$leaf = new StringAsset('asdf'),
|
||||
))
|
||||
));
|
||||
|
||||
$this->assertTrue($coll->removeLeaf($leaf));
|
||||
}
|
||||
|
||||
public function testRemoveInvalidLeaf()
|
||||
{
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
|
||||
$coll = new AssetCollection();
|
||||
$coll->removeLeaf(new StringAsset('asdf'));
|
||||
}
|
||||
|
||||
public function testReplaceLeaf()
|
||||
{
|
||||
$coll = new AssetCollection(array(
|
||||
$leaf = new StringAsset('asdf'),
|
||||
));
|
||||
|
||||
$this->assertTrue($coll->replaceLeaf($leaf, new StringAsset('foo')));
|
||||
}
|
||||
|
||||
public function testReplaceRecursiveLeaf()
|
||||
{
|
||||
$coll = new AssetCollection(array(
|
||||
new AssetCollection(array(
|
||||
$leaf = new StringAsset('asdf'),
|
||||
)),
|
||||
));
|
||||
|
||||
$this->assertTrue($coll->replaceLeaf($leaf, new StringAsset('foo')));
|
||||
}
|
||||
|
||||
public function testReplaceInvalidLeaf()
|
||||
{
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
|
||||
$coll = new AssetCollection();
|
||||
$coll->replaceLeaf(new StringAsset('foo'), new StringAsset('bar'));
|
||||
}
|
||||
}
|
126
vendor/kriswallsmith/assetic/tests/Assetic/Test/Asset/AssetReferenceTest.php
vendored
Normal file
126
vendor/kriswallsmith/assetic/tests/Assetic/Test/Asset/AssetReferenceTest.php
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
<?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\Asset;
|
||||
|
||||
use Assetic\Asset\AssetReference;
|
||||
|
||||
class AssetReferenceTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $am;
|
||||
private $ref;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->am = $this->getMock('Assetic\\AssetManager');
|
||||
$this->ref = new AssetReference($this->am, 'foo');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getMethodAndRetVal
|
||||
*/
|
||||
public function testMethods($method, $returnValue)
|
||||
{
|
||||
$asset = $this->getMock('Assetic\\Asset\\AssetInterface');
|
||||
|
||||
$this->am->expects($this->once())
|
||||
->method('get')
|
||||
->with('foo')
|
||||
->will($this->returnValue($asset));
|
||||
$asset->expects($this->once())
|
||||
->method($method)
|
||||
->will($this->returnValue($returnValue));
|
||||
|
||||
$this->assertEquals($returnValue, $this->ref->$method(), '->'.$method.'() returns the asset value');
|
||||
}
|
||||
|
||||
public function getMethodAndRetVal()
|
||||
{
|
||||
return array(
|
||||
array('getContent', 'asdf'),
|
||||
array('getSourceRoot', 'asdf'),
|
||||
array('getSourcePath', 'asdf'),
|
||||
array('getTargetPath', 'asdf'),
|
||||
array('getLastModified', 123),
|
||||
);
|
||||
}
|
||||
|
||||
public function testLazyFilters()
|
||||
{
|
||||
$this->am->expects($this->never())->method('get');
|
||||
$this->ref->ensureFilter($this->getMock('Assetic\\Filter\\FilterInterface'));
|
||||
}
|
||||
|
||||
public function testFilterFlush()
|
||||
{
|
||||
$asset = $this->getMock('Assetic\\Asset\\AssetInterface');
|
||||
|
||||
$this->am->expects($this->exactly(2))
|
||||
->method('get')
|
||||
->with('foo')
|
||||
->will($this->returnValue($asset));
|
||||
$asset->expects($this->once())->method('ensureFilter');
|
||||
$asset->expects($this->once())
|
||||
->method('getFilters')
|
||||
->will($this->returnValue(array()));
|
||||
|
||||
$this->ref->ensureFilter($this->getMock('Assetic\\Filter\\FilterInterface'));
|
||||
|
||||
$this->assertInternalType('array', $this->ref->getFilters(), '->getFilters() flushes and returns filters');
|
||||
}
|
||||
|
||||
public function testSetContent()
|
||||
{
|
||||
$asset = $this->getMock('Assetic\\Asset\\AssetInterface');
|
||||
|
||||
$this->am->expects($this->once())
|
||||
->method('get')
|
||||
->with('foo')
|
||||
->will($this->returnValue($asset));
|
||||
$asset->expects($this->once())
|
||||
->method('setContent')
|
||||
->with('asdf');
|
||||
|
||||
$this->ref->setContent('asdf');
|
||||
}
|
||||
|
||||
public function testLoad()
|
||||
{
|
||||
$filter = $this->getMock('Assetic\\Filter\\FilterInterface');
|
||||
$asset = $this->getMock('Assetic\\Asset\\AssetInterface');
|
||||
|
||||
$this->am->expects($this->exactly(2))
|
||||
->method('get')
|
||||
->with('foo')
|
||||
->will($this->returnValue($asset));
|
||||
$asset->expects($this->once())
|
||||
->method('load')
|
||||
->with($filter);
|
||||
|
||||
$this->ref->load($filter);
|
||||
}
|
||||
|
||||
public function testDump()
|
||||
{
|
||||
$filter = $this->getMock('Assetic\\Filter\\FilterInterface');
|
||||
$asset = $this->getMock('Assetic\\Asset\\AssetInterface');
|
||||
|
||||
$this->am->expects($this->exactly(2))
|
||||
->method('get')
|
||||
->with('foo')
|
||||
->will($this->returnValue($asset));
|
||||
$asset->expects($this->once())
|
||||
->method('dump')
|
||||
->with($filter);
|
||||
|
||||
$this->ref->dump($filter);
|
||||
}
|
||||
}
|
72
vendor/kriswallsmith/assetic/tests/Assetic/Test/Asset/FileAssetTest.php
vendored
Normal file
72
vendor/kriswallsmith/assetic/tests/Assetic/Test/Asset/FileAssetTest.php
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
<?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\Asset;
|
||||
|
||||
use Assetic\Asset\FileAsset;
|
||||
|
||||
class FileAssetTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testInterface()
|
||||
{
|
||||
$asset = new FileAsset(__FILE__);
|
||||
$this->assertInstanceOf('Assetic\\Asset\\AssetInterface', $asset, 'Asset implements AssetInterface');
|
||||
}
|
||||
|
||||
public function testLazyLoading()
|
||||
{
|
||||
$asset = new FileAsset(__FILE__);
|
||||
$this->assertEmpty($asset->getContent(), 'The asset content is empty before load');
|
||||
|
||||
$asset->load();
|
||||
$this->assertNotEmpty($asset->getContent(), 'The asset content is not empty after load');
|
||||
}
|
||||
|
||||
public function testGetLastModifiedType()
|
||||
{
|
||||
$asset = new FileAsset(__FILE__);
|
||||
$this->assertInternalType('integer', $asset->getLastModified(), '->getLastModified() returns an integer');
|
||||
}
|
||||
|
||||
public function testGetLastModifiedTypeFileNotFound()
|
||||
{
|
||||
$asset = new FileAsset(__DIR__ . "/foo/bar/baz.css");
|
||||
|
||||
$this->setExpectedException("RuntimeException", "The source file");
|
||||
$asset->getLastModified();
|
||||
}
|
||||
|
||||
public function testGetLastModifiedValue()
|
||||
{
|
||||
$asset = new FileAsset(__FILE__);
|
||||
$this->assertLessThan(time(), $asset->getLastModified(), '->getLastModified() returns the mtime');
|
||||
}
|
||||
|
||||
public function testDefaultBaseAndPath()
|
||||
{
|
||||
$asset = new FileAsset(__FILE__);
|
||||
$this->assertEquals(__DIR__, $asset->getSourceRoot(), '->__construct() defaults base to the asset directory');
|
||||
$this->assertEquals(basename(__FILE__), $asset->getSourcePath(), '->__construct() defaults path to the asset basename');
|
||||
}
|
||||
|
||||
public function testPathGuessing()
|
||||
{
|
||||
$asset = new FileAsset(__FILE__, array(), __DIR__);
|
||||
$this->assertEquals(basename(__FILE__), $asset->getSourcePath(), '->__construct() guesses the asset path');
|
||||
}
|
||||
|
||||
public function testInvalidBase()
|
||||
{
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
|
||||
$asset = new FileAsset(__FILE__, array(), __DIR__.'/foo');
|
||||
}
|
||||
}
|
61
vendor/kriswallsmith/assetic/tests/Assetic/Test/Asset/GlobAssetTest.php
vendored
Normal file
61
vendor/kriswallsmith/assetic/tests/Assetic/Test/Asset/GlobAssetTest.php
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
<?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\Asset;
|
||||
|
||||
use Assetic\Asset\GlobAsset;
|
||||
|
||||
class GlobAssetTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testInterface()
|
||||
{
|
||||
$asset = new GlobAsset(__DIR__.'/*.php');
|
||||
$this->assertInstanceOf('Assetic\\Asset\\AssetInterface', $asset, 'Asset implements AssetInterface');
|
||||
}
|
||||
|
||||
public function testIteration()
|
||||
{
|
||||
$assets = new GlobAsset(__DIR__.'/*.php');
|
||||
$this->assertGreaterThan(0, iterator_count($assets), 'GlobAsset initializes for iteration');
|
||||
}
|
||||
|
||||
public function testRecursiveIteration()
|
||||
{
|
||||
$assets = new GlobAsset(__DIR__.'/*.php');
|
||||
$this->assertGreaterThan(0, iterator_count($assets), 'GlobAsset initializes for recursive iteration');
|
||||
}
|
||||
|
||||
public function testGetLastModifiedType()
|
||||
{
|
||||
$assets = new GlobAsset(__DIR__.'/*.php');
|
||||
$this->assertInternalType('integer', $assets->getLastModified(), '->getLastModified() returns an integer');
|
||||
}
|
||||
|
||||
public function testGetLastModifiedValue()
|
||||
{
|
||||
$assets = new GlobAsset(__DIR__.'/*.php');
|
||||
$this->assertLessThan(time(), $assets->getLastModified(), '->getLastModified() returns a file mtime');
|
||||
}
|
||||
|
||||
public function testLoad()
|
||||
{
|
||||
$assets = new GlobAsset(__DIR__.'/*.php');
|
||||
$assets->load();
|
||||
|
||||
$this->assertNotEmpty($assets->getContent(), '->load() loads contents');
|
||||
}
|
||||
|
||||
public function testDump()
|
||||
{
|
||||
$assets = new GlobAsset(__DIR__.'/*.php');
|
||||
$this->assertNotEmpty($assets->dump(), '->dump() dumps contents');
|
||||
}
|
||||
}
|
58
vendor/kriswallsmith/assetic/tests/Assetic/Test/Asset/HttpAssetTest.php
vendored
Normal file
58
vendor/kriswallsmith/assetic/tests/Assetic/Test/Asset/HttpAssetTest.php
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
<?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\Asset;
|
||||
|
||||
use Assetic\Asset\HttpAsset;
|
||||
|
||||
class HttpAssetTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
const JQUERY = 'https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js';
|
||||
|
||||
public function testGetLastModified()
|
||||
{
|
||||
if (!extension_loaded('openssl')) {
|
||||
$this->markTestSkipped('The OpenSSL extension is not loaded.');
|
||||
}
|
||||
|
||||
$asset = new HttpAsset(self::JQUERY);
|
||||
$this->assertInternalType('integer', $asset->getLastModified(), '->getLastModified() returns an integer');
|
||||
}
|
||||
|
||||
public function testProtocolRelativeUrl()
|
||||
{
|
||||
$asset = new HttpAsset(substr(self::JQUERY, 6));
|
||||
$asset->load();
|
||||
$this->assertNotEmpty($asset->getContent());
|
||||
}
|
||||
|
||||
public function testMalformedUrl()
|
||||
{
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
|
||||
new HttpAsset(__FILE__);
|
||||
}
|
||||
|
||||
public function testInvalidUrl()
|
||||
{
|
||||
$this->setExpectedException('RuntimeException');
|
||||
|
||||
$asset = new HttpAsset('http://invalid.com/foobar');
|
||||
$asset->load();
|
||||
}
|
||||
|
||||
public function testSourceMetadata()
|
||||
{
|
||||
$asset = new HttpAsset(self::JQUERY);
|
||||
$this->assertEquals('https://ajax.googleapis.com', $asset->getSourceRoot(), '->__construct() set the source root');
|
||||
$this->assertEquals('ajax/libs/jquery/1.6.1/jquery.min.js', $asset->getSourcePath(), '->__construct() set the source path');
|
||||
}
|
||||
}
|
79
vendor/kriswallsmith/assetic/tests/Assetic/Test/Asset/StringAssetTest.php
vendored
Normal file
79
vendor/kriswallsmith/assetic/tests/Assetic/Test/Asset/StringAssetTest.php
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
<?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\Asset;
|
||||
|
||||
use Assetic\Asset\StringAsset;
|
||||
|
||||
class StringAssetTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testInterface()
|
||||
{
|
||||
$asset = new StringAsset('');
|
||||
$this->assertInstanceOf('Assetic\\Asset\\AssetInterface', $asset, 'Asset implements AssetInterface');
|
||||
}
|
||||
|
||||
public function testLoadAppliesFilters()
|
||||
{
|
||||
$filter = $this->getMock('Assetic\\Filter\\FilterInterface');
|
||||
$filter->expects($this->once())->method('filterLoad');
|
||||
|
||||
$asset = new StringAsset('foo', array($filter));
|
||||
$asset->load();
|
||||
}
|
||||
|
||||
public function testAutomaticLoad()
|
||||
{
|
||||
$filter = $this->getMock('Assetic\\Filter\\FilterInterface');
|
||||
$filter->expects($this->once())->method('filterLoad');
|
||||
|
||||
$asset = new StringAsset('foo', array($filter));
|
||||
$asset->dump();
|
||||
}
|
||||
|
||||
public function testGetFilters()
|
||||
{
|
||||
$asset = new StringAsset('');
|
||||
$this->assertInternalType('array', $asset->getFilters(), '->getFilters() returns an array');
|
||||
}
|
||||
|
||||
public function testLoadAppliesAdditionalFilter()
|
||||
{
|
||||
$asset = new StringAsset('');
|
||||
$asset->load();
|
||||
|
||||
$filter = $this->getMock('Assetic\\Filter\\FilterInterface');
|
||||
$filter->expects($this->once())
|
||||
->method('filterLoad')
|
||||
->with($asset);
|
||||
|
||||
$asset->load($filter);
|
||||
}
|
||||
|
||||
public function testDumpAppliesAdditionalFilter()
|
||||
{
|
||||
$asset = new StringAsset('');
|
||||
|
||||
$filter = $this->getMock('Assetic\\Filter\\FilterInterface');
|
||||
$filter->expects($this->once())
|
||||
->method('filterDump')
|
||||
->with($asset);
|
||||
|
||||
$asset->dump($filter);
|
||||
}
|
||||
|
||||
public function testLastModified()
|
||||
{
|
||||
$asset = new StringAsset('');
|
||||
$asset->setLastModified(123);
|
||||
$this->assertEquals(123, $asset->getLastModified(), '->getLastModified() return the set last modified value');
|
||||
}
|
||||
}
|
53
vendor/kriswallsmith/assetic/tests/Assetic/Test/AssetManagerTest.php
vendored
Normal file
53
vendor/kriswallsmith/assetic/tests/Assetic/Test/AssetManagerTest.php
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
<?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;
|
||||
|
||||
use Assetic\AssetManager;
|
||||
|
||||
class AssetManagerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $am;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->am = new AssetManager();
|
||||
}
|
||||
|
||||
public function testGetAsset()
|
||||
{
|
||||
$asset = $this->getMock('Assetic\\Asset\\AssetInterface');
|
||||
$this->am->set('foo', $asset);
|
||||
$this->assertSame($asset, $this->am->get('foo'), '->get() returns an asset');
|
||||
}
|
||||
|
||||
public function testGetInvalidAsset()
|
||||
{
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
$this->am->get('foo');
|
||||
}
|
||||
|
||||
public function testHas()
|
||||
{
|
||||
$asset = $this->getMock('Assetic\\Asset\\AssetInterface');
|
||||
$this->am->set('foo', $asset);
|
||||
|
||||
$this->assertTrue($this->am->has('foo'), '->has() returns true if the asset is set');
|
||||
$this->assertFalse($this->am->has('bar'), '->has() returns false if the asset is not set');
|
||||
}
|
||||
|
||||
public function testInvalidName()
|
||||
{
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
|
||||
$this->am->set('@foo', $this->getMock('Assetic\\Asset\\AssetInterface'));
|
||||
}
|
||||
}
|
206
vendor/kriswallsmith/assetic/tests/Assetic/Test/AssetWriterTest.php
vendored
Normal file
206
vendor/kriswallsmith/assetic/tests/Assetic/Test/AssetWriterTest.php
vendored
Normal file
@@ -0,0 +1,206 @@
|
||||
<?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;
|
||||
|
||||
use Assetic\Asset\FileAsset;
|
||||
|
||||
use Assetic\AssetManager;
|
||||
use Assetic\AssetWriter;
|
||||
|
||||
class AssetWriterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
$this->dir = sys_get_temp_dir().'/assetic_tests_'.rand(11111, 99999);
|
||||
mkdir($this->dir);
|
||||
$this->writer = new AssetWriter($this->dir, array(
|
||||
'locale' => array('en', 'de', 'fr'),
|
||||
'browser' => array('ie', 'firefox', 'other'),
|
||||
'gzip' => array('gzip', '')
|
||||
));
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
array_map('unlink', glob($this->dir.'/*'));
|
||||
rmdir($this->dir);
|
||||
}
|
||||
|
||||
public function testWriteManagerAssets()
|
||||
{
|
||||
$asset = $this->getMock('Assetic\\Asset\\AssetInterface');
|
||||
$am = $this->getMock('Assetic\\AssetManager');
|
||||
|
||||
$am->expects($this->once())
|
||||
->method('getNames')
|
||||
->will($this->returnValue(array('foo')));
|
||||
$am->expects($this->once())
|
||||
->method('get')
|
||||
->with('foo')
|
||||
->will($this->returnValue($asset));
|
||||
$asset->expects($this->atLeastOnce())
|
||||
->method('getTargetPath')
|
||||
->will($this->returnValue('target_url'));
|
||||
$asset->expects($this->once())
|
||||
->method('dump')
|
||||
->will($this->returnValue('content'));
|
||||
$asset->expects($this->atLeastOnce())
|
||||
->method('getVars')
|
||||
->will($this->returnValue(array()));
|
||||
$asset->expects($this->atLeastOnce())
|
||||
->method('getValues')
|
||||
->will($this->returnValue(array()));
|
||||
|
||||
$this->writer->writeManagerAssets($am);
|
||||
|
||||
$this->assertFileExists($this->dir.'/target_url');
|
||||
$this->assertEquals('content', file_get_contents($this->dir.'/target_url'));
|
||||
}
|
||||
|
||||
public function testWriteAssetWithVars()
|
||||
{
|
||||
$asset = $this->getMock('Assetic\Asset\AssetInterface');
|
||||
$asset->expects($this->atLeastOnce())
|
||||
->method('getVars')
|
||||
->will($this->returnValue(array('locale')));
|
||||
|
||||
$self = $this;
|
||||
$expectedValues = array(
|
||||
array('locale' => 'en'),
|
||||
array('locale' => 'de'),
|
||||
array('locale' => 'fr'),
|
||||
);
|
||||
$asset->expects($this->exactly(3))
|
||||
->method('setValues')
|
||||
->will($this->returnCallback(function($values) use($self, $expectedValues) {
|
||||
static $counter = 0;
|
||||
$self->assertEquals($expectedValues[$counter++], $values);
|
||||
}));
|
||||
$asset->expects($this->exactly(3))
|
||||
->method('getValues')
|
||||
->will($this->returnCallback(function() use($expectedValues) {
|
||||
static $counter = 0;
|
||||
return $expectedValues[$counter++];
|
||||
}));
|
||||
|
||||
$asset->expects($this->exactly(3))
|
||||
->method('dump')
|
||||
->will($this->onConsecutiveCalls('en', 'de', 'fr'));
|
||||
|
||||
$asset->expects($this->atLeastOnce())
|
||||
->method('getTargetPath')
|
||||
->will($this->returnValue('target.{locale}'));
|
||||
|
||||
$this->writer->writeAsset($asset);
|
||||
|
||||
$this->assertFileExists($this->dir.'/target.en');
|
||||
$this->assertFileExists($this->dir.'/target.de');
|
||||
$this->assertFileExists($this->dir.'/target.fr');
|
||||
$this->assertEquals('en', file_get_contents($this->dir.'/target.en'));
|
||||
$this->assertEquals('de', file_get_contents($this->dir.'/target.de'));
|
||||
$this->assertEquals('fr', file_get_contents($this->dir.'/target.fr'));
|
||||
}
|
||||
|
||||
public function testAssetWithInputVars()
|
||||
{
|
||||
$asset = new FileAsset(__DIR__.'/Fixture/messages.{locale}.js',
|
||||
array(), null, null, array('locale'));
|
||||
$asset->setTargetPath('messages.{locale}.js');
|
||||
|
||||
$this->writer->writeAsset($asset);
|
||||
|
||||
$this->assertFileExists($this->dir.'/messages.en.js');
|
||||
$this->assertFileExists($this->dir.'/messages.de.js');
|
||||
$this->assertFileExists($this->dir.'/messages.fr.js');
|
||||
$this->assertEquals('var messages = {"text.greeting": "Hello %name%!"};',
|
||||
file_get_contents($this->dir.'/messages.en.js'));
|
||||
$this->assertEquals('var messages = {"text.greeting": "Hallo %name%!"};',
|
||||
file_get_contents($this->dir.'/messages.de.js'));
|
||||
$this->assertEquals('var messages = {"text.greet": "All\u00f4 %name%!"};',
|
||||
file_get_contents($this->dir.'/messages.fr.js'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getCombinationTests
|
||||
*/
|
||||
public function testGetCombinations($vars, $expectedCombinations)
|
||||
{
|
||||
$ref = new \ReflectionMethod($this->writer, 'getCombinations');
|
||||
$ref->setAccessible(true);
|
||||
|
||||
$this->assertEquals($expectedCombinations, $ref->invoke($this->writer, $vars));
|
||||
}
|
||||
|
||||
public function getCombinationTests()
|
||||
{
|
||||
$tests = array();
|
||||
|
||||
// no variables
|
||||
$tests[] = array(
|
||||
array(),
|
||||
array(array())
|
||||
);
|
||||
|
||||
// one variables
|
||||
$tests[] = array(
|
||||
array('locale'),
|
||||
array(
|
||||
array('locale' => 'en'),
|
||||
array('locale' => 'de'),
|
||||
array('locale' => 'fr'),
|
||||
)
|
||||
);
|
||||
|
||||
// two variables
|
||||
$tests[] = array(
|
||||
array('locale', 'browser'),
|
||||
array(
|
||||
array('locale' => 'en', 'browser' => 'ie'),
|
||||
array('locale' => 'de', 'browser' => 'ie'),
|
||||
array('locale' => 'fr', 'browser' => 'ie'),
|
||||
array('locale' => 'en', 'browser' => 'firefox'),
|
||||
array('locale' => 'de', 'browser' => 'firefox'),
|
||||
array('locale' => 'fr', 'browser' => 'firefox'),
|
||||
array('locale' => 'en', 'browser' => 'other'),
|
||||
array('locale' => 'de', 'browser' => 'other'),
|
||||
array('locale' => 'fr', 'browser' => 'other'),
|
||||
)
|
||||
);
|
||||
|
||||
// three variables
|
||||
$tests[] = array(
|
||||
array('locale', 'browser', 'gzip'),
|
||||
array(
|
||||
array('locale' => 'en', 'browser' => 'ie', 'gzip' => 'gzip'),
|
||||
array('locale' => 'de', 'browser' => 'ie', 'gzip' => 'gzip'),
|
||||
array('locale' => 'fr', 'browser' => 'ie', 'gzip' => 'gzip'),
|
||||
array('locale' => 'en', 'browser' => 'firefox', 'gzip' => 'gzip'),
|
||||
array('locale' => 'de', 'browser' => 'firefox', 'gzip' => 'gzip'),
|
||||
array('locale' => 'fr', 'browser' => 'firefox', 'gzip' => 'gzip'),
|
||||
array('locale' => 'en', 'browser' => 'other', 'gzip' => 'gzip'),
|
||||
array('locale' => 'de', 'browser' => 'other', 'gzip' => 'gzip'),
|
||||
array('locale' => 'fr', 'browser' => 'other', 'gzip' => 'gzip'),
|
||||
array('locale' => 'en', 'browser' => 'ie', 'gzip' => ''),
|
||||
array('locale' => 'de', 'browser' => 'ie', 'gzip' => ''),
|
||||
array('locale' => 'fr', 'browser' => 'ie', 'gzip' => ''),
|
||||
array('locale' => 'en', 'browser' => 'firefox', 'gzip' => ''),
|
||||
array('locale' => 'de', 'browser' => 'firefox', 'gzip' => ''),
|
||||
array('locale' => 'fr', 'browser' => 'firefox', 'gzip' => ''),
|
||||
array('locale' => 'en', 'browser' => 'other', 'gzip' => ''),
|
||||
array('locale' => 'de', 'browser' => 'other', 'gzip' => ''),
|
||||
array('locale' => 'fr', 'browser' => 'other', 'gzip' => ''),
|
||||
)
|
||||
);
|
||||
|
||||
return $tests;
|
||||
}
|
||||
}
|
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();
|
||||
}
|
||||
}
|
204
vendor/kriswallsmith/assetic/tests/Assetic/Test/Extension/Twig/AsseticExtensionTest.php
vendored
Normal file
204
vendor/kriswallsmith/assetic/tests/Assetic/Test/Extension/Twig/AsseticExtensionTest.php
vendored
Normal file
@@ -0,0 +1,204 @@
|
||||
<?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\Extension\Twig;
|
||||
|
||||
use Assetic\Factory\AssetFactory;
|
||||
use Assetic\Extension\Twig\AsseticExtension;
|
||||
|
||||
class AsseticExtensionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $am;
|
||||
private $fm;
|
||||
private $factory;
|
||||
private $twig;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
if (!class_exists('Twig_Environment')) {
|
||||
$this->markTestSkipped('Twig is not installed.');
|
||||
}
|
||||
|
||||
$this->am = $this->getMock('Assetic\\AssetManager');
|
||||
$this->fm = $this->getMock('Assetic\\FilterManager');
|
||||
|
||||
$this->valueSupplier = $this->getMock('Assetic\ValueSupplierInterface');
|
||||
|
||||
$this->factory = new AssetFactory(__DIR__.'/templates');
|
||||
$this->factory->setAssetManager($this->am);
|
||||
$this->factory->setFilterManager($this->fm);
|
||||
|
||||
$this->twig = new \Twig_Environment();
|
||||
$this->twig->setLoader(new \Twig_Loader_Filesystem(__DIR__.'/templates'));
|
||||
$this->twig->addExtension(new AsseticExtension($this->factory, array(), $this->valueSupplier));
|
||||
}
|
||||
|
||||
public function testReference()
|
||||
{
|
||||
$asset = $this->getMock('Assetic\\Asset\\AssetInterface');
|
||||
$this->am->expects($this->any())
|
||||
->method('get')
|
||||
->with('foo')
|
||||
->will($this->returnValue($asset));
|
||||
|
||||
$xml = $this->renderXml('reference.twig');
|
||||
$this->assertEquals(1, count($xml->asset));
|
||||
$this->assertStringStartsWith('css/', (string) $xml->asset['url']);
|
||||
}
|
||||
|
||||
public function testGlob()
|
||||
{
|
||||
$xml = $this->renderXml('glob.twig');
|
||||
$this->assertEquals(1, count($xml->asset));
|
||||
$this->assertStringStartsWith('css/', (string) $xml->asset['url']);
|
||||
}
|
||||
|
||||
public function testAbsolutePath()
|
||||
{
|
||||
$xml = $this->renderXml('absolute_path.twig');
|
||||
$this->assertEquals(1, count($xml->asset));
|
||||
$this->assertStringStartsWith('css/', (string) $xml->asset['url']);
|
||||
}
|
||||
|
||||
public function testFilters()
|
||||
{
|
||||
$filter = $this->getMock('Assetic\\Filter\\FilterInterface');
|
||||
|
||||
$this->fm->expects($this->at(0))
|
||||
->method('get')
|
||||
->with('foo')
|
||||
->will($this->returnValue($filter));
|
||||
$this->fm->expects($this->at(1))
|
||||
->method('get')
|
||||
->with('bar')
|
||||
->will($this->returnValue($filter));
|
||||
|
||||
$xml = $this->renderXml('filters.twig');
|
||||
$this->assertEquals(1, count($xml->asset));
|
||||
$this->assertStringStartsWith('css/', (string) $xml->asset['url']);
|
||||
}
|
||||
|
||||
public function testOptionalFilter()
|
||||
{
|
||||
$filter = $this->getMock('Assetic\\Filter\\FilterInterface');
|
||||
|
||||
$this->fm->expects($this->once())
|
||||
->method('get')
|
||||
->with('foo')
|
||||
->will($this->returnValue($filter));
|
||||
|
||||
$xml = $this->renderXml('optional_filter.twig');
|
||||
$this->assertEquals(1, count($xml->asset));
|
||||
$this->assertStringStartsWith('css/', (string) $xml->asset['url']);
|
||||
}
|
||||
|
||||
public function testOutputPattern()
|
||||
{
|
||||
$xml = $this->renderXml('output_pattern.twig');
|
||||
$this->assertEquals(1, count($xml->asset));
|
||||
$this->assertStringStartsWith('css/packed/', (string) $xml->asset['url']);
|
||||
$this->assertStringEndsWith('.css', (string) $xml->asset['url']);
|
||||
}
|
||||
|
||||
public function testOutput()
|
||||
{
|
||||
$xml = $this->renderXml('output_url.twig');
|
||||
$this->assertEquals(1, count($xml->asset));
|
||||
$this->assertEquals('explicit_url.css', (string) $xml->asset['url']);
|
||||
}
|
||||
|
||||
public function testMixture()
|
||||
{
|
||||
$asset = $this->getMock('Assetic\\Asset\\AssetInterface');
|
||||
$this->am->expects($this->any())
|
||||
->method('get')
|
||||
->with('foo')
|
||||
->will($this->returnValue($asset));
|
||||
|
||||
$xml = $this->renderXml('mixture.twig');
|
||||
$this->assertEquals(1, count($xml->asset));
|
||||
$this->assertEquals('packed/mixture', (string) $xml->asset['url']);
|
||||
}
|
||||
|
||||
public function testDebug()
|
||||
{
|
||||
$filter = $this->getMock('Assetic\\Filter\\FilterInterface');
|
||||
|
||||
$this->fm->expects($this->once())
|
||||
->method('get')
|
||||
->with('bar')
|
||||
->will($this->returnValue($filter));
|
||||
|
||||
$xml = $this->renderXml('debug.twig');
|
||||
$this->assertEquals(2, count($xml->asset));
|
||||
$this->assertStringStartsWith('css/packed_', (string) $xml->asset[0]['url']);
|
||||
$this->assertStringEndsWith('.css', (string) $xml->asset[0]['url']);
|
||||
}
|
||||
|
||||
public function testCombine()
|
||||
{
|
||||
$filter = $this->getMock('Assetic\\Filter\\FilterInterface');
|
||||
|
||||
$this->fm->expects($this->once())
|
||||
->method('get')
|
||||
->with('bar')
|
||||
->will($this->returnValue($filter));
|
||||
|
||||
$xml = $this->renderXml('combine.twig');
|
||||
$this->assertEquals(1, count($xml->asset));
|
||||
$this->assertEquals('css/packed.css', (string) $xml->asset[0]['url']);
|
||||
}
|
||||
|
||||
public function testImage()
|
||||
{
|
||||
$xml = $this->renderXml('image.twig');
|
||||
$this->assertEquals(1, count($xml->image));
|
||||
$this->assertStringEndsWith('.png', (string) $xml->image[0]['url']);
|
||||
}
|
||||
|
||||
public function testFilterFunction()
|
||||
{
|
||||
$filter = $this->getMock('Assetic\\Filter\\FilterInterface');
|
||||
|
||||
$this->fm->expects($this->once())
|
||||
->method('get')
|
||||
->with('some_filter')
|
||||
->will($this->returnValue($filter));
|
||||
|
||||
$this->twig->addExtension(new AsseticExtension($this->factory, array(
|
||||
'some_func' => array(
|
||||
'filter' => 'some_filter',
|
||||
'options' => array('output' => 'css/*.css'),
|
||||
),
|
||||
)));
|
||||
|
||||
$xml = $this->renderXml('function.twig');
|
||||
$this->assertEquals(1, count($xml->asset));
|
||||
$this->assertStringEndsWith('.css', (string) $xml->asset[0]['url']);
|
||||
}
|
||||
|
||||
public function testVariables()
|
||||
{
|
||||
$this->valueSupplier->expects($this->once())
|
||||
->method('getValues')
|
||||
->will($this->returnValue(array('foo' => 'a', 'bar' => 'b')));
|
||||
|
||||
$xml = $this->renderXml('variables.twig');
|
||||
$this->assertEquals(2, $xml->url->count());
|
||||
$this->assertEquals("js/7d0828c_foo_1.a.b.js", (string) $xml->url[0]);
|
||||
$this->assertEquals("js/7d0828c_variable_input.a_2.a.b.js", (string) $xml->url[1]);
|
||||
}
|
||||
|
||||
private function renderXml($name, $context = array())
|
||||
{
|
||||
return new \SimpleXMLElement($this->twig->loadTemplate($name)->render($context));
|
||||
}
|
||||
}
|
97
vendor/kriswallsmith/assetic/tests/Assetic/Test/Extension/Twig/TwigFormulaLoaderTest.php
vendored
Normal file
97
vendor/kriswallsmith/assetic/tests/Assetic/Test/Extension/Twig/TwigFormulaLoaderTest.php
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
<?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\Extension\Twig;
|
||||
|
||||
use Assetic\Factory\AssetFactory;
|
||||
use Assetic\Extension\Twig\AsseticExtension;
|
||||
use Assetic\Extension\Twig\TwigFormulaLoader;
|
||||
|
||||
class TwigFormulaLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $am;
|
||||
private $fm;
|
||||
private $twig;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
if (!class_exists('Twig_Environment')) {
|
||||
$this->markTestSkipped('Twig is not installed.');
|
||||
}
|
||||
|
||||
$this->am = $this->getMock('Assetic\\AssetManager');
|
||||
$this->fm = $this->getMock('Assetic\\FilterManager');
|
||||
|
||||
$factory = new AssetFactory(__DIR__.'/templates');
|
||||
$factory->setAssetManager($this->am);
|
||||
$factory->setFilterManager($this->fm);
|
||||
|
||||
$twig = new \Twig_Environment();
|
||||
$twig->addExtension(new AsseticExtension($factory, array(
|
||||
'some_func' => array(
|
||||
'filter' => 'some_filter',
|
||||
'options' => array('output' => 'css/*.css'),
|
||||
),
|
||||
)));
|
||||
|
||||
$this->loader = new TwigFormulaLoader($twig);
|
||||
}
|
||||
|
||||
public function testMixture()
|
||||
{
|
||||
$asset = $this->getMock('Assetic\\Asset\\AssetInterface');
|
||||
|
||||
$expected = array(
|
||||
'mixture' => array(
|
||||
array('foo', 'foo/*', '@foo'),
|
||||
array(),
|
||||
array(
|
||||
'output' => 'packed/mixture',
|
||||
'name' => 'mixture',
|
||||
'debug' => false,
|
||||
'combine' => null,
|
||||
'vars' => array(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$resource = $this->getMock('Assetic\\Factory\\Resource\\ResourceInterface');
|
||||
$resource->expects($this->once())
|
||||
->method('getContent')
|
||||
->will($this->returnValue(file_get_contents(__DIR__.'/templates/mixture.twig')));
|
||||
$this->am->expects($this->any())
|
||||
->method('get')
|
||||
->with('foo')
|
||||
->will($this->returnValue($asset));
|
||||
|
||||
$formulae = $this->loader->load($resource);
|
||||
$this->assertEquals($expected, $formulae);
|
||||
}
|
||||
|
||||
public function testFunction()
|
||||
{
|
||||
$expected = array(
|
||||
'my_asset' => array(
|
||||
array('path/to/asset'),
|
||||
array('some_filter'),
|
||||
array('output' => 'css/*.css', 'name' => 'my_asset'),
|
||||
),
|
||||
);
|
||||
|
||||
$resource = $this->getMock('Assetic\\Factory\\Resource\\ResourceInterface');
|
||||
$resource->expects($this->once())
|
||||
->method('getContent')
|
||||
->will($this->returnValue(file_get_contents(__DIR__.'/templates/function.twig')));
|
||||
|
||||
$formulae = $this->loader->load($resource);
|
||||
$this->assertEquals($expected, $formulae);
|
||||
}
|
||||
}
|
48
vendor/kriswallsmith/assetic/tests/Assetic/Test/Extension/Twig/TwigResourceTest.php
vendored
Normal file
48
vendor/kriswallsmith/assetic/tests/Assetic/Test/Extension/Twig/TwigResourceTest.php
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
<?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\Extension\Twig;
|
||||
|
||||
use Assetic\Extension\Twig\TwigResource;
|
||||
|
||||
class TwigResourceTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
if (!class_exists('Twig_Environment')) {
|
||||
$this->markTestSkipped('Twig is not installed.');
|
||||
}
|
||||
}
|
||||
|
||||
public function testInvalidTemplateNameGetContent()
|
||||
{
|
||||
$loader = $this->getMock('Twig_LoaderInterface');
|
||||
$loader->expects($this->once())
|
||||
->method('getSource')
|
||||
->with('asdf')
|
||||
->will($this->throwException(new \Twig_Error_Loader('')));
|
||||
|
||||
$resource = new TwigResource($loader, 'asdf');
|
||||
$this->assertEquals('', $resource->getContent());
|
||||
}
|
||||
|
||||
public function testInvalidTemplateNameIsFresh()
|
||||
{
|
||||
$loader = $this->getMock('Twig_LoaderInterface');
|
||||
$loader->expects($this->once())
|
||||
->method('isFresh')
|
||||
->with('asdf', 1234)
|
||||
->will($this->throwException(new \Twig_Error_Loader('')));
|
||||
|
||||
$resource = new TwigResource($loader, 'asdf');
|
||||
$this->assertFalse($resource->isFresh(1234));
|
||||
}
|
||||
}
|
3
vendor/kriswallsmith/assetic/tests/Assetic/Test/Extension/Twig/templates/absolute_path.twig
vendored
Normal file
3
vendor/kriswallsmith/assetic/tests/Assetic/Test/Extension/Twig/templates/absolute_path.twig
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
<assets>
|
||||
{% stylesheets '/path/to/something.css' as='foo' %}<asset url="{{ foo }}" />{% endstylesheets %}
|
||||
</assets>
|
3
vendor/kriswallsmith/assetic/tests/Assetic/Test/Extension/Twig/templates/combine.twig
vendored
Normal file
3
vendor/kriswallsmith/assetic/tests/Assetic/Test/Extension/Twig/templates/combine.twig
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
<assets>
|
||||
{% stylesheets 'foo.css' 'bar.css' filter='?foo,bar' output='css/packed.css' debug=true combine=true %}<asset url="{{ asset_url }}" />{% endstylesheets %}
|
||||
</assets>
|
3
vendor/kriswallsmith/assetic/tests/Assetic/Test/Extension/Twig/templates/debug.twig
vendored
Normal file
3
vendor/kriswallsmith/assetic/tests/Assetic/Test/Extension/Twig/templates/debug.twig
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
<assets>
|
||||
{% stylesheets 'foo.css' 'bar.css' filter='?foo,bar' output='css/packed.css' debug=true %}<asset url="{{ asset_url }}" />{% endstylesheets %}
|
||||
</assets>
|
3
vendor/kriswallsmith/assetic/tests/Assetic/Test/Extension/Twig/templates/filters.twig
vendored
Normal file
3
vendor/kriswallsmith/assetic/tests/Assetic/Test/Extension/Twig/templates/filters.twig
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
<assets>
|
||||
{% stylesheets 'foo' filter='foo, bar' %}<asset url="{{ asset_url }}" />{% endstylesheets %}
|
||||
</assets>
|
3
vendor/kriswallsmith/assetic/tests/Assetic/Test/Extension/Twig/templates/function.twig
vendored
Normal file
3
vendor/kriswallsmith/assetic/tests/Assetic/Test/Extension/Twig/templates/function.twig
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
<assets>
|
||||
<asset url="{{ some_func('path/to/asset', { 'name': 'my_asset' }) }}" />
|
||||
</assets>
|
3
vendor/kriswallsmith/assetic/tests/Assetic/Test/Extension/Twig/templates/glob.twig
vendored
Normal file
3
vendor/kriswallsmith/assetic/tests/Assetic/Test/Extension/Twig/templates/glob.twig
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
<assets>
|
||||
{% stylesheets 'css/src/*' %}<asset url="{{ asset_url }}" />{% endstylesheets %}
|
||||
</assets>
|
3
vendor/kriswallsmith/assetic/tests/Assetic/Test/Extension/Twig/templates/image.twig
vendored
Normal file
3
vendor/kriswallsmith/assetic/tests/Assetic/Test/Extension/Twig/templates/image.twig
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
<images>
|
||||
{% image 'images/foo.png' %}<image url="{{ asset_url }}" />{% endimage %}
|
||||
</images>
|
3
vendor/kriswallsmith/assetic/tests/Assetic/Test/Extension/Twig/templates/mixture.twig
vendored
Normal file
3
vendor/kriswallsmith/assetic/tests/Assetic/Test/Extension/Twig/templates/mixture.twig
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
<assets>
|
||||
{% stylesheets 'foo' 'foo/*' '@foo' output='packed/*' name='mixture' %}<asset url="{{ asset_url }}" />{% endstylesheets %}
|
||||
</assets>
|
@@ -0,0 +1,3 @@
|
||||
<assets>
|
||||
{% stylesheets 'foo' filter='?foo' %}<asset url="{{ asset_url }}" />{% endstylesheets %}
|
||||
</assets>
|
3
vendor/kriswallsmith/assetic/tests/Assetic/Test/Extension/Twig/templates/output_pattern.twig
vendored
Normal file
3
vendor/kriswallsmith/assetic/tests/Assetic/Test/Extension/Twig/templates/output_pattern.twig
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
<assets>
|
||||
{% stylesheets 'foo' output='css/packed/*.css' %}<asset url="{{ asset_url }}" />{% endstylesheets %}
|
||||
</assets>
|
3
vendor/kriswallsmith/assetic/tests/Assetic/Test/Extension/Twig/templates/output_url.twig
vendored
Normal file
3
vendor/kriswallsmith/assetic/tests/Assetic/Test/Extension/Twig/templates/output_url.twig
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
<assets>
|
||||
{% stylesheets 'foo' output='explicit_url.css' %}<asset url="{{ asset_url }}" />{% endstylesheets %}
|
||||
</assets>
|
3
vendor/kriswallsmith/assetic/tests/Assetic/Test/Extension/Twig/templates/reference.twig
vendored
Normal file
3
vendor/kriswallsmith/assetic/tests/Assetic/Test/Extension/Twig/templates/reference.twig
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
<assets>
|
||||
{% stylesheets '@foo' %}<asset url="{{ asset_url }}" />{% endstylesheets %}
|
||||
</assets>
|
5
vendor/kriswallsmith/assetic/tests/Assetic/Test/Extension/Twig/templates/variables.twig
vendored
Normal file
5
vendor/kriswallsmith/assetic/tests/Assetic/Test/Extension/Twig/templates/variables.twig
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
<assets>
|
||||
{% javascripts "foo.js" "variable_input.{foo}.js" vars=["foo", "bar"] debug=true %}
|
||||
<url>{{ asset_url }}</url>
|
||||
{% endjavascripts %}
|
||||
</assets>
|
203
vendor/kriswallsmith/assetic/tests/Assetic/Test/Factory/AssetFactoryTest.php
vendored
Normal file
203
vendor/kriswallsmith/assetic/tests/Assetic/Test/Factory/AssetFactoryTest.php
vendored
Normal file
@@ -0,0 +1,203 @@
|
||||
<?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\Factory;
|
||||
|
||||
use Assetic\Factory\AssetFactory;
|
||||
|
||||
class AssetFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $am;
|
||||
private $fm;
|
||||
private $factory;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->am = $this->getMock('Assetic\\AssetManager');
|
||||
$this->fm = $this->getMock('Assetic\\FilterManager');
|
||||
|
||||
$this->factory = new AssetFactory(__DIR__);
|
||||
$this->factory->setAssetManager($this->am);
|
||||
$this->factory->setFilterManager($this->fm);
|
||||
}
|
||||
|
||||
public function testNoAssetManagerReference()
|
||||
{
|
||||
$this->setExpectedException('LogicException', 'There is no asset manager.');
|
||||
|
||||
$factory = new AssetFactory('.');
|
||||
$factory->createAsset(array('@foo'));
|
||||
}
|
||||
|
||||
public function testNoAssetManagerNotReference()
|
||||
{
|
||||
$factory = new AssetFactory('.');
|
||||
$this->assertInstanceOf('Assetic\\Asset\\AssetInterface', $factory->createAsset(array('foo')));
|
||||
}
|
||||
|
||||
public function testNoFilterManager()
|
||||
{
|
||||
$this->setExpectedException('LogicException', 'There is no filter manager.');
|
||||
|
||||
$factory = new AssetFactory('.');
|
||||
$factory->createAsset(array('foo'), array('foo'));
|
||||
}
|
||||
|
||||
public function testCreateAssetReference()
|
||||
{
|
||||
$referenced = $this->getMock('Assetic\\Asset\\AssetInterface');
|
||||
|
||||
$this->am->expects($this->any())
|
||||
->method('get')
|
||||
->with('jquery')
|
||||
->will($this->returnValue($referenced));
|
||||
|
||||
$assets = $this->factory->createAsset(array('@jquery'));
|
||||
$arr = iterator_to_array($assets);
|
||||
$this->assertInstanceOf('Assetic\\Asset\\AssetReference', $arr[0], '->createAsset() creates a reference');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getHttpUrls
|
||||
*/
|
||||
public function testCreateHttpAsset($sourceUrl)
|
||||
{
|
||||
$assets = $this->factory->createAsset(array($sourceUrl));
|
||||
$arr = iterator_to_array($assets);
|
||||
$this->assertInstanceOf('Assetic\\Asset\\HttpAsset', $arr[0], '->createAsset() creates an HTTP asset');
|
||||
}
|
||||
|
||||
public function getHttpUrls()
|
||||
{
|
||||
return array(
|
||||
array('http://example.com/foo.css'),
|
||||
array('https://example.com/foo.css'),
|
||||
array('//example.com/foo.css'),
|
||||
);
|
||||
}
|
||||
|
||||
public function testCreateFileAsset()
|
||||
{
|
||||
$assets = $this->factory->createAsset(array(basename(__FILE__)));
|
||||
$arr = iterator_to_array($assets);
|
||||
$this->assertInstanceOf('Assetic\\Asset\\FileAsset', $arr[0], '->createAsset() creates a file asset');
|
||||
}
|
||||
|
||||
public function testCreateGlobAsset()
|
||||
{
|
||||
$assets = $this->factory->createAsset(array('*'));
|
||||
$arr = iterator_to_array($assets);
|
||||
$this->assertInstanceOf('Assetic\\Asset\\FileAsset', $arr[0], '->createAsset() uses a glob to create a file assets');
|
||||
}
|
||||
|
||||
public function testCreateAssetCollection()
|
||||
{
|
||||
$asset = $this->factory->createAsset(array('*', basename(__FILE__)));
|
||||
$this->assertInstanceOf('Assetic\\Asset\\AssetCollection', $asset, '->createAsset() creates an asset collection');
|
||||
}
|
||||
|
||||
public function testFilter()
|
||||
{
|
||||
$this->fm->expects($this->once())
|
||||
->method('get')
|
||||
->with('foo')
|
||||
->will($this->returnValue($this->getMock('Assetic\\Filter\\FilterInterface')));
|
||||
|
||||
$asset = $this->factory->createAsset(array(), array('foo'));
|
||||
$this->assertEquals(1, count($asset->getFilters()), '->createAsset() adds filters');
|
||||
}
|
||||
|
||||
public function testInvalidFilter()
|
||||
{
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
|
||||
$this->fm->expects($this->once())
|
||||
->method('get')
|
||||
->with('foo')
|
||||
->will($this->throwException(new \InvalidArgumentException()));
|
||||
|
||||
$asset = $this->factory->createAsset(array(), array('foo'));
|
||||
}
|
||||
|
||||
public function testOptionalInvalidFilter()
|
||||
{
|
||||
$this->factory->setDebug(true);
|
||||
|
||||
$asset = $this->factory->createAsset(array(), array('?foo'));
|
||||
|
||||
$this->assertEquals(0, count($asset->getFilters()), '->createAsset() does not add an optional invalid filter');
|
||||
}
|
||||
|
||||
public function testIncludingOptionalFilter()
|
||||
{
|
||||
$this->fm->expects($this->once())
|
||||
->method('get')
|
||||
->with('foo')
|
||||
->will($this->returnValue($this->getMock('Assetic\\Filter\\FilterInterface')));
|
||||
|
||||
$this->factory->createAsset(array('foo.css'), array('?foo'));
|
||||
}
|
||||
|
||||
public function testWorkers()
|
||||
{
|
||||
$worker = $this->getMock('Assetic\\Factory\\Worker\\WorkerInterface');
|
||||
|
||||
// called once on the collection and once on each leaf
|
||||
$worker->expects($this->exactly(3))
|
||||
->method('process')
|
||||
->with($this->isInstanceOf('Assetic\\Asset\\AssetInterface'));
|
||||
|
||||
$this->factory->addWorker($worker);
|
||||
$this->factory->createAsset(array('foo.js', 'bar.js'));
|
||||
}
|
||||
|
||||
public function testWorkerReturn()
|
||||
{
|
||||
$worker = $this->getMock('Assetic\\Factory\\Worker\\WorkerInterface');
|
||||
$asset = $this->getMock('Assetic\\Asset\\AssetInterface');
|
||||
|
||||
$worker->expects($this->at(2))
|
||||
->method('process')
|
||||
->with($this->isInstanceOf('Assetic\\Asset\\AssetCollectionInterface'))
|
||||
->will($this->returnValue($asset));
|
||||
|
||||
$this->factory->addWorker($worker);
|
||||
$coll = $this->factory->createAsset(array('foo.js', 'bar.js'));
|
||||
|
||||
$this->assertEquals(1, count(iterator_to_array($coll)));
|
||||
}
|
||||
|
||||
public function testNestedFormula()
|
||||
{
|
||||
$this->fm->expects($this->once())
|
||||
->method('get')
|
||||
->with('foo')
|
||||
->will($this->returnValue($this->getMock('Assetic\\Filter\\FilterInterface')));
|
||||
|
||||
$inputs = array(
|
||||
'css/main.css',
|
||||
array(
|
||||
// nested formula
|
||||
array('css/more.sass'),
|
||||
array('foo'),
|
||||
),
|
||||
);
|
||||
|
||||
$asset = $this->factory->createAsset($inputs, array(), array('output' => 'css/*.css'));
|
||||
|
||||
$i = 0;
|
||||
foreach ($asset as $leaf) {
|
||||
$i++;
|
||||
}
|
||||
|
||||
$this->assertEquals(2, $i);
|
||||
}
|
||||
}
|
96
vendor/kriswallsmith/assetic/tests/Assetic/Test/Factory/LazyAssetManagerTest.php
vendored
Normal file
96
vendor/kriswallsmith/assetic/tests/Assetic/Test/Factory/LazyAssetManagerTest.php
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
<?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\Factory;
|
||||
|
||||
use Assetic\Factory\LazyAssetManager;
|
||||
|
||||
class LazyAssetManagerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $factory;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->factory = $this->getMockBuilder('Assetic\\Factory\\AssetFactory')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$this->am = new LazyAssetManager($this->factory);
|
||||
}
|
||||
|
||||
public function testGetFromLoader()
|
||||
{
|
||||
$resource = $this->getMock('Assetic\\Factory\\Resource\\ResourceInterface');
|
||||
$loader = $this->getMock('Assetic\\Factory\\Loader\\FormulaLoaderInterface');
|
||||
$asset = $this->getMock('Assetic\\Asset\\AssetInterface');
|
||||
|
||||
$formula = array(
|
||||
array('js/core.js', 'js/more.js'),
|
||||
array('?yui_js'),
|
||||
array('output' => 'js/all.js')
|
||||
);
|
||||
|
||||
$loader->expects($this->once())
|
||||
->method('load')
|
||||
->with($resource)
|
||||
->will($this->returnValue(array('foo' => $formula)));
|
||||
$this->factory->expects($this->once())
|
||||
->method('createAsset')
|
||||
->with($formula[0], $formula[1], $formula[2] + array('name' => 'foo'))
|
||||
->will($this->returnValue($asset));
|
||||
|
||||
$this->am->setLoader('foo', $loader);
|
||||
$this->am->addResource($resource, 'foo');
|
||||
|
||||
$this->assertSame($asset, $this->am->get('foo'), '->get() returns an asset from the loader');
|
||||
|
||||
// test the "once" expectations
|
||||
$this->am->get('foo');
|
||||
}
|
||||
|
||||
public function testGetResources()
|
||||
{
|
||||
$resources = array(
|
||||
$this->getMock('Assetic\\Factory\\Resource\\ResourceInterface'),
|
||||
$this->getMock('Assetic\\Factory\\Resource\\ResourceInterface'),
|
||||
);
|
||||
|
||||
$this->am->addResource($resources[0], 'foo');
|
||||
$this->am->addResource($resources[1], 'bar');
|
||||
|
||||
$ret = $this->am->getResources();
|
||||
|
||||
foreach ($resources as $resource) {
|
||||
$this->assertTrue(in_array($resource, $ret, true));
|
||||
}
|
||||
}
|
||||
|
||||
public function testGetResourcesEmpty()
|
||||
{
|
||||
$this->am->getResources();
|
||||
}
|
||||
|
||||
public function testSetFormula()
|
||||
{
|
||||
$this->am->setFormula('foo', array());
|
||||
$this->am->load();
|
||||
$this->assertTrue($this->am->hasFormula('foo'), '->load() does not remove manually added formulae');
|
||||
}
|
||||
|
||||
public function testIsDebug()
|
||||
{
|
||||
$this->factory->expects($this->once())
|
||||
->method('isDebug')
|
||||
->will($this->returnValue(false));
|
||||
|
||||
$this->assertSame(false, $this->am->isDebug(), '->isDebug() proxies the factory');
|
||||
}
|
||||
}
|
138
vendor/kriswallsmith/assetic/tests/Assetic/Test/Factory/Loader/CachedFormulaLoaderTest.php
vendored
Normal file
138
vendor/kriswallsmith/assetic/tests/Assetic/Test/Factory/Loader/CachedFormulaLoaderTest.php
vendored
Normal file
@@ -0,0 +1,138 @@
|
||||
<?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\Factory\Loader;
|
||||
|
||||
use Assetic\Factory\Loader\CachedFormulaLoader;
|
||||
|
||||
class CachedFormulaLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $loader;
|
||||
protected $configCache;
|
||||
protected $resource;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->loader = $this->getMock('Assetic\\Factory\\Loader\\FormulaLoaderInterface');
|
||||
$this->configCache = $this->getMockBuilder('Assetic\\Cache\\ConfigCache')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->resource = $this->getMock('Assetic\\Factory\\Resource\\ResourceInterface');
|
||||
}
|
||||
|
||||
public function testNotDebug()
|
||||
{
|
||||
$expected = array(
|
||||
'foo' => array(array(), array(), array()),
|
||||
'bar' => array(array(), array(), array()),
|
||||
);
|
||||
|
||||
$this->configCache->expects($this->once())
|
||||
->method('has')
|
||||
->with($this->isType('string'))
|
||||
->will($this->returnValue(false));
|
||||
$this->loader->expects($this->once())
|
||||
->method('load')
|
||||
->with($this->resource)
|
||||
->will($this->returnValue($expected));
|
||||
$this->configCache->expects($this->once())
|
||||
->method('set')
|
||||
->with($this->isType('string'), $expected);
|
||||
|
||||
$loader = new CachedFormulaLoader($this->loader, $this->configCache);
|
||||
$this->assertEquals($expected, $loader->load($this->resource), '->load() returns formulae');
|
||||
}
|
||||
|
||||
public function testNotDebugCached()
|
||||
{
|
||||
$expected = array(
|
||||
'foo' => array(array(), array(), array()),
|
||||
'bar' => array(array(), array(), array()),
|
||||
);
|
||||
|
||||
$this->configCache->expects($this->once())
|
||||
->method('has')
|
||||
->with($this->isType('string'))
|
||||
->will($this->returnValue(true));
|
||||
$this->resource->expects($this->never())
|
||||
->method('isFresh');
|
||||
$this->configCache->expects($this->once())
|
||||
->method('get')
|
||||
->with($this->isType('string'))
|
||||
->will($this->returnValue($expected));
|
||||
|
||||
$loader = new CachedFormulaLoader($this->loader, $this->configCache);
|
||||
$this->assertEquals($expected, $loader->load($this->resource), '->load() returns formulae');
|
||||
}
|
||||
|
||||
public function testDebugCached()
|
||||
{
|
||||
$timestamp = 123;
|
||||
$expected = array(
|
||||
'foo' => array(array(), array(), array()),
|
||||
'bar' => array(array(), array(), array()),
|
||||
);
|
||||
|
||||
$this->configCache->expects($this->once())
|
||||
->method('has')
|
||||
->with($this->isType('string'))
|
||||
->will($this->returnValue(true));
|
||||
$this->configCache->expects($this->once())
|
||||
->method('getTimestamp')
|
||||
->with($this->isType('string'))
|
||||
->will($this->returnValue($timestamp));
|
||||
$this->resource->expects($this->once())
|
||||
->method('isFresh')
|
||||
->with($timestamp)
|
||||
->will($this->returnValue(true));
|
||||
$this->loader->expects($this->never())
|
||||
->method('load');
|
||||
$this->configCache->expects($this->once())
|
||||
->method('get')
|
||||
->with($this->isType('string'))
|
||||
->will($this->returnValue($expected));
|
||||
|
||||
$loader = new CachedFormulaLoader($this->loader, $this->configCache, true);
|
||||
$this->assertEquals($expected, $loader->load($this->resource), '->load() returns formulae');
|
||||
}
|
||||
|
||||
public function testDebugCachedStale()
|
||||
{
|
||||
$timestamp = 123;
|
||||
$expected = array(
|
||||
'foo' => array(array(), array(), array()),
|
||||
'bar' => array(array(), array(), array()),
|
||||
);
|
||||
|
||||
$this->configCache->expects($this->once())
|
||||
->method('has')
|
||||
->with($this->isType('string'))
|
||||
->will($this->returnValue(true));
|
||||
$this->configCache->expects($this->once())
|
||||
->method('getTimestamp')
|
||||
->with($this->isType('string'))
|
||||
->will($this->returnValue($timestamp));
|
||||
$this->resource->expects($this->once())
|
||||
->method('isFresh')
|
||||
->with($timestamp)
|
||||
->will($this->returnValue(false));
|
||||
$this->loader->expects($this->once())
|
||||
->method('load')
|
||||
->with($this->resource)
|
||||
->will($this->returnValue($expected));
|
||||
$this->configCache->expects($this->once())
|
||||
->method('set')
|
||||
->with($this->isType('string'), $expected);
|
||||
|
||||
$loader = new CachedFormulaLoader($this->loader, $this->configCache, true);
|
||||
$this->assertEquals($expected, $loader->load($this->resource), '->load() returns formulae');
|
||||
}
|
||||
}
|
@@ -0,0 +1,69 @@
|
||||
<?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\Factory\Loader;
|
||||
|
||||
use Assetic\Factory\AssetFactory;
|
||||
use Assetic\Factory\Loader\FunctionCallsFormulaLoader;
|
||||
use Assetic\Factory\Resource\FileResource;
|
||||
|
||||
class FunctionCallsFormulaLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider getJavascriptInputs
|
||||
*/
|
||||
public function testInput($function, $inputs, $name, $expected)
|
||||
{
|
||||
$resource = $this->getMock('Assetic\\Factory\\Resource\\ResourceInterface');
|
||||
$factory = $this->getMockBuilder('Assetic\\Factory\\AssetFactory')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$resource->expects($this->once())
|
||||
->method('getContent')
|
||||
->will($this->returnValue('<?php '.$function.'('.$inputs.') ?>'));
|
||||
$factory->expects($this->once())
|
||||
->method('generateAssetName')
|
||||
->will($this->returnValue($name));
|
||||
|
||||
$loader = new FunctionCallsFormulaLoader($factory);
|
||||
$formulae = $loader->load($resource);
|
||||
|
||||
$this->assertEquals($expected, $formulae);
|
||||
}
|
||||
|
||||
public function getJavascriptInputs()
|
||||
{
|
||||
return array(
|
||||
array('assetic_javascripts', '"js/core.js"', 'asdf', array('asdf' => array(array('js/core.js'), array(), array('debug' => false, 'output' => 'js/*.js', 'name' => 'asdf', )))),
|
||||
array('assetic_javascripts', "'js/core.js'", 'asdf', array('asdf' => array(array('js/core.js'), array(), array('debug' => false, 'output' => 'js/*.js', 'name' => 'asdf', )))),
|
||||
array('assetic_javascripts', "array('js/core.js')", 'asdf', array('asdf' => array(array('js/core.js'), array(), array('debug' => false, 'output' => 'js/*.js', 'name' => 'asdf', )))),
|
||||
array('assetic_javascripts', 'array("js/core.js")', 'asdf', array('asdf' => array(array('js/core.js'), array(), array('debug' => false, 'output' => 'js/*.js', 'name' => 'asdf', )))),
|
||||
array('assetic_image', '"images/logo.gif"', 'asdf', array('asdf' => array(array('images/logo.gif'), array(), array('debug' => false, 'output' => 'images/*', 'name' => 'asdf')))),
|
||||
);
|
||||
}
|
||||
|
||||
public function testComplexFormula()
|
||||
{
|
||||
$factory = new AssetFactory(__DIR__.'/templates', true);
|
||||
$loader = new FunctionCallsFormulaLoader($factory);
|
||||
$resource = new FileResource(__DIR__.'/templates/debug.php');
|
||||
$formulae = $loader->load($resource);
|
||||
|
||||
$this->assertEquals(array(
|
||||
'test123' => array(
|
||||
array('foo.css', 'bar.css'),
|
||||
array('?foo', 'bar'),
|
||||
array('name' => 'test123', 'output' => 'css/packed.css', 'debug' => true),
|
||||
),
|
||||
), $formulae);
|
||||
}
|
||||
}
|
8
vendor/kriswallsmith/assetic/tests/Assetic/Test/Factory/Loader/templates/debug.php
vendored
Normal file
8
vendor/kriswallsmith/assetic/tests/Assetic/Test/Factory/Loader/templates/debug.php
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<assets>
|
||||
<?php foreach (assetic_stylesheets(
|
||||
array('foo.css', 'bar.css'),
|
||||
array('?foo', 'bar'),
|
||||
array('name' => 'test123', 'output' => 'css/packed.css', 'debug' => true)) as $url): ?>
|
||||
<asset url="<?php echo $url ?>" />
|
||||
<?php endforeach; ?>
|
||||
</assets>
|
@@ -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\Factory\Resource;
|
||||
|
||||
use Assetic\Factory\Resource\CoalescingDirectoryResource;
|
||||
use Assetic\Factory\Resource\DirectoryResource;
|
||||
|
||||
class CoalescingDirectoryResourceTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function shouldFilterFiles()
|
||||
{
|
||||
// notice only one directory has a trailing slash
|
||||
$resource = new CoalescingDirectoryResource(array(
|
||||
new DirectoryResource(__DIR__.'/Fixtures/dir1/', '/\.txt$/'),
|
||||
new DirectoryResource(__DIR__.'/Fixtures/dir2', '/\.txt$/'),
|
||||
));
|
||||
|
||||
$paths = array();
|
||||
foreach ($resource as $file) {
|
||||
$paths[] = realpath((string) $file);
|
||||
}
|
||||
sort($paths);
|
||||
|
||||
$this->assertEquals(array(
|
||||
realpath(__DIR__.'/Fixtures/dir1/file1.txt'),
|
||||
realpath(__DIR__.'/Fixtures/dir1/file2.txt'),
|
||||
realpath(__DIR__.'/Fixtures/dir2/file3.txt'),
|
||||
), $paths, 'files from multiple directories are merged');
|
||||
}
|
||||
}
|
108
vendor/kriswallsmith/assetic/tests/Assetic/Test/Factory/Resource/DirectoryResourceTest.php
vendored
Normal file
108
vendor/kriswallsmith/assetic/tests/Assetic/Test/Factory/Resource/DirectoryResourceTest.php
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
<?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\Factory\Resource;
|
||||
|
||||
use Assetic\Factory\Resource\DirectoryResource;
|
||||
|
||||
class DirectoryResourceTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testIsFresh()
|
||||
{
|
||||
$resource = new DirectoryResource(__DIR__);
|
||||
$this->assertTrue($resource->isFresh(time() + 5));
|
||||
$this->assertFalse($resource->isFresh(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getPatterns
|
||||
*/
|
||||
public function testGetContent($pattern)
|
||||
{
|
||||
$resource = new DirectoryResource(__DIR__, $pattern);
|
||||
$content = $resource->getContent();
|
||||
|
||||
$this->assertInternalType('string', $content);
|
||||
}
|
||||
|
||||
public function getPatterns()
|
||||
{
|
||||
return array(
|
||||
array(null),
|
||||
array('/\.php$/'),
|
||||
array('/\.foo$/'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getPatternsAndEmpty
|
||||
*/
|
||||
public function testIteration($pattern, $empty)
|
||||
{
|
||||
$resource = new DirectoryResource(__DIR__, $pattern);
|
||||
|
||||
$count = 0;
|
||||
foreach ($resource as $r) {
|
||||
++$count;
|
||||
$this->assertInstanceOf('Assetic\\Factory\\Resource\\ResourceInterface', $r);
|
||||
}
|
||||
|
||||
if ($empty) {
|
||||
$this->assertEmpty($count);
|
||||
} else {
|
||||
$this->assertNotEmpty($count);
|
||||
}
|
||||
}
|
||||
|
||||
public function getPatternsAndEmpty()
|
||||
{
|
||||
return array(
|
||||
array(null, false),
|
||||
array('/\.php$/', false),
|
||||
array('/\.foo$/', true),
|
||||
);
|
||||
}
|
||||
|
||||
public function testRecursiveIteration()
|
||||
{
|
||||
$resource = new DirectoryResource(realpath(__DIR__.'/..'), '/^'.preg_quote(basename(__FILE__)).'$/');
|
||||
|
||||
$count = 0;
|
||||
foreach ($resource as $r) {
|
||||
++$count;
|
||||
}
|
||||
|
||||
$this->assertEquals(1, $count);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getPaths
|
||||
*/
|
||||
public function testTrailingSlash($path)
|
||||
{
|
||||
$resource = new DirectoryResource($path);
|
||||
$this->assertStringEndsWith(DIRECTORY_SEPARATOR, (string) $resource, 'path ends with a slash');
|
||||
}
|
||||
|
||||
public function getPaths()
|
||||
{
|
||||
return array(
|
||||
array(__DIR__),
|
||||
array(__DIR__.DIRECTORY_SEPARATOR),
|
||||
);
|
||||
}
|
||||
|
||||
public function testInvalidDirectory()
|
||||
{
|
||||
$resource = new DirectoryResource(__DIR__.'foo');
|
||||
$this->assertEquals(0, iterator_count($resource), 'works for non-existent directory');
|
||||
}
|
||||
}
|
42
vendor/kriswallsmith/assetic/tests/Assetic/Test/Factory/Resource/FileResourceTest.php
vendored
Normal file
42
vendor/kriswallsmith/assetic/tests/Assetic/Test/Factory/Resource/FileResourceTest.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\Factory\Resource;
|
||||
|
||||
use Assetic\Factory\Resource\FileResource;
|
||||
|
||||
class FileResourceTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testIsFresh()
|
||||
{
|
||||
$resource = new FileResource(__FILE__);
|
||||
$this->assertTrue($resource->isFresh(time() + 5));
|
||||
$this->assertFalse($resource->isFresh(0));
|
||||
}
|
||||
|
||||
public function testGetContent()
|
||||
{
|
||||
$resource = new FileResource(__FILE__);
|
||||
$this->assertEquals(file_get_contents(__FILE__), $resource->getContent());
|
||||
}
|
||||
|
||||
public function testIsFreshOnInvalidPath()
|
||||
{
|
||||
$resource = new FileResource(__FILE__.'foo');
|
||||
$this->assertFalse($resource->isFresh(time()), '->isFresh() returns false if the file does not exist');
|
||||
}
|
||||
|
||||
public function testGetContentOnInvalidPath()
|
||||
{
|
||||
$resource = new FileResource(__FILE__.'foo');
|
||||
$this->assertSame('', $resource->getContent(), '->getContent() returns an empty string when path is invalid');
|
||||
}
|
||||
}
|
0
vendor/kriswallsmith/assetic/tests/Assetic/Test/Factory/Resource/Fixtures/dir1/file1.txt
vendored
Normal file
0
vendor/kriswallsmith/assetic/tests/Assetic/Test/Factory/Resource/Fixtures/dir1/file1.txt
vendored
Normal file
0
vendor/kriswallsmith/assetic/tests/Assetic/Test/Factory/Resource/Fixtures/dir1/file2.txt
vendored
Normal file
0
vendor/kriswallsmith/assetic/tests/Assetic/Test/Factory/Resource/Fixtures/dir1/file2.txt
vendored
Normal file
0
vendor/kriswallsmith/assetic/tests/Assetic/Test/Factory/Resource/Fixtures/dir2/file1.txt
vendored
Normal file
0
vendor/kriswallsmith/assetic/tests/Assetic/Test/Factory/Resource/Fixtures/dir2/file1.txt
vendored
Normal file
0
vendor/kriswallsmith/assetic/tests/Assetic/Test/Factory/Resource/Fixtures/dir2/file3.txt
vendored
Normal file
0
vendor/kriswallsmith/assetic/tests/Assetic/Test/Factory/Resource/Fixtures/dir2/file3.txt
vendored
Normal file
47
vendor/kriswallsmith/assetic/tests/Assetic/Test/Factory/Worker/EnsureFilterWorkerTest.php
vendored
Normal file
47
vendor/kriswallsmith/assetic/tests/Assetic/Test/Factory/Worker/EnsureFilterWorkerTest.php
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
<?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\Factory\Worker;
|
||||
|
||||
use Assetic\Factory\Worker\EnsureFilterWorker;
|
||||
|
||||
class EnsureFilterWorkerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testMatch()
|
||||
{
|
||||
$filter = $this->getMock('Assetic\\Filter\\FilterInterface');
|
||||
$asset = $this->getMock('Assetic\\Asset\\AssetInterface');
|
||||
|
||||
$asset->expects($this->once())
|
||||
->method('getTargetPath')
|
||||
->will($this->returnValue('css/main.css'));
|
||||
$asset->expects($this->once())
|
||||
->method('ensureFilter')
|
||||
->with($filter);
|
||||
|
||||
$worker = new EnsureFilterWorker('/\.css$/', $filter);
|
||||
$worker->process($asset);
|
||||
}
|
||||
|
||||
public function testNonMatch()
|
||||
{
|
||||
$filter = $this->getMock('Assetic\\Filter\\FilterInterface');
|
||||
$asset = $this->getMock('Assetic\\Asset\\AssetInterface');
|
||||
|
||||
$asset->expects($this->once())
|
||||
->method('getTargetPath')
|
||||
->will($this->returnValue('js/all.js'));
|
||||
$asset->expects($this->never())->method('ensureFilter');
|
||||
|
||||
$worker = new EnsureFilterWorker('/\.css$/', $filter);
|
||||
$worker->process($asset);
|
||||
}
|
||||
}
|
24
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/BaseImageFilterTest.php
vendored
Normal file
24
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/BaseImageFilterTest.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?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\Filter;
|
||||
|
||||
abstract class BaseImageFilterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
static public function assertMimeType($expected, $data, $message = null)
|
||||
{
|
||||
$finfo = new \finfo(FILEINFO_MIME_TYPE);
|
||||
|
||||
$actual = file_exists($data) ? $finfo->file($data) : $finfo->buffer($data);
|
||||
|
||||
self::assertEquals($expected, $actual, $message);
|
||||
}
|
||||
}
|
39
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/CallablesFilterTest.php
vendored
Normal file
39
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/CallablesFilterTest.php
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
<?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\Filter;
|
||||
|
||||
use Assetic\Filter\CallablesFilter;
|
||||
|
||||
class CallablesFilterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testInterface()
|
||||
{
|
||||
$filter = new CallablesFilter();
|
||||
$this->assertInstanceOf('Assetic\\Filter\\FilterInterface', $filter, 'CallablesFilter implements FilterInterface');
|
||||
}
|
||||
|
||||
public function testLoader()
|
||||
{
|
||||
$nb = 0;
|
||||
$filter = new CallablesFilter(function($asset) use(&$nb) { $nb++; });
|
||||
$filter->filterLoad($this->getMock('Assetic\\Asset\\AssetInterface'));
|
||||
$this->assertEquals(1, $nb, '->filterLoad() calls the loader callable');
|
||||
}
|
||||
|
||||
public function testDumper()
|
||||
{
|
||||
$nb = 0;
|
||||
$filter = new CallablesFilter(null, function($asset) use(&$nb) { $nb++; });
|
||||
$filter->filterDump($this->getMock('Assetic\\Asset\\AssetInterface'));
|
||||
$this->assertEquals(1, $nb, '->filterDump() calls the loader callable');
|
||||
}
|
||||
}
|
73
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/CoffeeScriptFilterTest.php
vendored
Normal file
73
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/CoffeeScriptFilterTest.php
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
<?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\Filter;
|
||||
|
||||
use Assetic\Asset\StringAsset;
|
||||
use Assetic\Filter\CoffeeScriptFilter;
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
*/
|
||||
class CoffeeScriptFilterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $filter;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
if (!isset($_SERVER['COFFEE_BIN']) || !isset($_SERVER['NODE_BIN'])) {
|
||||
$this->markTestSkipped('There is no COFFEE_BIN or NODE_BIN environment variable.');
|
||||
}
|
||||
|
||||
$this->filter = new CoffeeScriptFilter($_SERVER['COFFEE_BIN'], $_SERVER['NODE_BIN']);
|
||||
}
|
||||
|
||||
public function testFilterLoad()
|
||||
{
|
||||
$expected = <<<JAVASCRIPT
|
||||
(function() {
|
||||
var square;
|
||||
|
||||
square = function(x) {
|
||||
return x * x;
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
JAVASCRIPT;
|
||||
|
||||
$asset = new StringAsset('square = (x) -> x * x');
|
||||
$asset->load();
|
||||
|
||||
$this->filter->filterLoad($asset);
|
||||
|
||||
$this->assertEquals($expected, $asset->getContent());
|
||||
}
|
||||
|
||||
public function testBare()
|
||||
{
|
||||
$expected = <<<JAVASCRIPT
|
||||
var square;
|
||||
|
||||
square = function(x) {
|
||||
return x * x;
|
||||
};
|
||||
|
||||
JAVASCRIPT;
|
||||
$asset = new StringAsset('square = (x) -> x * x');
|
||||
$asset->load();
|
||||
|
||||
$this->filter->setBare(true);
|
||||
$this->filter->filterLoad($asset);
|
||||
|
||||
$this->assertEquals($expected, $asset->getContent());
|
||||
}
|
||||
}
|
66
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/CompassFilterTest.php
vendored
Normal file
66
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/CompassFilterTest.php
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
<?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\Filter;
|
||||
|
||||
use Assetic\Asset\FileAsset;
|
||||
use Assetic\Filter\CompassFilter;
|
||||
|
||||
/**
|
||||
* Compass filter test case.
|
||||
*
|
||||
* @author Maxime Thirouin <dev@moox.fr>
|
||||
* @group integration
|
||||
*/
|
||||
class CompassFilterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
if (!isset($_SERVER['COMPASS_BIN'])) {
|
||||
$this->markTestSkipped('There is no COMPASS_BIN environment variable.');
|
||||
}
|
||||
}
|
||||
|
||||
public function testFilterLoadWithScss()
|
||||
{
|
||||
$asset = new FileAsset(__DIR__.'/fixtures/compass/stylesheet.scss');
|
||||
$asset->load();
|
||||
|
||||
$filter = new CompassFilter($_SERVER['COMPASS_BIN']);
|
||||
$filter->filterLoad($asset);
|
||||
|
||||
$this->assertContains('.test-class', $asset->getContent());
|
||||
$this->assertContains('font-size: 2em;', $asset->getContent());
|
||||
}
|
||||
|
||||
public function testFilterLoadWithSass()
|
||||
{
|
||||
$asset = new FileAsset(__DIR__.'/fixtures/compass/stylesheet.sass');
|
||||
$asset->load();
|
||||
|
||||
$filter = new CompassFilter($_SERVER['COMPASS_BIN']);
|
||||
$filter->filterLoad($asset);
|
||||
|
||||
$this->assertContains('.test-class', $asset->getContent());
|
||||
$this->assertContains('font-size: 2em;', $asset->getContent());
|
||||
}
|
||||
|
||||
public function testCompassMixin()
|
||||
{
|
||||
$asset = new FileAsset(__DIR__.'/fixtures/compass/compass.sass');
|
||||
$asset->load();
|
||||
|
||||
$filter = new CompassFilter($_SERVER['COMPASS_BIN']);
|
||||
$filter->filterLoad($asset);
|
||||
|
||||
$this->assertContains('text-decoration', $asset->getContent());
|
||||
}
|
||||
}
|
54
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/CssEmbedFilterTest.php
vendored
Normal file
54
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/CssEmbedFilterTest.php
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
<?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\Filter;
|
||||
|
||||
use Assetic\Asset\FileAsset;
|
||||
use Assetic\Filter\CssEmbedFilter;
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
*/
|
||||
class CssEmbedFilterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
if (!isset($_SERVER['CSSEMBED_JAR'])) {
|
||||
$this->markTestSkipped('There is no CSSEMBED_JAR environment variable.');
|
||||
}
|
||||
}
|
||||
|
||||
public function testCssEmbedDataUri()
|
||||
{
|
||||
$data = base64_encode(file_get_contents(__DIR__.'/fixtures/home.png'));
|
||||
|
||||
$asset = new FileAsset(__DIR__ . '/fixtures/cssembed/test.css');
|
||||
$asset->load();
|
||||
|
||||
$filter = new CssEmbedFilter($_SERVER['CSSEMBED_JAR']);
|
||||
$filter->filterDump($asset);
|
||||
|
||||
$this->assertContains('url(data:image/png;base64,'.$data, $asset->getContent());
|
||||
}
|
||||
|
||||
public function testCssEmbedMhtml()
|
||||
{
|
||||
$asset = new FileAsset(__DIR__ . '/fixtures/cssembed/test.css');
|
||||
$asset->load();
|
||||
|
||||
$filter = new CssEmbedFilter($_SERVER['CSSEMBED_JAR']);
|
||||
$filter->setMhtml(true);
|
||||
$filter->setMhtmlRoot('/test');
|
||||
$filter->filterDump($asset);
|
||||
|
||||
$this->assertContains('url(mhtml:/test/!', $asset->getContent());
|
||||
}
|
||||
}
|
67
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/CssImportFilterTest.php
vendored
Normal file
67
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/CssImportFilterTest.php
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
<?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\Filter;
|
||||
|
||||
use Assetic\Asset\FileAsset;
|
||||
use Assetic\Filter\CssImportFilter;
|
||||
use Assetic\Filter\CssRewriteFilter;
|
||||
|
||||
class CssImportFilterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider getFilters
|
||||
*/
|
||||
public function testImport($filter1, $filter2)
|
||||
{
|
||||
$asset = new FileAsset(__DIR__.'/fixtures/cssimport/main.css', array(), __DIR__.'/fixtures/cssimport', 'main.css');
|
||||
$asset->setTargetPath('foo/bar.css');
|
||||
$asset->ensureFilter($filter1);
|
||||
$asset->ensureFilter($filter2);
|
||||
|
||||
$expected = <<<CSS
|
||||
/* main.css */
|
||||
/* import.css */
|
||||
body { color: red; }
|
||||
/* more/evenmore/deep1.css */
|
||||
/* more/evenmore/deep2.css */
|
||||
body {
|
||||
background: url(../more/evenmore/bg.gif);
|
||||
}
|
||||
body { color: black; }
|
||||
CSS;
|
||||
|
||||
$this->assertEquals($expected, $asset->dump(), '->filterLoad() inlines CSS imports');
|
||||
}
|
||||
|
||||
/**
|
||||
* The order of these two filters is only interchangeable because one acts on
|
||||
* load and the other on dump. We need a more scalable solution.
|
||||
*/
|
||||
public function getFilters()
|
||||
{
|
||||
return array(
|
||||
array(new CssImportFilter(), new CssRewriteFilter()),
|
||||
array(new CssRewriteFilter(), new CssImportFilter()),
|
||||
);
|
||||
}
|
||||
|
||||
public function testNonCssImport()
|
||||
{
|
||||
$asset = new FileAsset(__DIR__.'/fixtures/cssimport/noncssimport.css', array(), __DIR__.'/fixtures/cssimport', 'noncssimport.css');
|
||||
$asset->load();
|
||||
|
||||
$filter = new CssImportFilter();
|
||||
$filter->filterLoad($asset);
|
||||
|
||||
$this->assertEquals(file_get_contents(__DIR__.'/fixtures/cssimport/noncssimport.css'), $asset->getContent(), '->filterLoad() skips non css');
|
||||
}
|
||||
}
|
40
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/CssMinFilterTest.php
vendored
Normal file
40
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/CssMinFilterTest.php
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
<?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\Filter;
|
||||
|
||||
use Assetic\Asset\FileAsset;
|
||||
use Assetic\Filter\CssMinFilter;
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
*/
|
||||
class CssMinFilterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
if (!class_exists('CssMin')) {
|
||||
$this->markTestSkipped('CssMin is not installed.');
|
||||
}
|
||||
}
|
||||
|
||||
public function testRelativeSourceUrlImportImports()
|
||||
{
|
||||
$asset = new FileAsset(__DIR__.'/fixtures/cssmin/main.css');
|
||||
$asset->load();
|
||||
|
||||
$filter = new CssMinFilter(__DIR__.'/fixtures/cssmin');
|
||||
$filter->setFilter('ImportImports', true);
|
||||
$filter->filterDump($asset);
|
||||
|
||||
$this->assertEquals('body{color:white}body{background:black}', $asset->getContent());
|
||||
}
|
||||
}
|
124
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/CssRewriteFilterTest.php
vendored
Normal file
124
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/CssRewriteFilterTest.php
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
<?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\Filter;
|
||||
|
||||
use Assetic\Asset\StringAsset;
|
||||
use Assetic\Filter\CssRewriteFilter;
|
||||
|
||||
class CssRewriteFilterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideUrls
|
||||
*/
|
||||
public function testUrls($format, $sourcePath, $targetPath, $inputUrl, $expectedUrl)
|
||||
{
|
||||
$asset = new StringAsset(sprintf($format, $inputUrl), array(), null, $sourcePath);
|
||||
$asset->setTargetPath($targetPath);
|
||||
$asset->load();
|
||||
|
||||
$filter = new CssRewriteFilter();
|
||||
$filter->filterLoad($asset);
|
||||
$filter->filterDump($asset);
|
||||
|
||||
$this->assertEquals(sprintf($format, $expectedUrl), $asset->getContent(), '->filterDump() rewrites relative urls');
|
||||
}
|
||||
|
||||
public function provideUrls()
|
||||
{
|
||||
return array(
|
||||
// url variants
|
||||
array('body { background: url(%s); }', 'css/body.css', 'css/build/main.css', '../images/bg.gif', '../../images/bg.gif'),
|
||||
array('body { background: url("%s"); }', 'css/body.css', 'css/build/main.css', '../images/bg.gif', '../../images/bg.gif'),
|
||||
array('body { background: url(\'%s\'); }', 'css/body.css', 'css/build/main.css', '../images/bg.gif', '../../images/bg.gif'),
|
||||
|
||||
//url with data:
|
||||
array('body { background: url(\'%s\'); }', 'css/body.css', 'css/build/main.css', 'data:image/png;base64,abcdef=', 'data:image/png;base64,abcdef='),
|
||||
array('body { background: url(\'%s\'); }', 'css/body.css', 'css/build/main.css', '../images/bg-data:.gif', '../../images/bg-data:.gif'),
|
||||
|
||||
// @import variants
|
||||
array('@import "%s";', 'css/imports.css', 'css/build/main.css', 'import.css', '../import.css'),
|
||||
array('@import url(%s);', 'css/imports.css', 'css/build/main.css', 'import.css', '../import.css'),
|
||||
array('@import url("%s");', 'css/imports.css', 'css/build/main.css', 'import.css', '../import.css'),
|
||||
array('@import url(\'%s\');', 'css/imports.css', 'css/build/main.css', 'import.css', '../import.css'),
|
||||
|
||||
// path diffs
|
||||
array('body { background: url(%s); }', 'css/body/bg.css', 'css/build/main.css', '../../images/bg.gif', '../../images/bg.gif'),
|
||||
array('body { background: url(%s); }', 'css/body.css', 'main.css', '../images/bg.gif', 'css/../images/bg.gif'), // fixme
|
||||
array('body { background: url(%s); }', 'body.css', 'css/main.css', 'images/bg.gif', '../images/bg.gif'),
|
||||
array('body { background: url(%s); }', 'source/css/body.css', 'output/build/main.css', '../images/bg.gif', '../../source/images/bg.gif'),
|
||||
array('body { background: url(%s); }', 'css/body.css', 'css/build/main.css', '//example.com/images/bg.gif', '//example.com/images/bg.gif'),
|
||||
|
||||
// url diffs
|
||||
array('body { background: url(%s); }', 'css/body.css', 'css/build/main.css', 'http://foo.com/bar.gif', 'http://foo.com/bar.gif'),
|
||||
array('body { background: url(%s); }', 'css/body.css', 'css/build/main.css', '/images/foo.gif', '/images/foo.gif'),
|
||||
array('body { background: url(%s); }', 'css/body.css', 'css/build/main.css', 'http://foo.com/images/foo.gif', 'http://foo.com/images/foo.gif'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideMultipleUrls
|
||||
*/
|
||||
public function testMultipleUrls($format, $sourcePath, $targetPath, $inputUrl1, $inputUrl2, $expectedUrl1, $expectedUrl2)
|
||||
{
|
||||
$asset = new StringAsset(sprintf($format, $inputUrl1, $inputUrl2), array(), null, $sourcePath);
|
||||
$asset->setTargetPath($targetPath);
|
||||
$asset->load();
|
||||
|
||||
$filter = new CssRewriteFilter();
|
||||
$filter->filterLoad($asset);
|
||||
$filter->filterDump($asset);
|
||||
|
||||
$this->assertEquals(sprintf($format, $expectedUrl1, $expectedUrl2), $asset->getContent(), '->filterDump() rewrites relative urls');
|
||||
}
|
||||
|
||||
public function provideMultipleUrls()
|
||||
{
|
||||
return array(
|
||||
// multiple url
|
||||
array('body { background: url(%s); background: url(%s); }', 'css/body.css', 'css/build/main.css', '../images/bg.gif', '../images/bg2.gif', '../../images/bg.gif', '../../images/bg2.gif'),
|
||||
array("body { background: url(%s);\nbackground: url(%s); }", 'css/body.css', 'css/build/main.css', '../images/bg.gif', '../images/bg2.gif', '../../images/bg.gif', '../../images/bg2.gif'),
|
||||
|
||||
// multiple import
|
||||
array('@import "%s"; @import "%s";', 'css/imports.css', 'css/build/main.css', 'import.css', 'import2.css', '../import.css', '../import2.css'),
|
||||
array("@import \"%s\";\n@import \"%s\";", 'css/imports.css', 'css/build/main.css', 'import.css', 'import2.css', '../import.css', '../import2.css'),
|
||||
|
||||
// mixed urls and imports
|
||||
array('@import "%s"; body { background: url(%s); }', 'css/body.css', 'css/build/main.css', 'import.css', '../images/bg2.gif', '../import.css', '../../images/bg2.gif'),
|
||||
array("@import \"%s\";\nbody { background: url(%s); }", 'css/body.css', 'css/build/main.css', 'import.css', '../images/bg2.gif', '../import.css', '../../images/bg2.gif'),
|
||||
);
|
||||
}
|
||||
|
||||
public function testNoTargetPath()
|
||||
{
|
||||
$content = 'body { background: url(foo.gif); }';
|
||||
|
||||
$asset = new StringAsset($content);
|
||||
$asset->load();
|
||||
|
||||
$filter = new CssRewriteFilter();
|
||||
$filter->filterDump($asset);
|
||||
|
||||
$this->assertEquals($content, $asset->getContent(), '->filterDump() urls are not changed without urls');
|
||||
}
|
||||
|
||||
public function testExternalSource()
|
||||
{
|
||||
$asset = new StringAsset('body { background: url(../images/bg.gif); }', array(), 'http://www.example.com', 'css/main.css');
|
||||
$asset->setTargetPath('css/packed/main.css');
|
||||
$asset->load();
|
||||
|
||||
$filter = new CssRewriteFilter();
|
||||
$filter->filterDump($asset);
|
||||
|
||||
$this->assertContains('http://www.example.com/css/../images/bg.gif', $asset->getContent(), '->filterDump() rewrites references in external stylesheets');
|
||||
}
|
||||
}
|
59
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/FilterCollectionTest.php
vendored
Normal file
59
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/FilterCollectionTest.php
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
<?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\Filter;
|
||||
|
||||
use Assetic\Filter\FilterCollection;
|
||||
|
||||
class FilterCollectionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testInterface()
|
||||
{
|
||||
$filter = new FilterCollection();
|
||||
$this->assertInstanceOf('Assetic\\Filter\\FilterInterface', $filter, 'FilterCollection implements FilterInterface');
|
||||
}
|
||||
|
||||
public function testEnsure()
|
||||
{
|
||||
$filter = $this->getMock('Assetic\\Filter\\FilterInterface');
|
||||
$asset = $this->getMock('Assetic\\Asset\\AssetInterface');
|
||||
|
||||
$filter->expects($this->once())->method('filterLoad');
|
||||
|
||||
$coll = new FilterCollection();
|
||||
$coll->ensure($filter);
|
||||
$coll->ensure($filter);
|
||||
$coll->filterLoad($asset);
|
||||
}
|
||||
|
||||
public function testAll()
|
||||
{
|
||||
$filter = new FilterCollection(array(
|
||||
$this->getMock('Assetic\\Filter\\FilterInterface'),
|
||||
$this->getMock('Assetic\\Filter\\FilterInterface'),
|
||||
));
|
||||
|
||||
$this->assertInternalType('array', $filter->all(), '->all() returns an array');
|
||||
}
|
||||
|
||||
public function testEmptyAll()
|
||||
{
|
||||
$filter = new FilterCollection();
|
||||
$this->assertInternalType('array', $filter->all(), '->all() returns an array');
|
||||
}
|
||||
|
||||
public function testCountable()
|
||||
{
|
||||
$filters = new FilterCollection(array($this->getMock('Assetic\\Filter\\FilterInterface')));
|
||||
|
||||
$this->assertEquals(1, count($filters), 'Countable returns the count');
|
||||
}
|
||||
}
|
59
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/GoogleClosure/CompilerApiFilterTest.php
vendored
Normal file
59
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/GoogleClosure/CompilerApiFilterTest.php
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
<?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\Filter\GoogleClosure;
|
||||
|
||||
use Assetic\Asset\StringAsset;
|
||||
use Assetic\Filter\GoogleClosure\CompilerApiFilter;
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
*/
|
||||
class CompilerApiFilterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testRoundTrip()
|
||||
{
|
||||
$input = <<<EOF
|
||||
(function() {
|
||||
function unused(){}
|
||||
function foo(bar) {
|
||||
var foo = 'foo';
|
||||
return foo + bar;
|
||||
}
|
||||
alert(foo("bar"));
|
||||
})();
|
||||
EOF;
|
||||
|
||||
$expected = <<<EOF
|
||||
(function() {
|
||||
alert("foobar")
|
||||
})();
|
||||
|
||||
EOF;
|
||||
|
||||
$asset = new StringAsset($input);
|
||||
$asset->load();
|
||||
|
||||
$filter = new CompilerApiFilter();
|
||||
$filter->setCompilationLevel(CompilerApiFilter::COMPILE_SIMPLE_OPTIMIZATIONS);
|
||||
$filter->setJsExterns('');
|
||||
$filter->setExternsUrl('');
|
||||
$filter->setExcludeDefaultExterns(true);
|
||||
$filter->setFormatting(CompilerApiFilter::FORMAT_PRETTY_PRINT);
|
||||
$filter->setUseClosureLibrary(false);
|
||||
$filter->setWarningLevel(CompilerApiFilter::LEVEL_VERBOSE);
|
||||
|
||||
$filter->filterLoad($asset);
|
||||
$filter->filterDump($asset);
|
||||
|
||||
$this->assertEquals($expected, $asset->getContent());
|
||||
}
|
||||
}
|
53
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/GoogleClosure/CompilerJarFilterTest.php
vendored
Normal file
53
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/GoogleClosure/CompilerJarFilterTest.php
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
<?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\Filter\GoogleClosure;
|
||||
|
||||
use Assetic\Asset\StringAsset;
|
||||
use Assetic\Filter\GoogleClosure\CompilerJarFilter;
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
*/
|
||||
class CompilerJarFilterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testCompile()
|
||||
{
|
||||
if (!isset($_SERVER['CLOSURE_JAR'])) {
|
||||
$this->markTestSkipped('There is no CLOSURE_JAR environment variable.');
|
||||
}
|
||||
|
||||
$input = <<<EOF
|
||||
(function() {
|
||||
function unused(){}
|
||||
function foo(bar) {
|
||||
var foo = 'foo';
|
||||
return foo + bar;
|
||||
}
|
||||
alert(foo("bar"));
|
||||
})();
|
||||
EOF;
|
||||
|
||||
$expected = <<<EOF
|
||||
(function(){alert("foobar")})();
|
||||
|
||||
EOF;
|
||||
|
||||
$asset = new StringAsset($input);
|
||||
$asset->load();
|
||||
|
||||
$filter = new CompilerJarFilter($_SERVER['CLOSURE_JAR']);
|
||||
$filter->filterLoad($asset);
|
||||
$filter->filterDump($asset);
|
||||
|
||||
$this->assertEquals($expected, $asset->getContent());
|
||||
}
|
||||
}
|
45
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/GssFilterTest.php
vendored
Normal file
45
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/GssFilterTest.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?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\Filter\GoogleClosure;
|
||||
|
||||
use Assetic\Asset\StringAsset;
|
||||
use Assetic\Filter\GssFilter;
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
*/
|
||||
class GssFilterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testCompile()
|
||||
{
|
||||
if (!isset($_SERVER['GSS_JAR'])) {
|
||||
$this->markTestSkipped('There is no GSS_JAR environment variable.');
|
||||
}
|
||||
|
||||
$input = <<<EOF
|
||||
@def BG_COLOR rgb(235, 239, 249);
|
||||
body {background-color: BG_COLOR;}
|
||||
EOF;
|
||||
|
||||
$expected = <<<EOF
|
||||
body{background-color:#ebeff9}
|
||||
EOF;
|
||||
|
||||
$asset = new StringAsset($input);
|
||||
$asset->load();
|
||||
|
||||
$filter = new GssFilter($_SERVER['GSS_JAR']);
|
||||
$filter->filterLoad($asset);
|
||||
|
||||
$this->assertEquals($expected, $asset->getContent());
|
||||
}
|
||||
}
|
39
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/JSMinFilterTest.php
vendored
Normal file
39
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/JSMinFilterTest.php
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
<?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\Filter;
|
||||
|
||||
use Assetic\Asset\FileAsset;
|
||||
use Assetic\Filter\JSMinFilter;
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
*/
|
||||
class JSMinFilterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
if (!class_exists('JSMin')) {
|
||||
$this->markTestSkipped('JSMin is not installed.');
|
||||
}
|
||||
}
|
||||
|
||||
public function testRelativeSourceUrlImportImports()
|
||||
{
|
||||
$asset = new FileAsset(__DIR__.'/fixtures/jsmin/js.js');
|
||||
$asset->load();
|
||||
|
||||
$filter = new JSMinFilter();
|
||||
$filter->filterDump($asset);
|
||||
|
||||
$this->assertEquals('var a="abc";;;var bbb="u";', $asset->getContent());
|
||||
}
|
||||
}
|
39
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/JSMinPlusFilterTest.php
vendored
Normal file
39
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/JSMinPlusFilterTest.php
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
<?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\Filter;
|
||||
|
||||
use Assetic\Asset\FileAsset;
|
||||
use Assetic\Filter\JSMinPlusFilter;
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
*/
|
||||
class JSMinPlusFilterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
if (!class_exists('JSMinPlus')) {
|
||||
$this->markTestSkipped('JSMinPlus is not installed.');
|
||||
}
|
||||
}
|
||||
|
||||
public function testRelativeSourceUrlImportImports()
|
||||
{
|
||||
$asset = new FileAsset(__DIR__.'/fixtures/jsmin/js.js');
|
||||
$asset->load();
|
||||
|
||||
$filter = new JSMinPlusFilter();
|
||||
$filter->filterDump($asset);
|
||||
|
||||
$this->assertEquals('var a="abc",bbb="u"', $asset->getContent());
|
||||
}
|
||||
}
|
45
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/JpegoptimFilterTest.php
vendored
Normal file
45
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/JpegoptimFilterTest.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?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\Filter;
|
||||
|
||||
use Assetic\Asset\FileAsset;
|
||||
use Assetic\Filter\JpegoptimFilter;
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
*/
|
||||
class JpegoptimFilterTest extends BaseImageFilterTest
|
||||
{
|
||||
private $filter;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
if (!isset($_SERVER['JPEGOPTIM_BIN'])) {
|
||||
$this->markTestSkipped('No jpegoptim configuration.');
|
||||
}
|
||||
|
||||
$this->filter = new JpegoptimFilter($_SERVER['JPEGOPTIM_BIN']);
|
||||
}
|
||||
|
||||
public function testFilter()
|
||||
{
|
||||
$asset = new FileAsset(__DIR__.'/fixtures/home.jpg');
|
||||
$asset->load();
|
||||
|
||||
$before = $asset->getContent();
|
||||
$this->filter->filterDump($asset);
|
||||
|
||||
$this->assertNotEmpty($asset->getContent(), '->filterLoad() sets content');
|
||||
$this->assertNotEquals($before, $asset->getContent(), '->filterDump() changes the content');
|
||||
$this->assertMimeType('image/jpeg', $asset->getContent(), '->filterDump() creates JPEG data');
|
||||
}
|
||||
}
|
45
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/JpegtranFilterTest.php
vendored
Normal file
45
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/JpegtranFilterTest.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?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\Filter;
|
||||
|
||||
use Assetic\Asset\FileAsset;
|
||||
use Assetic\Filter\JpegtranFilter;
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
*/
|
||||
class JpegtranFilterTest extends BaseImageFilterTest
|
||||
{
|
||||
private $filter;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
if (!isset($_SERVER['JPEGTRAN_BIN'])) {
|
||||
$this->markTestSkipped('No jpegtran configuration.');
|
||||
}
|
||||
|
||||
$this->filter = new JpegtranFilter($_SERVER['JPEGTRAN_BIN']);
|
||||
}
|
||||
|
||||
public function testFilter()
|
||||
{
|
||||
$asset = new FileAsset(__DIR__.'/fixtures/home.jpg');
|
||||
$asset->load();
|
||||
|
||||
$before = $asset->getContent();
|
||||
$this->filter->filterDump($asset);
|
||||
|
||||
$this->assertNotEmpty($asset->getContent(), '->filterLoad() sets content');
|
||||
$this->assertNotEquals($before, $asset->getContent(), '->filterDump() changes the content');
|
||||
$this->assertMimeType('image/jpeg', $asset->getContent(), '->filterDump() creates JPEG data');
|
||||
}
|
||||
}
|
63
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/LessFilterTest.php
vendored
Normal file
63
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/LessFilterTest.php
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
<?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\Filter;
|
||||
|
||||
use Assetic\Asset\FileAsset;
|
||||
use Assetic\Asset\StringAsset;
|
||||
use Assetic\Filter\LessFilter;
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
*/
|
||||
class LessFilterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $filter;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
if (!isset($_SERVER['NODE_BIN']) || !isset($_SERVER['NODE_PATH'])) {
|
||||
$this->markTestSkipped('No node.js configuration.');
|
||||
}
|
||||
|
||||
$this->filter = new LessFilter($_SERVER['NODE_BIN'], array($_SERVER['NODE_PATH']));
|
||||
}
|
||||
|
||||
public function testFilterLoad()
|
||||
{
|
||||
$asset = new StringAsset('.foo{.bar{width:1+1;}}');
|
||||
$asset->load();
|
||||
|
||||
$this->filter->filterLoad($asset);
|
||||
|
||||
$this->assertEquals(".foo .bar {\n width: 2;\n}\n", $asset->getContent(), '->filterLoad() parses the content');
|
||||
}
|
||||
|
||||
public function testImport()
|
||||
{
|
||||
$expected = <<<EOF
|
||||
.foo {
|
||||
color: blue;
|
||||
}
|
||||
.foo {
|
||||
color: red;
|
||||
}
|
||||
|
||||
EOF;
|
||||
|
||||
$asset = new FileAsset(__DIR__.'/fixtures/less/main.less');
|
||||
$asset->load();
|
||||
|
||||
$this->filter->filterLoad($asset);
|
||||
|
||||
$this->assertEquals($expected, $asset->getContent(), '->filterLoad() sets an include path based on source url');
|
||||
}
|
||||
}
|
67
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/LessphpFilterTest.php
vendored
Normal file
67
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/LessphpFilterTest.php
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
<?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\Filter;
|
||||
|
||||
use Assetic\Asset\FileAsset;
|
||||
use Assetic\Asset\StringAsset;
|
||||
use Assetic\Filter\LessphpFilter;
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
*/
|
||||
class LessphpFilterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
$this->filter = new LessphpFilter();
|
||||
}
|
||||
|
||||
public function testFilterLoad()
|
||||
{
|
||||
$asset = new StringAsset('.foo{.bar{width:1+ 1;}}');
|
||||
$asset->load();
|
||||
|
||||
$this->filter->filterLoad($asset);
|
||||
|
||||
$this->assertEquals(".foo .bar { width:2; }\n", $asset->getContent(), '->filterLoad() parses the content');
|
||||
}
|
||||
|
||||
public function testImport()
|
||||
{
|
||||
$expected = <<<EOF
|
||||
.foo { color:blue; }
|
||||
.foo { color:red; }
|
||||
|
||||
EOF;
|
||||
|
||||
$asset = new FileAsset(__DIR__.'/fixtures/less/main.less');
|
||||
$asset->load();
|
||||
|
||||
$this->filter->filterLoad($asset);
|
||||
|
||||
$this->assertEquals($expected, $asset->getContent(), '->filterLoad() sets an include path based on source url');
|
||||
}
|
||||
|
||||
public function testPresets()
|
||||
{
|
||||
$asset = new StringAsset('.foo { color: @bar }');
|
||||
$asset->load();
|
||||
|
||||
$this->filter->setPresets(array(
|
||||
'bar' => 'green'
|
||||
));
|
||||
|
||||
$this->filter->filterLoad($asset);
|
||||
|
||||
$this->assertEquals(".foo { color:green; }\n", $asset->getContent(), '->setPresets() to pass variables into lessphp filter');
|
||||
}
|
||||
}
|
56
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/OptiPngFilterTest.php
vendored
Normal file
56
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/OptiPngFilterTest.php
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
<?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\Filter;
|
||||
|
||||
use Assetic\Asset\FileAsset;
|
||||
use Assetic\Filter\OptiPngFilter;
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
*/
|
||||
class OptiPngFilterTest extends BaseImageFilterTest
|
||||
{
|
||||
private $filter;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
if (!isset($_SERVER['OPTIPNG_BIN'])) {
|
||||
$this->markTestSkipped('No OptiPNG configuration.');
|
||||
}
|
||||
|
||||
$this->filter = new OptiPngFilter($_SERVER['OPTIPNG_BIN']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getImages
|
||||
*/
|
||||
public function testFilter($image)
|
||||
{
|
||||
$asset = new FileAsset($image);
|
||||
$asset->load();
|
||||
|
||||
$before = $asset->getContent();
|
||||
$this->filter->filterDump($asset);
|
||||
|
||||
$this->assertNotEmpty($asset->getContent(), '->filterDump() sets content');
|
||||
$this->assertNotEquals($before, $asset->getContent(), '->filterDump() changes the content');
|
||||
$this->assertMimeType('image/png', $asset->getContent(), '->filterDump() creates PNG data');
|
||||
}
|
||||
|
||||
public function getImages()
|
||||
{
|
||||
return array(
|
||||
array(__DIR__.'/fixtures/home.gif'),
|
||||
array(__DIR__.'/fixtures/home.png'),
|
||||
);
|
||||
}
|
||||
}
|
69
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/PackagerFilterTest.php
vendored
Normal file
69
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/PackagerFilterTest.php
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
<?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\Filter;
|
||||
|
||||
use Assetic\Asset\FileAsset;
|
||||
use Assetic\Filter\PackagerFilter;
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
*/
|
||||
class PackagerFilterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
if (!class_exists('Packager', false)) {
|
||||
$this->markTestSkipped('Packager is not available.');
|
||||
}
|
||||
}
|
||||
|
||||
public function testPackager()
|
||||
{
|
||||
$expected = <<<EOF
|
||||
/*
|
||||
---
|
||||
|
||||
name: Util
|
||||
|
||||
provides: [Util]
|
||||
|
||||
...
|
||||
*/
|
||||
|
||||
function foo() {}
|
||||
|
||||
|
||||
/*
|
||||
---
|
||||
|
||||
name: App
|
||||
|
||||
requires: [Util/Util]
|
||||
|
||||
...
|
||||
*/
|
||||
|
||||
var bar = foo();
|
||||
|
||||
|
||||
EOF;
|
||||
|
||||
$asset = new FileAsset(__DIR__.'/fixtures/packager/app/application.js', array(), __DIR__.'/fixtures/packager/app', 'application.js');
|
||||
$asset->load();
|
||||
|
||||
$filter = new PackagerFilter();
|
||||
$filter->addPackage(__DIR__.'/fixtures/packager/lib');
|
||||
$filter->filterLoad($asset);
|
||||
|
||||
$this->assertEquals($expected, $asset->getContent(), '->filterLoad() runs packager');
|
||||
}
|
||||
}
|
36
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/PackerFilterTest.php
vendored
Normal file
36
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/PackerFilterTest.php
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Assetic package, an OpenSky project.
|
||||
*
|
||||
* (c) 2010-2011 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\Filter;
|
||||
|
||||
use Assetic\Asset\FileAsset;
|
||||
use Assetic\Filter\PackerFilter;
|
||||
|
||||
class PackerFilterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
if (!class_exists('JavaScriptPacker')) {
|
||||
$this->markTestSkipped('JavaScriptPacker is not installed.');
|
||||
}
|
||||
}
|
||||
|
||||
public function testPacker()
|
||||
{
|
||||
$asset = new FileAsset(__DIR__.'/fixtures/packer/example.js');
|
||||
$asset->load();
|
||||
|
||||
$filter = new PackerFilter();
|
||||
$filter->filterDump($asset);
|
||||
|
||||
$this->assertEquals("var exampleFunction=function(arg1,arg2){alert('exampleFunction called!')}", $asset->getContent());
|
||||
}
|
||||
}
|
57
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/PngoutFilterTest.php
vendored
Normal file
57
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/PngoutFilterTest.php
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
<?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\Filter;
|
||||
|
||||
use Assetic\Asset\FileAsset;
|
||||
use Assetic\Filter\PngoutFilter;
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
*/
|
||||
class PngoutFilterTest extends BaseImageFilterTest
|
||||
{
|
||||
private $filter;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
if (!isset($_SERVER['PNGOUT_BIN'])) {
|
||||
$this->markTestSkipped('No pngout configuration.');
|
||||
}
|
||||
|
||||
$this->filter = new PngoutFilter($_SERVER['PNGOUT_BIN']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getImages
|
||||
*/
|
||||
public function testFilter($image)
|
||||
{
|
||||
$asset = new FileAsset($image);
|
||||
$asset->load();
|
||||
|
||||
$before = $asset->getContent();
|
||||
$this->filter->filterDump($asset);
|
||||
|
||||
$this->assertNotEmpty($asset->getContent(), '->filterLoad() sets content');
|
||||
$this->assertNotEquals($before, $asset->getContent(), '->filterLoad() changes the content');
|
||||
$this->assertMimeType('image/png', $asset->getContent(), '->filterLoad() creates PNG data');
|
||||
}
|
||||
|
||||
public function getImages()
|
||||
{
|
||||
return array(
|
||||
array(__DIR__.'/fixtures/home.gif'),
|
||||
array(__DIR__.'/fixtures/home.jpg'),
|
||||
array(__DIR__.'/fixtures/home.png'),
|
||||
);
|
||||
}
|
||||
}
|
70
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/Sass/SassFilterTest.php
vendored
Normal file
70
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/Sass/SassFilterTest.php
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
<?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\Filter\Sass;
|
||||
|
||||
use Assetic\Asset\StringAsset;
|
||||
use Assetic\Filter\Sass\SassFilter;
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
*/
|
||||
class SassFilterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $filter;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
if (!isset($_SERVER['SASS_BIN'])) {
|
||||
$this->markTestSkipped('There is no SASS_BIN environment variable.');
|
||||
}
|
||||
|
||||
$this->filter = new SassFilter($_SERVER['SASS_BIN']);
|
||||
}
|
||||
|
||||
public function testSass()
|
||||
{
|
||||
$input = <<<EOF
|
||||
body
|
||||
color: #F00
|
||||
EOF;
|
||||
|
||||
$asset = new StringAsset($input);
|
||||
$asset->load();
|
||||
|
||||
$this->filter->setStyle(SassFilter::STYLE_COMPACT);
|
||||
$this->filter->filterLoad($asset);
|
||||
|
||||
$this->assertEquals("body { color: red; }\n", $asset->getContent(), '->filterLoad() parses the sass');
|
||||
}
|
||||
|
||||
public function testScssGuess()
|
||||
{
|
||||
$input = <<<'EOF'
|
||||
$red: #F00;
|
||||
|
||||
.foo {
|
||||
color: $red;
|
||||
}
|
||||
|
||||
EOF;
|
||||
|
||||
$expected = '.foo { color: red; }';
|
||||
|
||||
$asset = new StringAsset($input, array(), null, 'foo.scss');
|
||||
$asset->load();
|
||||
|
||||
$this->filter->setStyle(SassFilter::STYLE_COMPACT);
|
||||
$this->filter->filterLoad($asset);
|
||||
|
||||
$this->assertEquals(".foo { color: red; }\n", $asset->getContent(), '->filterLoad() detects SCSS based on source path extension');
|
||||
}
|
||||
}
|
44
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/Sass/ScssFilterTest.php
vendored
Normal file
44
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/Sass/ScssFilterTest.php
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
<?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\Filter\Sass;
|
||||
|
||||
use Assetic\Asset\FileAsset;
|
||||
use Assetic\Filter\Sass\ScssFilter;
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
*/
|
||||
class ScssFilterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testImport()
|
||||
{
|
||||
if (!isset($_SERVER['SASS_BIN'])) {
|
||||
$this->markTestSkipped('There is no SASS_BIN environment variable.');
|
||||
}
|
||||
|
||||
$asset = new FileAsset(__DIR__.'/../fixtures/sass/main.scss');
|
||||
$asset->load();
|
||||
|
||||
$filter = new ScssFilter($_SERVER['SASS_BIN']);
|
||||
$filter->setStyle(ScssFilter::STYLE_COMPACT);
|
||||
$filter->filterLoad($asset);
|
||||
|
||||
$expected = <<<EOF
|
||||
.foo { color: blue; }
|
||||
|
||||
.foo { color: red; }
|
||||
|
||||
EOF;
|
||||
|
||||
$this->assertEquals($expected, $asset->getContent(), '->filterLoad() loads imports');
|
||||
}
|
||||
}
|
69
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/SprocketsFilterTest.php
vendored
Normal file
69
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/SprocketsFilterTest.php
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
<?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\Filter;
|
||||
|
||||
use Assetic\Asset\FileAsset;
|
||||
use Assetic\Filter\SprocketsFilter;
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
*/
|
||||
class SprocketsFilterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $assetRoot;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
if (!isset($_SERVER['SPROCKETS_LIB']) || !isset($_SERVER['RUBY_BIN'])) {
|
||||
$this->markTestSkipped('There is no sprockets configuration.');
|
||||
}
|
||||
|
||||
$this->assetRoot = sys_get_temp_dir().'/assetic_sprockets';
|
||||
if (is_dir($this->assetRoot)) {
|
||||
$this->cleanup();
|
||||
} else {
|
||||
mkdir($this->assetRoot);
|
||||
}
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
$this->cleanup();
|
||||
}
|
||||
|
||||
private function cleanup()
|
||||
{
|
||||
$it = new \RecursiveDirectoryIterator($this->assetRoot);
|
||||
foreach (new \RecursiveIteratorIterator($it) as $path => $file) {
|
||||
if (is_file($path)) {
|
||||
unlink($path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function testFilterLoad()
|
||||
{
|
||||
$asset = new FileAsset(__DIR__.'/fixtures/sprockets/main.js');
|
||||
$asset->load();
|
||||
|
||||
$filter = new SprocketsFilter($_SERVER['SPROCKETS_LIB'], $_SERVER['RUBY_BIN']);
|
||||
$filter->addIncludeDir(__DIR__.'/fixtures/sprockets/lib1');
|
||||
$filter->addIncludeDir(__DIR__.'/fixtures/sprockets/lib2');
|
||||
$filter->setAssetRoot($this->assetRoot);
|
||||
$filter->filterLoad($asset);
|
||||
|
||||
$this->assertContains('/* header.js */', $asset->getContent());
|
||||
$this->assertContains('/* include.js */', $asset->getContent());
|
||||
$this->assertContains('/* footer.js */', $asset->getContent());
|
||||
$this->assertFileExists($this->assetRoot.'/images/image.gif');
|
||||
}
|
||||
}
|
53
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/StylusFilterTest.php
vendored
Normal file
53
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/StylusFilterTest.php
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
<?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\Filter;
|
||||
|
||||
use Assetic\Asset\StringAsset;
|
||||
use Assetic\Filter\StylusFilter;
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
*/
|
||||
class StylusFilterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $filter;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
if (!isset($_SERVER['NODE_BIN']) || !isset($_SERVER['NODE_PATH'])) {
|
||||
$this->markTestSkipped('No node.js configuration.');
|
||||
}
|
||||
|
||||
$this->filter = new StylusFilter($_SERVER['NODE_BIN'], array($_SERVER['NODE_PATH']));
|
||||
}
|
||||
|
||||
public function testFilterLoad()
|
||||
{
|
||||
$asset = new StringAsset("body\n font 12px Helvetica, Arial, sans-serif\n color black");
|
||||
$asset->load();
|
||||
|
||||
$this->filter->filterLoad($asset);
|
||||
|
||||
$this->assertEquals("body {\n font: 12px Helvetica, Arial, sans-serif;\n color: #000;\n}\n", $asset->getContent(), '->filterLoad() parses the content');
|
||||
}
|
||||
|
||||
public function testFilterLoadWithCompression()
|
||||
{
|
||||
$asset = new StringAsset("body\n font 12px Helvetica, Arial, sans-serif\n color black;");
|
||||
$asset->load();
|
||||
|
||||
$this->filter->setCompress(true);
|
||||
$this->filter->filterLoad($asset);
|
||||
|
||||
$this->assertEquals("body{font:12px Helvetica,Arial,sans-serif;color:#000}\n", $asset->getContent(), '->filterLoad() parses the content and compress it');
|
||||
}
|
||||
}
|
100
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/UglifyJsFilterTest.php
vendored
Normal file
100
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/UglifyJsFilterTest.php
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
<?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\Filter;
|
||||
|
||||
use Assetic\Asset\FileAsset;
|
||||
use Assetic\Filter\UglifyJsFilter;
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
*/
|
||||
class UglifyJsFilterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $asset;
|
||||
private $filter;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
if (!isset($_SERVER['UGLIFYJS_BIN'])) {
|
||||
$this->markTestSkipped('There is no uglifyJs configuration.');
|
||||
}
|
||||
|
||||
$this->asset = new FileAsset(__DIR__.'/fixtures/uglifyjs/script.js');
|
||||
$this->asset->load();
|
||||
|
||||
if (isset($_SERVER['NODE_BIN'])) {
|
||||
$this->filter = new UglifyJsFilter($_SERVER['UGLIFYJS_BIN'], $_SERVER['NODE_BIN']);
|
||||
} else {
|
||||
$this->filter = new UglifyJsFilter($_SERVER['UGLIFYJS_BIN']);
|
||||
}
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
$this->asset = null;
|
||||
$this->filter = null;
|
||||
}
|
||||
|
||||
public function testUglify()
|
||||
{
|
||||
$this->filter->filterDump($this->asset);
|
||||
|
||||
$expected = <<<JS
|
||||
/**
|
||||
* Copyright
|
||||
*/function bar(a){return var2.push(a),a}var foo=new Array(1,2,3,4),bar=Array(a,b,c),var1=new Array(5),var2=new Array(a),foo=function(a){return a};
|
||||
JS;
|
||||
$this->assertSame($expected, $this->asset->getContent());
|
||||
}
|
||||
|
||||
public function testUnsafeUglify()
|
||||
{
|
||||
$this->filter->setUnsafe(true);
|
||||
$this->filter->filterDump($this->asset);
|
||||
|
||||
$expected = <<<JS
|
||||
/**
|
||||
* Copyright
|
||||
*/function bar(a){return var2.push(a),a}var foo=[1,2,3,4],bar=[a,b,c],var1=Array(5),var2=Array(a),foo=function(a){return a};
|
||||
JS;
|
||||
$this->assertSame($expected, $this->asset->getContent());
|
||||
}
|
||||
|
||||
public function testBeautifyUglify()
|
||||
{
|
||||
$this->filter->setBeautify(true);
|
||||
$this->filter->filterDump($this->asset);
|
||||
|
||||
$expected = <<<JS
|
||||
/**
|
||||
* Copyright
|
||||
*/function bar(a) {
|
||||
return var2.push(a), a;
|
||||
}
|
||||
|
||||
var foo = new Array(1, 2, 3, 4), bar = Array(a, b, c), var1 = new Array(5), var2 = new Array(a), foo = function(a) {
|
||||
return a;
|
||||
};
|
||||
JS;
|
||||
|
||||
$this->assertSame($expected, $this->asset->getContent());
|
||||
}
|
||||
|
||||
public function testNoCopyrightUglify()
|
||||
{
|
||||
$this->filter->setNoCopyright(true);
|
||||
$this->filter->filterDump($this->asset);
|
||||
|
||||
$expected = 'function bar(a){return var2.push(a),a}var foo=new Array(1,2,3,4),bar=Array(a,b,c),var1=new Array(5),var2=new Array(a),foo=function(a){return a};';
|
||||
$this->assertSame($expected, $this->asset->getContent());
|
||||
}
|
||||
}
|
31
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/Yui/BaseCompressorFilterTest.php
vendored
Normal file
31
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/Yui/BaseCompressorFilterTest.php
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
<?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\Filter\Yui;
|
||||
|
||||
use Assetic\Asset\AssetInterface;
|
||||
use Assetic\Filter\Yui\BaseCompressorFilter;
|
||||
|
||||
class BaseCompressorFilterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testInterface()
|
||||
{
|
||||
$filter = new YuiCompressorFilterForTest('/path/to/jar');
|
||||
$this->assertInstanceOf('Assetic\\Filter\\FilterInterface', $filter, 'BaseCompressorFilter implements FilterInterface');
|
||||
}
|
||||
}
|
||||
|
||||
class YuiCompressorFilterForTest extends BaseCompressorFilter
|
||||
{
|
||||
public function filterDump(AssetInterface $asset)
|
||||
{
|
||||
}
|
||||
}
|
23
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/Yui/CssCompressorFilterTest.php
vendored
Normal file
23
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/Yui/CssCompressorFilterTest.php
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<?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\Filter\Yui;
|
||||
|
||||
use Assetic\Filter\Yui\CssCompressorFilter;
|
||||
|
||||
class CssCompressorFilterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testInterface()
|
||||
{
|
||||
$filter = new CssCompressorFilter('/path/to/jar');
|
||||
$this->assertInstanceOf('Assetic\\Filter\\FilterInterface', $filter, 'CssCompressorFilter implements FilterInterface');
|
||||
}
|
||||
}
|
62
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/Yui/JsCompressorFilterTest.php
vendored
Normal file
62
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/Yui/JsCompressorFilterTest.php
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
<?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\Filter\Yui;
|
||||
|
||||
use Assetic\Asset\StringAsset;
|
||||
use Assetic\Filter\Yui\JsCompressorFilter;
|
||||
|
||||
class JsCompressorFilterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testInterface()
|
||||
{
|
||||
$filter = new JsCompressorFilter('/path/to/jar');
|
||||
$this->assertInstanceOf('Assetic\\Filter\\FilterInterface', $filter, 'JsCompressorFilter implements FilterInterface');
|
||||
}
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
*/
|
||||
public function testFilterDump()
|
||||
{
|
||||
if (!isset($_SERVER['YUI_COMPRESSOR_JAR'])) {
|
||||
$this->markTestSkipped('There is no YUI_COMPRESSOR_JAR environment variable.');
|
||||
}
|
||||
|
||||
$source = <<<JAVASCRIPT
|
||||
(function() {
|
||||
|
||||
var asdf = 'asdf';
|
||||
var qwer = 'qwer';
|
||||
|
||||
if (asdf.indexOf(qwer)) {
|
||||
alert("That's not possible!");
|
||||
} else {
|
||||
alert("Boom.");
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
JAVASCRIPT;
|
||||
|
||||
$expected = <<<JAVASCRIPT
|
||||
(function(){var a="asdf";var b="qwer";if(a.indexOf(b)){alert("That's not possible!")}else{alert("Boom.")}})();
|
||||
JAVASCRIPT;
|
||||
|
||||
$asset = new StringAsset($source);
|
||||
$asset->load();
|
||||
|
||||
$filter = new JsCompressorFilter($_SERVER['YUI_COMPRESSOR_JAR']);
|
||||
$filter->filterDump($asset);
|
||||
|
||||
$this->assertEquals($expected, $asset->getContent(), '->filterDump()');
|
||||
}
|
||||
}
|
4
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/compass/compass.sass
vendored
Normal file
4
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/compass/compass.sass
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
@import "compass/typography/links/hover-link"
|
||||
|
||||
a
|
||||
@include hover-link
|
4
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/compass/partials/_sass.sass
vendored
Normal file
4
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/compass/partials/_sass.sass
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
@import "compass/utilities"
|
||||
|
||||
@mixin mixin-test($fontSize: 1em)
|
||||
font-size: $fontSize
|
6
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/compass/partials/_scss.scss
vendored
Normal file
6
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/compass/partials/_scss.scss
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
@import "compass/utilities";
|
||||
|
||||
@mixin mixin-test($fontSize: 1em)
|
||||
{
|
||||
font-size: $fontSize;
|
||||
}
|
4
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/compass/stylesheet.sass
vendored
Normal file
4
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/compass/stylesheet.sass
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
@import "partials/sass"
|
||||
|
||||
.test-class
|
||||
@include mixin-test(2em)
|
6
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/compass/stylesheet.scss
vendored
Normal file
6
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/compass/stylesheet.scss
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
@import "partials/scss";
|
||||
|
||||
.test-class
|
||||
{
|
||||
@include mixin-test(2em);
|
||||
}
|
4
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/cssembed/test.css
vendored
Normal file
4
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/cssembed/test.css
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
.test
|
||||
{
|
||||
background: url(../home.png);
|
||||
}
|
2
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/cssimport/import.css
vendored
Normal file
2
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/cssimport/import.css
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/* import.css */
|
||||
body { color: red; }
|
4
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/cssimport/main.css
vendored
Normal file
4
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/cssimport/main.css
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
/* main.css */
|
||||
@import "import.css";
|
||||
@import url('more/evenmore/deep1.css');
|
||||
body { color: black; }
|
1
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/cssimport/more.sass
vendored
Normal file
1
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/cssimport/more.sass
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/* more.sass */
|
@@ -0,0 +1,2 @@
|
||||
/* more/evenmore/deep1.css */
|
||||
@import url(deep2.css);
|
@@ -0,0 +1,4 @@
|
||||
/* more/evenmore/deep2.css */
|
||||
body {
|
||||
background: url(bg.gif);
|
||||
}
|
2
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/cssimport/noncssimport.css
vendored
Normal file
2
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/cssimport/noncssimport.css
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/* noncssimport.css */
|
||||
@import "more.sass";
|
3
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/cssmin/fonts.css
vendored
Normal file
3
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/cssmin/fonts.css
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
body {
|
||||
color: white;
|
||||
}
|
5
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/cssmin/main.css
vendored
Normal file
5
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/cssmin/main.css
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
@import url("fonts.css");
|
||||
|
||||
body {
|
||||
background: black;
|
||||
}
|
BIN
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/home.gif
vendored
Normal file
BIN
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/home.gif
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 61 B |
BIN
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/home.jpg
vendored
Normal file
BIN
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/home.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 431 B |
BIN
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/home.png
vendored
Normal file
BIN
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/home.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 184 B |
7
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/jsmin/js.js
vendored
Normal file
7
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/jsmin/js.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
var a = "abc";
|
||||
|
||||
// fsfafwe
|
||||
|
||||
;;
|
||||
var bbb = "u";
|
||||
|
1
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/less/_include.less
vendored
Normal file
1
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/less/_include.less
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.foo { color: blue; }
|
3
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/less/main.less
vendored
Normal file
3
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/less/main.less
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
@import "_include";
|
||||
|
||||
.foo { color: red; }
|
11
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/packager/app/application.js
vendored
Normal file
11
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/packager/app/application.js
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
---
|
||||
|
||||
name: App
|
||||
|
||||
requires: [Util/Util]
|
||||
|
||||
...
|
||||
*/
|
||||
|
||||
var bar = foo();
|
4
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/packager/lib/package.yml
vendored
Normal file
4
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/packager/lib/package.yml
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
name: "Util"
|
||||
|
||||
sources:
|
||||
- "util.js"
|
11
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/packager/lib/util.js
vendored
Normal file
11
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/packager/lib/util.js
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
---
|
||||
|
||||
name: Util
|
||||
|
||||
provides: [Util]
|
||||
|
||||
...
|
||||
*/
|
||||
|
||||
function foo() {}
|
7
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/packer/example.js
vendored
Normal file
7
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/packer/example.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* Example function
|
||||
*/
|
||||
var exampleFunction = function(arg1, arg2) {
|
||||
// Some comment...
|
||||
alert('exampleFunction called!');
|
||||
}
|
1
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/sass/_include.scss
vendored
Normal file
1
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/sass/_include.scss
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.foo { color: blue; }
|
3
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/sass/main.scss
vendored
Normal file
3
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/sass/main.scss
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
@import "_include";
|
||||
|
||||
.foo { color: red; }
|
1
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/sprockets/include.js
vendored
Normal file
1
vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/fixtures/sprockets/include.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/* include.js */
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user