Adding stubs for JsHelper::submit()

This commit is contained in:
mark_story 2009-07-21 00:24:58 -04:00
parent a5bfe72bd2
commit a3d5a9beae
2 changed files with 40 additions and 0 deletions

View file

@ -233,6 +233,18 @@ class JsHelper extends AppHelper {
}
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.

View file

@ -289,6 +289,34 @@ CODE;
);
$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);
}
}