Skip to content

Commit

Permalink
Removing remaining ClassRegistry::getObject() in HtmlHelper.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Aug 11, 2010
1 parent 7b3f2f7 commit 90b0ac7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
6 changes: 2 additions & 4 deletions cake/libs/view/helpers/html.php
Expand Up @@ -235,8 +235,7 @@ public function meta($type, $url = null, $options = array()) {
if ($inline) {
return $out;
} else {
$view =& ClassRegistry::getObject('view');
$view->addScript($out);
$this->_View->addScript($out);
}
}

Expand Down Expand Up @@ -473,8 +472,7 @@ public function scriptBlock($script, $options = array()) {
if ($inline) {
return sprintf($this->tags['javascriptblock'], $attributes, $script);
} else {
$view =& ClassRegistry::getObject('view');
$view->addScript(sprintf($this->tags['javascriptblock'], $attributes, $script));
$this->_View->addScript(sprintf($this->tags['javascriptblock'], $attributes, $script));
return null;
}
}
Expand Down
22 changes: 8 additions & 14 deletions cake/tests/cases/libs/view/helpers/html.test.php
Expand Up @@ -647,10 +647,8 @@ function testScriptBlock() {
);
$this->assertTags($result, $expected);

ClassRegistry::removeObject('view');
$view = $this->getMock('View', array(), array(), '', false);
ClassRegistry::addObject('view', $view);
$view->expects($this->any())->method('addScript')

$this->View->expects($this->any())->method('addScript')
->with($this->matchesRegularExpression('/window\.foo\s\=\s2;/'));

$result = $this->Html->scriptBlock('window.foo = 2;', array('inline' => false));
Expand Down Expand Up @@ -698,11 +696,7 @@ function testScriptStartAndScriptEnd() {
);
$this->assertTags($result, $expected);

ClassRegistry::removeObject('view');
$view = $this->getMock('View', array(), array(), '', false);
ClassRegistry::addObject('view', $view);

$view->expects($this->once())->method('addScript');
$this->View->expects($this->once())->method('addScript');

$result = $this->Html->scriptStart(array('safe' => false, 'inline' => false));
$this->assertNull($result);
Expand Down Expand Up @@ -1122,12 +1116,12 @@ function testMeta() {
$result = $this->Html->meta(array('name' => 'ROBOTS', 'content' => 'ALL'));
$this->assertTags($result, array('meta' => array('name' => 'ROBOTS', 'content' => 'ALL')));

ClassRegistry::removeObject('view');
$view = $this->getMock('View', array(), array(), '', false);
ClassRegistry::addObject('view', $view);
$view->expects($this->any())->method('addScript')->with($this->matchesRegularExpression('/^<meta/'));

$this->assertNull($this->Html->meta(array('name' => 'ROBOTS', 'content' => 'ALL'), null, array('inline' => false)));
$this->View->expects($this->any())->method('addScript')
->with($this->matchesRegularExpression('/^<meta/'));

$result = $this->Html->meta(array('name' => 'ROBOTS', 'content' => 'ALL'), null, array('inline' => false));
$this->assertNull($result);
}

/**
Expand Down

0 comments on commit 90b0ac7

Please sign in to comment.