Skip to content
Permalink
Browse files

Adding tests for custom url on submit()

  • Loading branch information...
markstory committed Jul 25, 2009
1 parent e8b39fb commit 49e0e5743f4486a3edb98497606ca2849ef6a839
Showing with 28 additions and 10 deletions.
  1. +0 −1 cake/libs/view/helpers/js.php
  2. +28 −9 cake/tests/cases/libs/view/helpers/js.test.php
@@ -267,7 +267,6 @@ function submit($caption = null, $options = array()) {
$url = $options['url'];
unset($options['url']);
}
$requestString .= $this->request($url, $options);
if (!empty($requestString)) {
$event = $this->event('click', $requestString, $options);
@@ -346,30 +346,49 @@ function testLinkWithNoBuffering() {
**/
function testSubmitWithMock() {
$this->_useMock();
$options = array(
'update' => '#content',
'id' => 'test-submit'
);
$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', '*'));
$params = array(
'update' => $options['update'],
'data' => 'serialize-code'
);
$params = array('update' => $options['update'], 'data' => 'serialize-code');
$this->Js->TestJsEngine->expectAt(3, 'dispatchMethod', array(
'event', array('click', "ajax-code", $params)
));
$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, 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);
}
}

0 comments on commit 49e0e57

Please sign in to comment.
You can’t perform that action at this time.