2

I'm working on writing some automated tests for an AJAX API, and getting strange results. If I directly view the page, I see the following output, sent by drupal_json_output:

{"guid":"8e2a179e-c901-8744-05fc-e80de9500dd6","success":1}

My unit test hits this same URL. Here's the test function:

 public function testInit() {
    $response = $this->drupalGetAJAX('plugin/init', array('query' => array('guid' => $this->registered_user->uuid)));
    $this->assertEqual($response['guid'], $this->registered_user->uuid, 'GUID Loaded');
    $this->pass(json_encode($response));
  }

When I initiate the test run, it goes to the usual batch API progress page. Rather than moving directly to the test results page, I get "An error has occurred, please continue to the error page". Here's the output that follows:

An AJAX HTTP error occurred. HTTP Result Code: 200 Debugging information follows. Path: /batch?id=64&op=do StatusText: OK ResponseText: {"guid":"a06f78ec-1368-f4c4-c9ac-a710b3e941b5","success":1}{"status":true,"percentage":"100","message":"Processed test 1 of 1 - \u003Cem class=\u0022placeholder\u0022\u003EPlugin\u003C\/em\u003E.\u003Cdiv class=\u0022simpletest-fail\u0022\u003EOverall results: 7 passes, 1 fail, 0 exceptions, and 1 debug message\u003C\/div\u003E\u003Cdiv class=\u0022item-list\u0022\u003E\u003Cul\u003E\u003Cli class=\u0022first last\u0022\u003E\u003Cdiv class=\u0022simpletest-fail\u0022\u003EPlugin: 7 passes, 1 fail, 0 exceptions, and 1 debug message\u003C\/div\u003E\u003C\/li\u003E\n\u003C\/ul\u003E\u003C\/div\u003E"}

This reads to me like some sort of error within the test runner, as you can see the response from the AJAX API module is there. It looks like it's showing my module's JSON output concatenated to the output of the batch call to the test runner.

The output for $response is always "1" when viewing the test results page. In the detailed test result page, the call is listed as follows, returning 1 byte:

GET http://platform.dev/plugin/init?guid=5b299683-49d8-7754-f9ca-3fb88e79ff0f returned 200 (1 byte).

For experimentation sake, I also ran the test suites for AJAX commands and the batch API. The same thing happens. My best guess is that this is a bug in Drupal 7.15.

1
  • Do you have any debug modules enabled. Try disabling one module at a time and check if it is due to a contrib module first. Also make sure there is no space before the <?php tag.
    – junedkazi
    Commented Sep 19, 2012 at 18:48

1 Answer 1

0

The issue is a known one, and a patch fixed the issue - http://drupal.org/files/drupal.simpletest-curl-cookiejar.33.patch

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.