Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updating HtmlHelper and its tests to use View::append().

  • Loading branch information...
commit 4606ea39a90986eb8a781ba0f77583db7e6f6c9d 1 parent bd4ee41
Mark Story markstory authored
29 lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php
View
@@ -144,7 +144,7 @@ class HtmlHelperTest extends CakeTestCase {
*/
public function setUp() {
parent::setUp();
- $this->View = $this->getMock('View', array('addScript'), array(new TheHtmlTestController()));
+ $this->View = $this->getMock('View', array('append'), array(new TheHtmlTestController()));
$this->Html = new TestHtmlHelper($this->View);
$this->Html->request = new CakeRequest(null, false);
$this->Html->request->webroot = '';
@@ -508,12 +508,13 @@ public function testCssLink() {
$this->assertTags($result[1], $expected);
$this->assertEquals(count($result), 2);
- $this->View->expects($this->at(0))->method('addScript')
- ->with($this->matchesRegularExpression('/css_in_head.css/'));
+ $this->View->expects($this->at(0))
+ ->method('append')
+ ->with('css', $this->matchesRegularExpression('/css_in_head.css/'));
$this->View->expects($this->at(1))
- ->method('addScript')
- ->with($this->matchesRegularExpression('/more_css_in_head.css/'));
+ ->method('append')
+ ->with('css', $this->matchesRegularExpression('/more_css_in_head.css/'));
$result = $this->Html->css('css_in_head', null, array('inline' => false));
$this->assertNull($result);
@@ -654,8 +655,9 @@ public function testScript() {
);
$this->assertTags($result, $expected);
- $this->View->expects($this->any())->method('addScript')
- ->with($this->matchesRegularExpression('/script_in_head.js/'));
+ $this->View->expects($this->any())
+ ->method('append')
+ ->with('script', $this->matchesRegularExpression('/script_in_head.js/'));
$result = $this->Html->script('script_in_head', array('inline' => false));
$this->assertNull($result);
}
@@ -751,8 +753,9 @@ public function testScriptBlock() {
$this->assertTags($result, $expected);
- $this->View->expects($this->any())->method('addScript')
- ->with($this->matchesRegularExpression('/window\.foo\s\=\s2;/'));
+ $this->View->expects($this->any())
+ ->method('append')
+ ->with('script', $this->matchesRegularExpression('/window\.foo\s\=\s2;/'));
$result = $this->Html->scriptBlock('window.foo = 2;', array('inline' => false));
$this->assertNull($result);
@@ -799,7 +802,8 @@ public function testScriptStartAndScriptEnd() {
);
$this->assertTags($result, $expected);
- $this->View->expects($this->once())->method('addScript');
+ $this->View->expects($this->once())
+ ->method('append');
$result = $this->Html->scriptStart(array('safe' => false, 'inline' => false));
$this->assertNull($result);
echo 'this is some javascript';
@@ -1245,8 +1249,9 @@ public function testMeta() {
$this->assertTags($result, array('meta' => array('name' => 'ROBOTS', 'content' => 'ALL')));
- $this->View->expects($this->any())->method('addScript')
- ->with($this->matchesRegularExpression('/^<meta/'));
+ $this->View->expects($this->any())
+ ->method('append')
+ ->with('meta', $this->matchesRegularExpression('/^<meta/'));
$result = $this->Html->meta(array('name' => 'ROBOTS', 'content' => 'ALL'), null, array('inline' => false));
$this->assertNull($result);
8 lib/Cake/View/Helper/HtmlHelper.php
View
@@ -281,7 +281,7 @@ public function meta($type, $url = null, $options = array()) {
if ($inline) {
return $out;
} else {
- $this->_View->addScript($out);
+ $this->_View->append('meta', $out);
}
}
@@ -436,7 +436,7 @@ public function css($path, $rel = null, $options = array()) {
if ($options['inline']) {
return $out;
} else {
- $this->_View->addScript($out);
+ $this->_View->append(__FUNCTION__, $out);
}
}
@@ -513,7 +513,7 @@ public function script($url, $options = array()) {
if ($options['inline']) {
return $out;
} else {
- $this->_View->addScript($out);
+ $this->_View->append(__FUNCTION__, $out);
}
}
@@ -541,7 +541,7 @@ public function scriptBlock($script, $options = array()) {
if ($inline) {
return sprintf($this->_tags['javascriptblock'], $attributes, $script);
} else {
- $this->_View->addScript(sprintf($this->_tags['javascriptblock'], $attributes, $script));
+ $this->_View->append('script', sprintf($this->_tags['javascriptblock'], $attributes, $script));
return null;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.