You are here

public function FusionApplyApiTestCase::testFusionApplyImplements in Fusion Accelerator 7

Same name and namespace in other branches
  1. 7.2 fusion_apply/tests/fusion_apply.test \FusionApplyApiTestCase::testFusionApplyImplements()

Tests fusion_apply_implements().

File

fusion_apply/tests/fusion_apply.test, line 141
Tests for the Fusion Apply module.

Class

FusionApplyApiTestCase
Tests API functionality.

Code

public function testFusionApplyImplements() {

  // Verify that fusion_apply_implements() only returns extensions that are
  // compatible with this version of Fusion Apply.
  $extensions = fusion_apply_implements();

  // The expected extensions and their specific properties, if any.
  $all_expected = array(
    // Fusion Apply is always expected.
    'fusion_apply' => array(),
    // Node is a required core module, so always expected.
    'node' => array(
      'version' => VERSION,
      'path' => drupal_get_path('module', 'fusion_apply') . '/modules',
    ),
    // fusion_apply_test has been installed.
    'fusion_apply_test' => array(
      'directory' => 'skins',
    ),
    'fusion_apply_test_basetheme' => array(
      'type' => 'theme',
      'api' => 2,
      'directory' => 'skins',
      'base themes' => array(),
      'sub themes' => drupal_map_assoc(array(
        'fusion_apply_test_subtheme',
      )),
    ),
    'fusion_apply_test_subtheme' => array(
      'type' => 'theme',
      'api' => 2,
      'directory' => 'skins',
      'base themes' => drupal_map_assoc(array(
        'fusion_apply_test_basetheme',
      )),
      'sub themes' => array(),
    ),
  );

  // When running tests on Fusion Apply code packaged by drupal.org, all 'version'
  // properties will have the version of the Fusion Apply module. When running on a
  // repository checkout, the version is NULL (undefined).
  $fusion_apply_module_info = system_get_info('module', 'fusion_apply');
  $fusion_apply_module_version = !empty($fusion_apply_module_info['version']) ? $fusion_apply_module_info['version'] : NULL;
  foreach ($all_expected as $name => $expected) {

    // Populate defaults.
    $expected += array(
      'type' => 'module',
      'name' => $name,
      'version' => $fusion_apply_module_version,
    );
    $expected += array(
      'path' => drupal_get_path($expected['type'], $name),
      'directory' => NULL,
    );
    $this
      ->assertEqual($extensions[$name], $expected, t('%extension implementation found:<pre>@data</pre>', array(
      '%extension' => $name,
      '@data' => var_export($extensions[$name], TRUE),
    )));
    unset($extensions[$name]);
  }

  // Ensure that fusion_apply_test_incompatible is not contained.
  $this
    ->assertTrue(!isset($extensions['fusion_apply_test_incompatible']), 'Incompatible extension not found.');

  // After asserting all expected, the list of extensions should be empty.
  $this
    ->assertTrue(empty($extensions), 'No unexpected extensions found.');
}