mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
Adding stubs for JsHelper::submit()
This commit is contained in:
parent
a5bfe72bd2
commit
a3d5a9beae
2 changed files with 40 additions and 0 deletions
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue