You are here

protected function XAutoloadWebTestCase::xautoloadModuleCheckJson in X Autoload 7.4

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

Parameters

string $module:

array $cache_types: The autoloader modes that are enabled, e.g. array('apc' => 'apc', 'xcache' => 'xcache')

bool $cache_lazy: Whether the "lazy" mode is enabled.

string[] $classes:

1 call to XAutoloadWebTestCase::xautoloadModuleCheckJson()
XAutoloadWebTestCase::xautoloadTestWithCacheTypes in lib/Drupal/xautoload/Tests/XAutoloadWebTestCase.php

File

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

Class

XAutoloadWebTestCase

Namespace

Drupal\xautoload\Tests

Code

protected function xautoloadModuleCheckJson($module, $cache_types, $cache_lazy, $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, $cache_types, $cache_lazy, $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_exists'][$class], "Class {$class} was found {$when}.");
    }
  }
}