Exemplo n.º 1
0
 public function testLexerTagParsingJs()
 {
     // htpl instance
     $tpl = '
     <w-minify>
         <script src="assets/js/skel.min.js"></script>
         <script src="assets/js/init.js"></script>
     </w-minify>
     ';
     $provider = new \Webiny\Htpl\TemplateProviders\ArrayProvider(['test' => $tpl]);
     $htpl = new \Webiny\Htpl\Htpl($provider);
     $htpl->setOptions(['minify' => ['driver' => 'Webiny\\Htpl\\UnitTests\\Mocks\\WMinifyMock']]);
     $result = $htpl->build('test')->fetch();
     $this->assertSame('<script type="text/javascript" src="/mock/min.js"/>', $result);
     $this->assertSame(['assets/js/skel.min.js', 'assets/js/init.js'], WMinifyMock::$jsFiles);
 }
Exemplo n.º 2
0
    public function testWMinifyAbstract()
    {
        $tpl = '';
        $provider = new \Webiny\Htpl\TemplateProviders\ArrayProvider(['test' => $tpl]);
        $htpl = new \Webiny\Htpl\Htpl($provider);
        // register minify providers
        $minProvider = new \Webiny\Htpl\TemplateProviders\ArrayProvider(['js1.js' => 'var = "foo";

            alert(var);
            ', 'js2.js' => 'var2 = "bar";']);
        $minCache = new \Webiny\Htpl\Cache\ArrayCache();
        $htpl->setOptions(['minify' => ['webRoot' => '/minified/', 'provider' => $minProvider, 'cache' => $minCache]]);
        $minDriver = new \Webiny\Htpl\Functions\WMinify\WMinify($htpl);
        $this->assertInstanceOf('\\Webiny\\Htpl\\Htpl', $minDriver->getHtpl());
        $this->assertInstanceOf('\\Webiny\\Htpl\\TemplateProviders\\TemplateProviderInterface', $minDriver->getProvider());
        $this->assertInstanceOf('\\Webiny\\Htpl\\Cache\\CacheInterface', $minDriver->getCache());
        $this->assertSame('/minified/', $minDriver->getWebRoot());
    }