Fixing return value for JavascriptHelper::blockEnd() for script caching (Ticket #3172)

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5686 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2007-09-23 14:23:39 +00:00
parent 52f1e2dc5c
commit 8f4dd39257
2 changed files with 31 additions and 5 deletions

View file

@ -105,8 +105,8 @@ class JavascriptHelper extends AppHelper {
if (!empty($script)) {
$this->_cachedEvents[] = $script;
return null;
}
return $this->tags['javascriptend'];
}
/**

View file

@ -86,6 +86,32 @@ class JavascriptTest extends UnitTestCase {
$this->assertEqual($result, $expected);
}
function testScriptBlock() {
$result = $this->Javascript->codeBlock("something");
$this->assertPattern('/^<script[^<>]+>something<\/script>$/', $result);
$this->assertPattern('/^<script[^<>]+type="text\/javascript">something<\/script>$/', $result);
$this->assertPattern('/^<script[^<>]+type="text\/javascript"[^<>]*>/', $result);
$this->assertNoPattern('/^<script[^type]=[^<>]*>/', $result);
$result = $this->Javascript->codeBlock();
$this->assertPattern('/^<script[^<>]+>$/', $result);
$this->assertNoPattern('/^<script[^type]=[^<>]*>/', $result);
$result = $this->Javascript->blockEnd();
$this->assertEqual("</script>", $result);
$this->Javascript->cacheEvents(false, true);
$result = $this->Javascript->codeBlock();
$this->assertIdentical($result, null);
echo 'alert("this is a buffered script");';
$result = $this->Javascript->blockEnd();
$this->assertIdentical($result, null);
$result = $this->Javascript->getCache();
$this->assertEqual('alert("this is a buffered script");', $result);
}
function tearDown() {
unset($this->Javascript);
}