Skip to content

Commit

Permalink
remove render-template-as-string
Browse files Browse the repository at this point in the history
it was just a testing crutch, and isn't required
  • Loading branch information
AD7six committed Nov 14, 2014
1 parent 23b9701 commit adaabac
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 28 deletions.
4 changes: 0 additions & 4 deletions src/View/BakeView.php
Expand Up @@ -148,10 +148,6 @@ protected function _getViewFileName($name = null) {
* @return string Bake template to evaluate
*/
protected function _getViewFileContents($name) {
if (strpos($name, '<') !== false) {
return $name;
}

$filename = $this->_getViewFileName($name);
return file_get_contents($filename);
}
Expand Down
29 changes: 5 additions & 24 deletions tests/TestCase/View/BakeViewTest.php
Expand Up @@ -48,21 +48,6 @@ public function tearDown() {
unset($this->View);
}

/**
* test rendering a string
*
* @return void
*/
public function testRenderString() {
$template = 'The value of aVariable is: <%= $aVariable %>.';

$this->View->set(['aVariable' => 123]);
$result = $this->View->render($template);
$expected = 'The value of aVariable is: 123.';

$this->assertSame($expected, $result, 'variables in erb-style tags should be evaluated');
}

/**
* test rendering a template file
*
Expand All @@ -82,11 +67,9 @@ public function testRenderTemplate() {
* @return void
*/
public function testRenderIgnorePhpTags() {
$template = 'The value of aVariable is: <%= $aVariable %>. Not <?php echo $aVariable ?>.';

$this->View->set(['aVariable' => 123]);
$result = $this->View->render($template);
$expected = 'The value of aVariable is: 123. Not <?php echo $aVariable ?>.';
$result = $this->View->render('view_tests/simple_php');
$expected = "The value of aVariable is: 123. Not <?php echo \$aVariable ?>.\n";

$this->assertSame($expected, $result, 'variables in php tags should be treated as strings');
}
Expand All @@ -97,11 +80,9 @@ public function testRenderIgnorePhpTags() {
* @return void
*/
public function testRenderIgnorePhpShortTags() {
$template = 'The value of aVariable is: <%= $aVariable %>. Not <?= $aVariable ?>.';

$this->View->set(['aVariable' => 123]);
$result = $this->View->render($template);
$expected = 'The value of aVariable is: 123. Not <?= $aVariable ?>.';
$result = $this->View->render('view_tests/simple_php_short_tags');
$expected = "The value of aVariable is: 123. Not <?= \$aVariable ?>.\n";

$this->assertSame($expected, $result, 'variables in php tags should be treated as strings');
}
Expand Down Expand Up @@ -131,7 +112,7 @@ public function testRenderNewlines() {
* @return void
*/
public function testSwallowLeadingWhitespace() {
$result = $this->View->render('view_tests/leading-whitespace');
$result = $this->View->render('view_tests/leading_whitespace');
$expected = $this->_getCompareTemplate('leading-whitespace');

$this->assertSame(
Expand Down
@@ -0,0 +1 @@
The value of aVariable is: <%= $aVariable %>. Not <?php echo $aVariable ?>.
@@ -0,0 +1 @@
The value of aVariable is: <%= $aVariable %>. Not <?= $aVariable ?>.

0 comments on commit adaabac

Please sign in to comment.