當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Asset\StringAsset類代碼示例

本文整理匯總了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');
 }
開發者ID:laubosslink,項目名稱:lab,代碼行數:7,代碼來源:LessFilterTest.php

示例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());
    }
開發者ID:laubosslink,項目名稱:lab,代碼行數:26,代碼來源:CompilerJarFilterTest.php

示例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()');
    }
開發者ID:selimcr,項目名稱:servigases,代碼行數:32,代碼來源:JsCompressorFilterTest.php

示例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());
    }
開發者ID:laubosslink,項目名稱:lab,代碼行數:32,代碼來源:CompilerApiFilterTest.php

示例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)');
 }
開發者ID:alexanderTsig,項目名稱:arabic,代碼行數:8,代碼來源:LessphpFilterTest.php

示例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');
 }
開發者ID:kebenxiaoming,項目名稱:owncloudRedis,代碼行數:8,代碼來源:StylusFilterTest.php

示例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()');
 }
開發者ID:selimcr,項目名稱:servigases,代碼行數:8,代碼來源:StringAssetTest.php

示例8: testAppend

 public function testAppend()
 {
     $asset = new StringAsset('foobar');
     $asset->load();
     $filter = new SeparatorFilter('+');
     $filter->filterDump($asset);
     $this->assertEquals('foobar+', $asset->getContent());
 }
開發者ID:selimcr,項目名稱:servigases,代碼行數:8,代碼來源:SeparatorFilterTest.php

示例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');
 }
開發者ID:laubosslink,項目名稱:lab,代碼行數:8,代碼來源:StylusFilterTest.php

示例10: testIgnoreNonPuliAssets

 public function testIgnoreNonPuliAssets()
 {
     $asset = new StringAsset('content');
     $asset->load();
     $this->filter->filterLoad($asset);
     $this->filter->filterDump($asset);
     // no error
 }
開發者ID:puli,項目名稱:assetic-extension,代碼行數:8,代碼來源:PuliCssRewriteFilterTest.php

示例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());
 }
開發者ID:selimcr,項目名稱:servigases,代碼行數:8,代碼來源:CoffeeScriptFilterTest.php

示例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');
 }
開發者ID:laubosslink,項目名稱:lab,代碼行數:8,代碼來源:LessphpFilterTest.php

示例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
 }
開發者ID:alexanderTsig,項目名稱:arabic,代碼行數:9,代碼來源:CssRewriteFilterTest.php

示例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());
 }
開發者ID:daveearley,項目名稱:basset,代碼行數:9,代碼來源:UriRewriteFilterTest.php

示例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');
 }
開發者ID:laiello,項目名稱:mediathequescrum,代碼行數:9,代碼來源:CssRewriteFilterTest.php


注:本文中的Assetic\Asset\StringAsset類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。