public function testSingle() { $phtml = <<<'PHTML' <div class="container"> <div class="row"> <div class="col-md-6 col-sm-3"> <p> Some content </p> </div> <div class="col-md-6 col-sm-3"> <p> Some content </p> </div> <div class="col-md-6 col-sm-3"> <p> Some content </p> </div> </div> </div> PHTML; $this->assertEquals(str_replace("\r", '', $phtml), $this->renderer->compileFile('single')); }
public function testIssue44() { $jade = <<<JADE - \t\t/** \t\t* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) \t\t* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) \t\t*/ doctype html JADE; $renderer = new Renderer(['adapterOptions' => ['path' => __DIR__ . '/cache/issues'], 'pretty' => false, 'paths' => [__DIR__ . '/views/issues']]); $this->assertEquals('<?php /** * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) */?><!DOCTYPE html>', $renderer->compile($jade)); $this->assertEquals('<?php /*** CakePHP(tm) : Rapid Development Framework (http://cakephp.org) * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) */?><!DOCTYPE html><!DOCTYPE html> <html> <head><?=$view->Html->charset()?> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">', $renderer->compileFile('issue-44')); $this->assertEquals('<ul class="right hide-on-med-and-down"><li><?=$view->Html->link(__(\'Dashboard\'), [\'controller\' => \'Users\', \'action\' => \'index\'])?></li><li><?=$view->Html->link(__(\'Log Out\'), [\'controller\' => \'Users\', \'action\' => \'logout\'])?></li></ul><ul id="nav-mobile" class="side-nav"><li><?=$view->Html->link(__(\'Dashboard\'), [\'controller\' => \'Users\', \'action\' => \'index\'])?></li><li><?=$view->Html->link(__(\'Log Out\'), [\'controller\' => \'Users\', \'action\' => \'logout\'])?></li></ul><a class="button-collapse" href="#" data-activates="nav-mobile"><i class="material-icons">menu</i></a><div class="progress -main"><div class="indeterminate"></div></div>', $this->renderer->compileFile('issue-44/for_members.ctp.1')); $this->assertEquals('<ul class="right hide-on-med-and-down"><li><?=$view->Html->link(__(\'Dashboard\'), [\'controller\' => \'Users\', \'action\' => \'index\'])?></li><li><?=$view->Html->link(__(\'Log Out\'), [\'controller\' => \'Users\', \'action\' => \'logout\'])?></li></ul><ul id="nav-mobile" class="side-nav"><li><?=$view->Html->link(__(\'Dashboard\'), [\'controller\' => \'Users\', \'action\' => \'index\'])?></li><li><?=$view->Html->link(__(\'Log Out\'), [\'controller\' => \'Users\', \'action\' => \'logout\'])?></li></ul><a class="button-collapse" href="#" data-activates="nav-mobile"><i class="material-icons">menu</i></a><div class="progress -main"><div class="indeterminate"></div></div>', $this->renderer->compileFile('issue-44/for_members.ctp.2')); $renderer = new Renderer(['adapterOptions' => ['path' => __DIR__ . '/cache/issues'], 'lexerOptions' => ['indentWidth' => 2, 'indentStyle' => ' '], 'pretty' => false, 'paths' => [__DIR__ . '/views/issues']]); $this->assertEquals('<?php /** * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) */?><!DOCTYPE html>', $renderer->compile($jade)); $this->assertEquals('<?php /** * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) */?><!DOCTYPE html><!DOCTYPE html> <html> <head><?=$view->Html->charset()?> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">', $renderer->compileFile('issue-44')); $this->assertEquals('<ul class="right hide-on-med-and-down"><li><?=$view->Html->link(__(\'Dashboard\'), [\'controller\' => \'Users\', \'action\' => \'index\'])?></li><li><?=$view->Html->link(__(\'Log Out\'), [\'controller\' => \'Users\', \'action\' => \'logout\'])?></li></ul><ul id="nav-mobile" class="side-nav"><li><?=$view->Html->link(__(\'Dashboard\'), [\'controller\' => \'Users\', \'action\' => \'index\'])?></li><li><?=$view->Html->link(__(\'Log Out\'), [\'controller\' => \'Users\', \'action\' => \'logout\'])?></li></ul><a class="button-collapse" href="#" data-activates="nav-mobile"><i class="material-icons">menu</i></a><div class="progress -main"><div class="indeterminate"></div></div>', $this->renderer->compileFile('issue-44/for_members.ctp.1')); $this->assertEquals('<ul class="right hide-on-med-and-down"><li><?=$view->Html->link(__(\'Dashboard\'), [\'controller\' => \'Users\', \'action\' => \'index\'])?></li><li><?=$view->Html->link(__(\'Log Out\'), [\'controller\' => \'Users\', \'action\' => \'logout\'])?></li></ul><ul id="nav-mobile" class="side-nav"><li><?=$view->Html->link(__(\'Dashboard\'), [\'controller\' => \'Users\', \'action\' => \'index\'])?></li><li><?=$view->Html->link(__(\'Log Out\'), [\'controller\' => \'Users\', \'action\' => \'logout\'])?></li></ul><a class="button-collapse" href="#" data-activates="nav-mobile"><i class="material-icons">menu</i></a><div class="progress -main"><div class="indeterminate"></div></div>', $this->renderer->compileFile('issue-44/for_members.ctp.2')); }
public function testForcedInlineTags() { $phtml = <<<'PHTML' <?php $content = "This is some Content.\n\n This comment contains own whitespace to preserve."?> <some-container> <pre><?=htmlentities(isset($content) ? $content : '', \ENT_QUOTES, 'UTF-8')?></pre> <pre>Some <strong>interpolated content</strong></pre> <div> <?=htmlentities(isset($content) ? $content : '', \ENT_QUOTES, 'UTF-8')?> </div> <div> Some <strong> interpolated content </strong> </div> <code><?=htmlentities(isset($content) ? $content : '', \ENT_QUOTES, 'UTF-8')?></code> <code>Some <strong>interpolated content</strong></code> </some-container> PHTML; $this->assertEquals(str_replace("\r", '', $phtml), $this->renderer->compileFile('forced-inline')); }