1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Tests for variable.module.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* Helper class for module test cases.
|
10 |
|
|
*/
|
11 |
|
|
class VariableTestCase extends DrupalWebTestCase {
|
12 |
|
|
protected $admin_user;
|
13 |
|
|
|
14 |
|
|
public static function getInfo() {
|
15 |
|
|
return array(
|
16 |
|
|
'name' => 'Test Variable API',
|
17 |
|
|
'description' => 'Exercise the Variable API, default values, save and delete variables, etc.',
|
18 |
|
|
'group' => 'Variable',
|
19 |
|
|
);
|
20 |
|
|
}
|
21 |
|
|
|
22 |
|
|
function setUp() {
|
23 |
|
|
parent::setUp('variable', 'variable_admin');
|
24 |
|
|
|
25 |
|
|
$this->admin_user = $this->drupalCreateUser(array('access administration pages', 'administer site configuration'));
|
26 |
|
|
$this->drupalLogin($this->admin_user);
|
27 |
|
|
}
|
28 |
|
|
|
29 |
|
|
/**
|
30 |
|
|
* Test that all core modules can be enabled, disabled and uninstalled.
|
31 |
|
|
*/
|
32 |
|
|
function testVariableAPI() {
|
33 |
|
|
// Check default values, set, get, delete.
|
34 |
|
|
$this->assertEqual(variable_get_value('site_name'), 'Drupal', 'Function variable_get_value() returns proper default values.');
|
35 |
|
|
$name = 'My test site';
|
36 |
|
|
variable_set_value('site_name', $name);
|
37 |
|
|
$this->assertTrue(variable_get('site_name'), 'Variable has been set using Variable API.');
|
38 |
|
|
$this->drupalGet('');
|
39 |
|
|
$this->assertText($name, 'Site name set with variable_set_value() is displayed.');
|
40 |
|
|
variable_delete('site_name');
|
41 |
|
|
$this->assertFalse(variable_get('site_name'), 'Variable has been deleted using Variable API.');
|
42 |
|
|
$this->assertEqual(variable_get_value('site_name'), 'Drupal', 'Variable has been reset to its default value.');
|
43 |
|
|
// Find variable information and specific variable in module and group list
|
44 |
|
|
$variable = variable_get_info('site_name');
|
45 |
|
|
$this->assertEqual($variable['title'], t('Site name'), 'Variable information can be retrieved for specific variable.');
|
46 |
|
|
// Check our admin pages just to make sure all variable widgets are properly displayed.
|
47 |
|
|
$this->drupalGet('admin/config/system/variable');
|
48 |
|
|
$this->drupalGet('admin/config/system/variable/module');
|
49 |
|
|
$this->drupalGet('admin/config/system/variable/edit/site_name');
|
50 |
|
|
}
|
51 |
|
|
|
52 |
|
|
|
53 |
|
|
} |