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 testCompassMixin() { $asset = new FileAsset(__DIR__ . '/fixtures/compass/compass.sass'); $asset->load(); $this->filter->filterLoad($asset); $this->assertContains('text-decoration', $asset->getContent()); }
public function testCompassExtensionCanBeDisabled() { $this->setExpectedException("Exception", "Undefined mixin box-shadow: failed at `@include box-shadow(10px " . "10px 8px red);` line: 4"); $asset = new FileAsset(__DIR__ . '/fixtures/sass/main_compass.scss'); $asset->load(); $this->getFilter(false)->filterLoad($asset); }
public function testRelativeSourceUrlImportImports() { $asset = new FileAsset(__DIR__ . '/fixtures/jsmin/js.js'); $asset->load(); $filter = new JSqueezeFilter(); $filter->filterDump($asset); $this->assertEquals(";var a='abc',bbb='u';", $asset->getContent()); }
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()); }
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()); }
public function testRelativeSourceUrlImportImports() { $asset = new FileAsset(__DIR__ . '/fixtures/minifycsscompressor/main.css'); $asset->load(); $filter = new MinifyCssCompressorFilter(); $filter->filterDump($asset); $this->assertEquals('body{color:white}body{background:black}', $asset->getContent()); }
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'); }
public function testFileAsset() { $asset = new FileAsset(__DIR__ . '/fixtures/handlebars/template.handlebars'); $asset->load(); $this->filter->filterLoad($asset); $this->assertNotContains('{{ var }}', $asset->getContent()); $this->assertContains('Ember.TEMPLATES["template"]', $asset->getContent()); $this->assertContains('data.buffer.push("<div id=\\"test\\"><h2>");', $asset->getContent()); }
public function testMinimizeHandlebars() { $asset = new FileAsset(__DIR__ . '/fixtures/handlebars/template.handlebars'); $asset->load(); $this->filter->setMinimize(true); $this->filter->filterLoad($asset); $this->assertNotContains('{{ var }}', $asset->getContent()); $this->assertNotContains("\n", $asset->getContent()); }
public function testCssEmbedMhtml() { $asset = new FileAsset(__DIR__ . '/fixtures/cssembed/test.css'); $asset->load(); $this->filter->setMhtml(true); $this->filter->setMhtmlRoot('/test'); $this->filter->filterDump($asset); $this->assertContains('url(mhtml:/test/!', $asset->getContent()); }
public function testCompilation() { $asset = new FileAsset(__DIR__ . '/stubs/coffeescript/script.coffee'); $asset->load(); $filter = new CoffeeScriptphpFilter(); $filter->filterLoad($asset); $expected = file_get_contents(__DIR__ . '/stubs/coffeescript/script.js'); $this->assertEquals($expected, $asset->getContent()); }
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()); }
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 PhpCssEmbedFilter(); $filter->filterLoad($asset); $this->assertContains('url(data:image/png;base64,' . $data, $asset->getContent()); }
public function testCompilingWithImportPath() { $asset = new FileAsset(__DIR__ . '/stubs/sass/style.sass'); $asset->load(); $filter = new SassphpFilter(); $filter->addImportPath(__DIR__ . '/stubs/sass/import_path'); $filter->filterLoad($asset); $expected = file_get_contents(__DIR__ . '/stubs/sass/style.css'); $this->assertEquals($expected, $asset->getContent()); }
/** * @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 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'); }
protected function setUp() { $uglifyjsBin = $this->findExecutable('uglifyjs', 'UGLIFYJS2_BIN'); $nodeBin = $this->findExecutable('node', 'NODE_BIN'); if (!$uglifyjsBin) { $this->markTestSkipped('Unable to find `uglifyjs` executable.'); } // verify uglifyjs version $pb = new ProcessBuilder($nodeBin ? array($nodeBin, $uglifyjsBin) : array($uglifyjsBin)); $pb->add('--version'); if (isset($_SERVER['NODE_PATH'])) { $pb->setEnv('NODE_PATH', $_SERVER['NODE_PATH']); } if (0 !== $pb->getProcess()->run()) { $this->markTestSkipped('Incorrect version of UglifyJs'); } $this->asset = new FileAsset(__DIR__ . '/fixtures/uglifyjs/script.js'); $this->asset->load(); $this->filter = new UglifyJs2Filter($uglifyjsBin, $nodeBin); }
public function testCompressImport() { $expected = <<<EOF .foo{color:blue}.foo{color:red} EOF; $asset = new FileAsset(__DIR__ . '/fixtures/less/main.less'); $asset->load(); $this->filter->addTreeOption('compress', true); $this->filter->filterLoad($asset); $this->assertEquals($expected, $asset->getContent(), '->filterLoad() sets an include path based on source url'); }
public function testFilterLoad() { $asset = new FileAsset(__DIR__ . '/fixtures/sprockets/main.js'); $asset->load(); $this->filter->addIncludeDir(__DIR__ . '/fixtures/sprockets/lib1'); $this->filter->addIncludeDir(__DIR__ . '/fixtures/sprockets/lib2'); $this->filter->setAssetRoot($this->assetRoot); $this->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'); }
public function testImport() { $asset = new FileAsset(__DIR__ . '/../fixtures/sass/main.scss'); $asset->load(); $this->filter->setStyle(ScssFilter::STYLE_COMPACT); $this->filter->filterLoad($asset); $expected = <<<EOF .foo { color: blue; } .foo { color: red; } EOF; $this->assertEquals($expected, $asset->getContent(), '->filterLoad() loads imports'); }
public function testImport() { $expected = <<<EOF .foo { color: blue; } .foo { color: red; } EOF; $asset = new FileAsset(__DIR__ . '/fixtures/sass/main.scss'); $asset->load(); $this->filter->filterLoad($asset); $this->assertEquals($expected, $asset->getContent(), '->filterLoad() sets an include path based on source url'); }
public function testCompassExtension() { $expected = <<<EOF .shadow { -webkit-box-shadow : 10px 10px 8px red; -moz-box-shadow : 10px 10px 8px red; box-shadow : 10px 10px 8px red; } EOF; $asset = new FileAsset(__DIR__ . '/fixtures/sass/main_compass.scss'); $asset->load(); $this->getFilter(true)->filterLoad($asset); $this->assertEquals($expected, $asset->getContent(), 'compass plugin can be enabled'); $asset = new FileAsset(__DIR__ . '/fixtures/sass/main_compass.scss'); $asset->load(); $this->getFilter(false)->filterLoad($asset); $this->assertEquals("@import \"compass\";\n", $asset->getContent(), 'compass plugin can be disabled'); }
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'); }
/** * @group integration */ public function testFilterLoad() { if (!isset($_SERVER['SPROCKETIZE_BIN'])) { $this->markTestSkipped('There is no SPROCKETIZE_BIN environment variable.'); } $asset = new FileAsset(__DIR__.'/fixtures/sprockets/main.js', array(), 'main.js'); $asset->load(); $filter = new SprocketsFilter(__DIR__.'/fixtures/sprockets', $_SERVER['SPROCKETIZE_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'); }
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'); }
public function getFile($path) { if (strtolower(substr($path, 0, 4)) === 'http') { $f = new HttpAsset($path); $f->load(); } else { $f = new FileAsset($path); $f->load(); } return $f; }