本文整理汇总了PHP中Assetic\Asset\StringAsset类的典型用法代码示例。如果您正苦于以下问题:PHP StringAsset类的具体用法?PHP StringAsset怎么用?PHP StringAsset使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StringAsset类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFilterLoad
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');
}
示例2: testCompile
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());
}
示例3: testFilterDump
/**
* @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: testRoundTrip
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());
}
示例5: testPreserveCommentsFalse
public function testPreserveCommentsFalse()
{
$asset = new StringAsset("/* Line 1 */\n.foo { color: green }");
$asset->load();
$this->filter->setPreserveComments(false);
$this->filter->filterLoad($asset);
$this->assertNotContains('/* Line 1 */', $asset->getContent(), '->setPreserveComments(false)');
}
示例6: testFilterLoadWithUseNib
public function testFilterLoadWithUseNib()
{
$asset = new StringAsset("@import 'nib'\nbody\n whitespace nowrap\n font 12px Helvetica, Arial, sans-serif\n color black");
$asset->load();
$this->filter->setUseNib(true);
$this->filter->filterLoad($asset);
$this->assertEquals("body {\n white-space: nowrap;\n font: 12px Helvetica, Arial, sans-serif;\n color: #000;\n}\n", $asset->getContent(), '->filterLoad() parses the content using the nib extension');
}
示例7: testGetContentNullUnlessLoaded
public function testGetContentNullUnlessLoaded()
{
// see https://github.com/kriswallsmith/assetic/pull/432
$asset = new StringAsset("test");
$this->assertNull($asset->getContent(), '->getContent() returns null unless load() has been called.');
$asset->load();
$this->assertEquals("test", $asset->getContent(), '->getContent() returns the content after load()');
}
示例8: testAppend
public function testAppend()
{
$asset = new StringAsset('foobar');
$asset->load();
$filter = new SeparatorFilter('+');
$filter->filterDump($asset);
$this->assertEquals('foobar+', $asset->getContent());
}
示例9: testFilterLoadWithCompression
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');
}
示例10: testIgnoreNonPuliAssets
public function testIgnoreNonPuliAssets()
{
$asset = new StringAsset('content');
$asset->load();
$this->filter->filterLoad($asset);
$this->filter->filterDump($asset);
// no error
}
示例11: testNoHeader
public function testNoHeader()
{
$asset = new StringAsset('square = (x) -> x * x');
$asset->load();
$this->filter->setNoHeader(true);
$this->filter->filterLoad($asset);
$this->assertNotRegExp('/^\\/\\/ Generated by CoffeeScript/i', $asset->getContent());
}
示例12: testPresets
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');
}
示例13: testEmptyUrl
public function testEmptyUrl()
{
$asset = new StringAsset('body { background: url(); }', array(), 'http://www.example.com', 'css/main.css');
$asset->setTargetPath('css/packed/main.css');
$asset->load();
$filter = new CssRewriteFilter();
$filter->filterDump($asset);
// no error is thrown
}
示例14: testUriRewriteWithSymlinks
public function testUriRewriteWithSymlinks()
{
$filter = new UriRewriteFilter('path/to/public', array('//assets' => strtr('path/to/outside/public/assets', '/', DIRECTORY_SEPARATOR)));
$input = "body { background-image: url('../foo/bar.png'); }";
$asset = new StringAsset($input, array(), 'path/to/outside/public/assets/baz', 'qux.css');
$asset->load();
$filter->filterDump($asset);
$this->assertEquals("body { background-image: url('/assets/foo/bar.png'); }", $asset->getContent());
}
示例15: testNoTargetPath
public function testNoTargetPath()
{
$content = 'body{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');
}