mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Adding tests for custom url on submit()
This commit is contained in:
parent
e8b39fb9a5
commit
49e0e5743f
2 changed files with 28 additions and 10 deletions
|
@ -267,7 +267,6 @@ class JsHelper extends AppHelper {
|
||||||
$url = $options['url'];
|
$url = $options['url'];
|
||||||
unset($options['url']);
|
unset($options['url']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$requestString .= $this->request($url, $options);
|
$requestString .= $this->request($url, $options);
|
||||||
if (!empty($requestString)) {
|
if (!empty($requestString)) {
|
||||||
$event = $this->event('click', $requestString, $options);
|
$event = $this->event('click', $requestString, $options);
|
||||||
|
|
|
@ -346,30 +346,49 @@ CODE;
|
||||||
**/
|
**/
|
||||||
function testSubmitWithMock() {
|
function testSubmitWithMock() {
|
||||||
$this->_useMock();
|
$this->_useMock();
|
||||||
$options = array(
|
|
||||||
'update' => '#content',
|
$options = array('update' => '#content', 'id' => 'test-submit');
|
||||||
'id' => 'test-submit'
|
|
||||||
);
|
|
||||||
$this->Js->TestJsEngine->setReturnValue('dispatchMethod', 'serialize-code', array('serializeForm', '*'));
|
$this->Js->TestJsEngine->setReturnValue('dispatchMethod', 'serialize-code', array('serializeForm', '*'));
|
||||||
$this->Js->TestJsEngine->setReturnValue('dispatchMethod', 'ajax-code', array('request', '*'));
|
$this->Js->TestJsEngine->setReturnValue('dispatchMethod', 'ajax-code', array('request', '*'));
|
||||||
|
|
||||||
$this->Js->TestJsEngine->expectAt(0, 'dispatchMethod', array('get', '*'));
|
$this->Js->TestJsEngine->expectAt(0, 'dispatchMethod', array('get', '*'));
|
||||||
$this->Js->TestJsEngine->expectAt(1, 'dispatchMethod', array('serializeForm', '*'));
|
$this->Js->TestJsEngine->expectAt(1, 'dispatchMethod', array('serializeForm', '*'));
|
||||||
$this->Js->TestJsEngine->expectAt(2, 'dispatchMethod', array('request', '*'));
|
$this->Js->TestJsEngine->expectAt(2, 'dispatchMethod', array('request', '*'));
|
||||||
$params = array(
|
|
||||||
'update' => $options['update'],
|
$params = array('update' => $options['update'], 'data' => 'serialize-code');
|
||||||
'data' => 'serialize-code'
|
|
||||||
);
|
|
||||||
$this->Js->TestJsEngine->expectAt(3, 'dispatchMethod', array(
|
$this->Js->TestJsEngine->expectAt(3, 'dispatchMethod', array(
|
||||||
'event', array('click', "ajax-code", $params)
|
'event', array('click', "ajax-code", $params)
|
||||||
));
|
));
|
||||||
|
|
||||||
$result = $this->Js->submit('Save', $options);
|
$result = $this->Js->submit('Save', $options);
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'div' => array('class' => 'submit'),
|
'div' => array('class' => 'submit'),
|
||||||
'input' => array('type' => 'submit', 'id' => $options['id'], 'value' => 'Save'),
|
'input' => array('type' => 'submit', 'id' => $options['id'], 'value' => 'Save'),
|
||||||
'/div'
|
'/div'
|
||||||
);
|
);
|
||||||
$this->assertTags($result, $expected, true);
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
|
|
||||||
|
$this->Js->TestJsEngine->expectAt(4, 'dispatchMethod', array('get', '*'));
|
||||||
|
$this->Js->TestJsEngine->expectAt(5, 'dispatchMethod', array('serializeForm', '*'));
|
||||||
|
$requestParams = array(
|
||||||
|
'/custom/url', array('update' => '#content', 'data' => 'serialize-code')
|
||||||
|
);
|
||||||
|
$this->Js->TestJsEngine->expectAt(6, 'dispatchMethod', array('request', $requestParams));
|
||||||
|
|
||||||
|
$params = array('update' => '#content', 'data' => 'serialize-code');
|
||||||
|
$this->Js->TestJsEngine->expectAt(7, 'dispatchMethod', array(
|
||||||
|
'event', array('click', "ajax-code", $params)
|
||||||
|
));
|
||||||
|
|
||||||
|
$options = array('update' => '#content', 'id' => 'test-submit', 'url' => '/custom/url');
|
||||||
|
$result = $this->Js->submit('Save', $options);
|
||||||
|
$expected = array(
|
||||||
|
'div' => array('class' => 'submit'),
|
||||||
|
'input' => array('type' => 'submit', 'id' => $options['id'], 'value' => 'Save'),
|
||||||
|
'/div'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue