Skip to content

Commit

Permalink
Adding stubs for JsHelper::submit()
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Jul 21, 2009
1 parent a5bfe72 commit a3d5a9b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cake/libs/view/helpers/js.php
Expand Up @@ -233,6 +233,18 @@ function link($title, $url = null, $options = array()) {
}
return $out;
}
/**
* Uses the selected JS engine to create a submit input
* element that is enhanced with Javascript. Options can include
* both those for FormHelper::submit() and JsBaseEngine::request(), JsBaseEngine::event();
*
* @param string $title The display text of the submit button.
* @param array $options Array of options to use.
* @return string Completed submit button.
**/
function submit($title, $options = array()) {

}
/**
* Parse a set of Options and extract the Html options.
* Extracted Html Options are removed from the $options param.
Expand Down
28 changes: 28 additions & 0 deletions cake/tests/cases/libs/view/helpers/js.test.php
Expand Up @@ -289,6 +289,34 @@ function testLinkWithMock() {
);
$this->assertTags($result, $expected);
}
/**
* test submit() with a Mock to check Engine method calls
*
* @return void
**/
function testSubmitWithMock() {
$this->_useMock();
$options = array(
'update' => '#content',
'id' => 'test-submit'
);
$this->Js->TestJsEngine->setReturnValue('dispatchMethod', 'serialize-code', array('serializeForm', '*'));
$this->Js->TestJsEngine->setReturnValue('dispatchMethod', 'ajax code', array('request', '*'));

$this->Js->TestJsEngine->expectAt(0, 'dispatchMethod', array('get', '*'));
$this->Js->TestJsEngine->expectAt(1, 'dispatchMethod', array('serializeForm', '*'));
$this->Js->TestJsEngine->expectAt(2, 'dispatchMethod', array('request', '*'));
$this->Js->TestJsEngine->expectAt(3, 'dispatchMethod', array(
'event', array('click', "serialize-code\najax-code", $options)
));
$result = $this->Js->submit('Save', $options);
$expected = array(
'div' => array('class' => 'input submit'),
'input' => array('type' => 'submit', 'id' => $options['id'], 'value' => 'Save'),
'/div'
);
$this->assertTags($result, $expected);
}
}


Expand Down

0 comments on commit a3d5a9b

Please sign in to comment.