Skip to content

Commit

Permalink
add tests demonstrating newline handling works
Browse files Browse the repository at this point in the history
  • Loading branch information
AD7six committed Nov 14, 2014
1 parent 3e20189 commit 9594e62
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/TestCase/View/BakeViewTest.php
Expand Up @@ -58,6 +58,14 @@ public function testRenderString() {
$this->assertSame($expected, $result, 'variables in erb-style tags should be evaluated');
}

public function testRenderTemplate() {
$this->View->set(['aVariable' => 123]);
$result = $this->View->render('view_tests/simple');
$expected = "The value of aVariable is: 123.\n";

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

public function testRenderIgnorePhpTags() {
$template = 'The value of aVariable is: <%= $aVariable %>. Not <?php echo $aVariable ?>.';

Expand All @@ -78,4 +86,17 @@ public function testRenderIgnorePhpShortTags() {
$this->assertSame($expected, $result, 'variables in php tags should be treated as strings');
}

public function testRenderNewlines() {
$result = $this->View->render('view_tests/newlines');
$expected = "There should be a newline about here: \n";
$expected .= "And this should be on the next line.\n";
$expected .= "\n";
$expected .= "There should be no new line after this";

$this->assertSame(
$expected,
$result,
'Tags at the end of a line should not swallow new lines when rendered'
);
}
}
1 change: 1 addition & 0 deletions tests/test_app/TestApp/Template/Bake/view_tests/simple.ctp
@@ -0,0 +1 @@
The value of aVariable is: <%= $aVariable %>.

0 comments on commit 9594e62

Please sign in to comment.