Skip to content

Commit

Permalink
Making Helper extend Object, this fixes issues where Helpers would no…
Browse files Browse the repository at this point in the history
…t have dispatchMethod or requestAction available.

Correcting JsHelper::call__ into JsHelper::__call
Updating test cases to remove reference operators
  • Loading branch information
markstory committed Apr 24, 2010
1 parent 9e08196 commit 33bfe0e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion cake/libs/view/helper.php
Expand Up @@ -27,7 +27,7 @@
* @package cake
* @subpackage cake.cake.libs.view
*/
class Helper {
class Helper extends Object {

/**
* List of helpers used by this helper
Expand Down
2 changes: 1 addition & 1 deletion cake/libs/view/helpers/js.php
Expand Up @@ -119,7 +119,7 @@ public function __construct($settings = array()) {
* @param array $params Parameters for the method being called.
* @return mixed Depends on the return of the dispatched method, or it could be an instance of the EngineHelper
*/
public function call__($method, $params) {
public function __call($method, $params) {
if (isset($this->{$this->__engineName}) && method_exists($this->{$this->__engineName}, $method)) {
$buffer = false;
if (in_array(strtolower($method), $this->{$this->__engineName}->bufferedMethods)) {
Expand Down
36 changes: 18 additions & 18 deletions cake/tests/cases/libs/view/helpers/js.test.php
Expand Up @@ -83,13 +83,13 @@ function startTest() {
$this->_asset = Configure::read('Asset.timestamp');
Configure::write('Asset.timestamp', false);

$this->Js =& new JsHelper('JsBase');
$this->Js->Html =& new HtmlHelper();
$this->Js->Form =& new FormHelper();
$this->Js->Form->Html =& new HtmlHelper();
$this->Js->JsBaseEngine =& new JsBaseEngineHelper();
$this->Js = new JsHelper('JsBase');
$this->Js->Html = new HtmlHelper();
$this->Js->Form = new FormHelper();
$this->Js->Form->Html = new HtmlHelper();
$this->Js->JsBaseEngine = new JsBaseEngineHelper();

$view =& new JsHelperMockView();
$view = new JsHelperMockView();
ClassRegistry::addObject('view', $view);
}

Expand All @@ -111,11 +111,11 @@ function endTest() {
* @return void
*/
function _useMock() {
$this->Js =& new JsHelper(array('TestJs'));
$this->Js->TestJsEngine =& new TestJsEngineHelper($this);
$this->Js->Html =& new HtmlHelper();
$this->Js->Form =& new FormHelper();
$this->Js->Form->Html =& new HtmlHelper();
$this->Js = new JsHelper(array('TestJs'));
$this->Js->TestJsEngine = new TestJsEngineHelper($this);
$this->Js->Html = new HtmlHelper();
$this->Js->Form = new FormHelper();
$this->Js->Form->Html = new HtmlHelper();
}

/**
Expand All @@ -124,16 +124,16 @@ function _useMock() {
* @return void
*/
function testConstruction() {
$js =& new JsHelper();
$js = new JsHelper();
$this->assertEqual($js->helpers, array('Html', 'Form', 'JqueryEngine'));

$js =& new JsHelper(array('mootools'));
$js = new JsHelper(array('mootools'));
$this->assertEqual($js->helpers, array('Html', 'Form', 'mootoolsEngine'));

$js =& new JsHelper('prototype');
$js = new JsHelper('prototype');
$this->assertEqual($js->helpers, array('Html', 'Form', 'prototypeEngine'));

$js =& new JsHelper('MyPlugin.Dojo');
$js = new JsHelper('MyPlugin.Dojo');
$this->assertEqual($js->helpers, array('Html', 'Form', 'MyPlugin.DojoEngine'));
}

Expand All @@ -148,7 +148,7 @@ function testMethodDispatching() {

$this->Js->methodOne();

$this->Js->TestEngine =& new StdClass();
$this->Js->TestEngine = new StdClass();
$this->expectError();
$this->Js->someMethodThatSurelyDoesntExist();
}
Expand Down Expand Up @@ -228,7 +228,7 @@ function testWriteScriptsNoFile() {
$result = $this->Js->writeBuffer(array('onDomReady' => true, 'cache' => false, 'clear' => false));

ClassRegistry::removeObject('view');
$view =& new JsHelperMockView();
$view = new JsHelperMockView();
ClassRegistry::addObject('view', $view);

$view->expectCallCount('addScript', 1);
Expand All @@ -244,7 +244,7 @@ function testWriteScriptsNoFile() {
function testWriteBufferNotInline() {
$this->Js->set('foo', 1);

$view =& new JsHelperMockView();
$view = new JsHelperMockView();
ClassRegistry::removeObject('view');
ClassRegistry::addObject('view', $view);
$view->expectCallCount('addScript', 1);
Expand Down

0 comments on commit 33bfe0e

Please sign in to comment.