You are here

function SkinrApiTestCase::testSkinrImplements in Skinr 8.2

Test module_implements().

File

src/Tests/skinr.test, line 245
Tests for the Skinr module.

Class

SkinrApiTestCase
Tests API functionality.

Namespace

Drupal\tracker\Tests

Code

function testSkinrImplements() {

  // Test clearing cache.
  cache_clear_all('skinr_implements', 'cache_bootstrap');
  $this
    ->assertFalse(cache_get('skinr_implements', 'cache_bootstrap'), t('The skinr implements cache is empty.'));
  $this
    ->drupalGet('');
  $this
    ->assertTrue(cache_get('skinr_implements', 'cache_bootstrap'), t('The skinr implements cache is populated after requesting a page.'));

  // Test clearing cache with an authenticated user.
  $this->user = $this
    ->drupalCreateUser(array());
  $this
    ->drupalLogin($this->user);
  cache_clear_all('skinr_implements', 'cache_bootstrap');
  $this
    ->drupalGet('');
  $this
    ->assertTrue(cache_get('skinr_implements', 'cache_bootstrap'), t('The skinr implements cache is populated after requesting a page.'));

  // Make sure $module.skinr.inc files (both in the module root, which are
  // auto-loaded by drupal, and in custom paths and themes, which are
  // loaded by skinr_implements()) are loaded when the hook is called. Also
  // ensure only module that implement the current Skinr API are loaded.
  $modules = skinr_implements('skinr_skin_info');

  // Ensure the hook is found in includes.
  $this
    ->assertTrue(in_array('skinr_test', $modules), 'Hook found in $module.skinr.inc file auto-loaded by module_hook().');
  $this
    ->assertTrue(in_array('skinr_test_subtheme', $modules), 'Hook found in $module.skinr.inc file in custom path.');

  // Ensure that skinr_test_incompatible is not included.
  $this
    ->assertTrue(!in_array('skinr_test_incompatible', $modules), 'Hook in incompatible module not found.');
}