You are here

public function BootstrapGetFilenameWebTestCase::testRecursiveRebuilds in Drupal 7

Test that drupal_get_filename() does not break recursive rebuilds.

File

modules/simpletest/tests/bootstrap.test, line 610

Class

BootstrapGetFilenameWebTestCase
Test drupal_get_filename() in the context of a full Drupal installation.

Code

public function testRecursiveRebuilds() {

  // Ensure that the drupal_get_filename() call due to a missing module does
  // not break the data returned by an attempted recursive rebuild. The code
  // path which is tested is as follows:
  // - Call drupal_get_schema().
  // - Within a hook_schema() implementation, trigger a drupal_get_filename()
  //   search for a nonexistent module.
  // - In the watchdog() call that results from that, trigger
  //   drupal_get_schema() again.
  // Without some kind of recursion protection, this could cause the second
  // drupal_get_schema() call to return incomplete results. This test ensures
  // that does not happen.
  $non_existing_module = $this
    ->randomName();
  variable_set('system_test_drupal_get_filename_test_module_name', $non_existing_module);
  $this
    ->drupalGet('system-test/drupal-get-filename-with-schema-rebuild');
  $original_drupal_get_schema_tables = variable_get('system_test_drupal_get_filename_with_schema_rebuild_original_tables');
  $final_drupal_get_schema_tables = variable_get('system_test_drupal_get_filename_with_schema_rebuild_final_tables');
  $this
    ->assertTrue(!empty($original_drupal_get_schema_tables));
  $this
    ->assertTrue(!empty($final_drupal_get_schema_tables));
  $this
    ->assertEqual($original_drupal_get_schema_tables, $final_drupal_get_schema_tables);
}