I am trying to write the test case for my custom ajax functionality in Drupal 7. I am firing the event on click in my .js
file but the test case gets a fail.
In my .tpl.php
template file I have the following code:
<a href="javasctipt:void(0)" id="myFirstEvent">Click Here</a>
In the Js file I am getting the event as follows:
$('#myFirstEvent').live('click', function())
$.ajax({
cache: false,
url: Drupal.settings.basePath + '?q=mymodule/add',
data: {page: page, sort: sort, order: order},
dataType: 'text',
error: function(request, status, error) {
alert(status);
},
success: function(data, status, request) {
/**Function definition goes here**/
}
In my custom.test file I have the following:
$edit = array();
$this>drupalGet("myform/add");
$this->drupalPost('myform/add', $edit, 'myFirstEvent');
$this->assertResponse(200, 'Success');
But I am not getting the success screen (Green Color) after I execute my test cases.
(function($) { // your code here }) (jQuery);
– Serjas Oct 23 '12 at 5:24