public function SkinrApiTestCase::testSkinrImplementsAPI in Skinr 7.2
Tests skinr_implements().
File
- tests/
skinr.test, line 168 - Tests for the Skinr module.
Class
- SkinrApiTestCase
- Tests API functionality.
Code
public function testSkinrImplementsAPI() {
// Verify that skinr_implements() only returns extensions that are
// compatible with this version of Skinr.
$extensions = skinr_implements_api();
$this
->verbose(highlight_string('<?php ' . var_export($extensions, TRUE), TRUE));
// The expected extensions and their specific properties, if any.
$all_expected = array(
// Skinr is always expected.
'skinr' => array(
'include file' => drupal_get_path('module', 'skinr') . '/skinr.skinr.inc',
),
// System and node are required core modules, so always expected.
'system' => array(
'version' => VERSION,
'path' => drupal_get_path('module', 'skinr') . '/modules',
'include file' => drupal_get_path('module', 'skinr') . '/modules/system.skinr.inc',
),
'node' => array(
'version' => VERSION,
'path' => drupal_get_path('module', 'skinr') . '/modules',
'include file' => drupal_get_path('module', 'skinr') . '/modules/node.skinr.inc',
),
// skinr_test has been installed.
'skinr_test' => array(
'directory' => 'skins',
'include file' => drupal_get_path('module', 'skinr_test') . '/skinr_test.skinr.inc',
),
'skinr_test_basetheme' => array(
'type' => 'theme',
'api' => 2,
'directory' => 'skins',
'base themes' => array(),
'sub themes' => drupal_map_assoc(array(
'skinr_test_subtheme',
)),
'include file' => drupal_get_path('theme', 'skinr_test_basetheme') . '/skinr_test_basetheme.skinr.inc',
),
'skinr_test_subtheme' => array(
'type' => 'theme',
'api' => 2,
'directory' => 'skins',
'base themes' => drupal_map_assoc(array(
'skinr_test_basetheme',
)),
'sub themes' => array(),
'include file' => drupal_get_path('theme', 'skinr_test_subtheme') . '/skinr_test_subtheme.skinr.inc',
),
);
// When running tests on Skinr code packaged by drupal.org, all 'version'
// properties will have the version of the Skinr module. When running on a
// repository checkout, the version is NULL (undefined).
$skinr_module_info = system_get_info('module', 'skinr');
$skinr_module_version = !empty($skinr_module_info['version']) ? $skinr_module_info['version'] : NULL;
foreach ($all_expected as $name => $expected) {
// Populate defaults.
$expected += array(
'type' => 'module',
'name' => $name,
'version' => $skinr_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 skinr_test_incompatible is not contained.
$this
->assertTrue(!isset($extensions['skinr_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.');
}