Skip to content

Instantly share code, notes, and snippets.

@sun
Created October 9, 2012 00:36
Show Gist options
  • Save sun/3855847 to your computer and use it in GitHub Desktop.
Save sun/3855847 to your computer and use it in GitHub Desktop.
ModuleEnable test
<?php
/**
* @file
* Contains Drupal\system\Tests\Module\ModuleEnable.
*/
namespace Drupal\system\Tests\Module;
use Drupal\simpletest\WebTestBase;
/**
* Tests module_enable().
*/
class ModuleEnable extends WebTestBase {
public static function getInfo() {
return array(
'name' => 'Module enable',
'description' => 'Tests module_enable().',
'group' => 'Module',
);
}
/**
* Tests two subsequent calls to module_enable() for the same module.
*/
function testSubsequentWithDependencies() {
$this->assertFalse(module_exists('module_test'));
module_enable(array('module_test'));
$this->assertTrue(module_exists('module_test'));
$this->assertIdentical(config('system.module')->get('enabled.module_test'), '0');
module_enable(array('module_test'));
$this->assertTrue(module_exists('module_test'));
$this->assertIdentical(config('system.module')->get('enabled.module_test'), '0');
}
/**
* Tests two subsequent calls to module_enable() for the same module.
*/
function testSubsequentWithoutDependencies() {
$this->assertFalse(module_exists('module_test'));
module_enable(array('module_test'), FALSE);
$this->assertTrue(module_exists('module_test'));
$this->assertIdentical(config('system.module')->get('enabled.module_test'), '0');
module_enable(array('module_test'), FALSE);
$this->assertTrue(module_exists('module_test'));
$this->assertIdentical(config('system.module')->get('enabled.module_test'), '0');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment