- π³πΏNew Zealand quietone
More information was asked in this issue 10 years ago. That has not been supplied, there has been no further discussion and much has changed since this issue was opened. I am closing at outdated.
While writing some patches for taxonomy_autocomplete, I found myself unable to easily write SimpleTest cases to test it, since it changes the browser header and outputs JSON.
I tried to test by buffering the output of the function, but had problems because json_decode didn't always successfully convert the result to a non-null object, even when the JSON result appeared valid.
This would be easier to test if the code in the taxonomy_autocomplete function broken out into a helper function that would return an array. This way, the helper function could be tested without dealing with JSON, and the taxonomy_autocomplete function could just serve as the callback to serve JSON to the browser.
The code would look something like this:
<?php
function taxonomy_autocomplete($vid, $string='') {
$matches = _taxonomy_autocomplete($vid, $string);
drupal_json($matches);
}
function _taxonomy_autocomplete($vid, $string='') {
// insert code from old taxonomy_autocomplete, but return the array of matches instead of outputting JSON.
}
?>
Does anyone have any comments or suggestions on this?
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
More information was asked in this issue 10 years ago. That has not been supplied, there has been no further discussion and much has changed since this issue was opened. I am closing at outdated.