When a page is loaded using DrupalWebTestCase::drupalGet() Drupal settings from javascript is parsed and put into DrupalWebTestCase::drupalSettings.
This is done using a regular expression. This expression does not always return the entire settings json.
It lazily tries to find ); and the Drupal.settings json might contain those characters without it being an error.
Matching it without using laziness is not desirable, as another ); later on the page will have this return to much.
The only solution i see is to modify core, adding some sort of comment at the end of the settings json stating that it has ended here:
includes/common.inc line 4374 in current 7.x-dev from January 22, 2015 - 06:28
$js_element['#value'] = 'jQuery.extend(Drupal.settings, ' . drupal_json_encode(drupal_array_merge_deep_array($item['data'])) . ");/*Drupal.settings end*/";
And change the preg match to search for this:
modules/simpletest/drupal_web_test_case.php line 2902 in current 7.x-dev from January 22, 2015 - 06:28
if (preg_match('/jQuery\.extend\(Drupal\.settings, (.*?)\);\/\*Drupal.settings end\*\//', $content, $matches)) {
Patch attached.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | drupal-core-drupalsettings-not-extracted-correctly-2428029-0-7.x-dev.patch | 1.46 KB | mian3010 |
Comments
Comment #1
mian3010 commentedComment #2
mian3010 commentedI see this is a duplicate of issue https://www.drupal.org/node/1816556, sorry