You are here

protected function XAutoloadWebTestCase::xautoloadModuleCheckJson in X Autoload 7.3

Same name and namespace in other branches
  1. 7.5 lib/Drupal/xautoload/Tests/XAutoloadWebTestCase.php \Drupal\xautoload\Tests\XAutoloadWebTestCase::xautoloadModuleCheckJson()
  2. 7.4 lib/Drupal/xautoload/Tests/XAutoloadWebTestCase.php \Drupal\xautoload\Tests\XAutoloadWebTestCase::xautoloadModuleCheckJson()
1 call to XAutoloadWebTestCase::xautoloadModuleCheckJson()
XAutoloadWebTestCase::xautoloadCheckCacheMode in lib/Drupal/xautoload/Tests/XAutoloadWebTestCase.php

File

lib/Drupal/xautoload/Tests/XAutoloadWebTestCase.php, line 88

Class

XAutoloadWebTestCase

Namespace

Drupal\xautoload\Tests

Code

protected function xautoloadModuleCheckJson($module, $mode, $classes) {
  $path = "{$module}.json";
  $json = $this
    ->drupalGet($path);
  $all = json_decode($json, TRUE);
  if (!is_array($all) || empty($all)) {
    $this
      ->fail("{$path} must return a non-empty json array.");
    return;
  }
  foreach ($all as $phase => $observations) {
    $when = $phase === 'early' ? 'on early bootstrap' : ($phase === 'boot' ? 'during hook_boot()' : 'at an undefined time');
    $this
      ->xautoloadCheckTestEnvironment($observations, $mode, $phase, $when);

    // Test the classes of the example module.
    foreach ($classes as $class) {

      // Test that the class was already found in $phase.
      $this
        ->assertTrue($observations[$class], "Class {$class} was found {$when}.");
    }
  }
}