summaryrefslogtreecommitdiff
path: root/modules/simpletest
diff options
context:
space:
mode:
Diffstat (limited to 'modules/simpletest')
-rw-r--r--modules/simpletest/drupal_web_test_case.php32
-rw-r--r--modules/simpletest/tests/common.test4
-rw-r--r--modules/simpletest/tests/module.test33
3 files changed, 42 insertions, 27 deletions
diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php
index b2d5af76d..535e18b4c 100644
--- a/modules/simpletest/drupal_web_test_case.php
+++ b/modules/simpletest/drupal_web_test_case.php
@@ -632,18 +632,17 @@ class DrupalWebTestCase extends DrupalTestCase {
*
* @param $settings
* An associative array of settings to change from the defaults, keys are
- * node properties, for example 'body' => 'Hello, world!'.
+ * node properties, for example 'title' => 'Hello, world!'.
* @return
* Created node object.
*/
protected function drupalCreateNode($settings = array()) {
// Populate defaults array.
$settings += array(
- 'body' => $this->randomName(32),
+ 'body' => array(array()),
'title' => $this->randomName(8),
'comment' => 2,
'changed' => REQUEST_TIME,
- 'format' => FILTER_FORMAT_DEFAULT,
'moderate' => 0,
'promote' => 0,
'revision' => 1,
@@ -660,11 +659,6 @@ class DrupalWebTestCase extends DrupalTestCase {
$settings['date'] = format_date($settings['created'], 'custom', 'Y-m-d H:i:s O');
}
- // Add the default teaser.
- if (!isset($settings['teaser'])) {
- $settings['teaser'] = $settings['body'];
- }
-
// If the node's user uid is not specified manually, use the currently
// logged in user if available, or else the user running the test.
if (!isset($settings['uid'])) {
@@ -677,6 +671,13 @@ class DrupalWebTestCase extends DrupalTestCase {
}
}
+ // Merge body field value and format separately.
+ $body = array(
+ 'value' => $this->randomName(32),
+ 'format' => FILTER_FORMAT_DEFAULT
+ );
+ $settings['body'][0] += $body;
+
$node = (object) $settings;
node_save($node);
@@ -989,9 +990,18 @@ class DrupalWebTestCase extends DrupalTestCase {
$this->preloadRegistry();
// Add the specified modules to the list of modules in the default profile.
- $args = func_get_args();
- $modules = array_unique(array_merge(drupal_get_profile_modules('default', 'en'), $args));
- drupal_install_modules($modules, TRUE);
+ // Install the modules specified by the default profile.
+ $core_modules = drupal_get_profile_modules('default', 'en');
+ drupal_install_modules($core_modules, TRUE);
+
+ node_type_clear();
+
+ // Install additional modules one at a time in order to make sure that the
+ // list of modules is updated between each module's installation.
+ $modules = func_get_args();
+ foreach ($modules as $module) {
+ drupal_install_modules(array($module), TRUE);
+ }
// Because the schema is static cached, we need to flush
// it between each run. If we don't, then it will contain
diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test
index 6b767a527..4ea5cb4ce 100644
--- a/modules/simpletest/tests/common.test
+++ b/modules/simpletest/tests/common.test
@@ -261,9 +261,7 @@ class CascadingStylesheetsTestCase extends DrupalWebTestCase {
// Create a node, using the PHP filter that tests drupal_add_css().
$settings = array(
'type' => 'page',
- 'format' => 3, // PHP filter.
- 'body_format' => 3,
- 'body' => t('This tests the inline CSS!') . "<?php drupal_add_css('$css', 'inline'); ?>",
+ 'body' => array(array('value' => t('This tests the inline CSS!') . "<?php drupal_add_css('$css', 'inline'); ?>", 'format' => 3)), // PHP filter.
'promote' => 1,
);
$node = $this->drupalCreateNode($settings);
diff --git a/modules/simpletest/tests/module.test b/modules/simpletest/tests/module.test
index 87f1a1544..f42753f58 100644
--- a/modules/simpletest/tests/module.test
+++ b/modules/simpletest/tests/module.test
@@ -22,19 +22,24 @@ class ModuleUnitTest extends DrupalWebTestCase {
* The basic functionality of module_list().
*/
function testModuleList() {
- $base_module_list = drupal_get_profile_modules('default', 'en');
- // Key the list by module name.
- $base_module_list = array_combine($base_module_list, $base_module_list);
- // All default profile modules have a weight equal to 0, the default sort
- // order is thus simply alphabetical.
- ksort($base_module_list);
- $this->assertModuleList($base_module_list, t('Default profile'));
+ // Build a list of modules filenames.
+ $base_module_list = array();
+ foreach (drupal_get_profile_modules('default', 'en') as $module) {
+ $base_module_list[$module] = drupal_get_path('module', $module);
+ }
+ asort($base_module_list);
+ // Build a list of module names based on that order. Since all default
+ // profile modules have a weight equal to 0, the default sort order is
+ // simply alphabetical.
+ $module_list = array_keys($base_module_list);
+ $this->assertModuleList($module_list, t('Default profile'));
// Try to install a new module.
drupal_install_modules(array('path'));
- $base_module_list['path'] = 'path';
- ksort($base_module_list);
- $this->assertModuleList($base_module_list, t('After adding a module'));
+ $base_module_list['path'] = drupal_get_path('module', 'path');
+ asort($base_module_list);
+ $module_list = array_keys($base_module_list);
+ $this->assertModuleList($module_list, t('After adding a module'));
// Try to mess with the module weights.
db_update('system')
@@ -46,8 +51,9 @@ class ModuleUnitTest extends DrupalWebTestCase {
module_list(TRUE);
// Move path at the end of the array.
unset($base_module_list['path']);
- $base_module_list['path'] = 'path';
- $this->assertModuleList($base_module_list, t('After changing weights'));
+ $base_module_list['path'] = drupal_get_path('module', 'path');
+ $module_list = array_keys($base_module_list);
+ $this->assertModuleList($module_list, t('After changing weights'));
// Test the fixed list feature.
$fixed_list = array(
@@ -60,7 +66,7 @@ class ModuleUnitTest extends DrupalWebTestCase {
// Reset the module list.
module_list(TRUE);
- $this->assertModuleList($base_module_list, t('After reset'));
+ $this->assertModuleList($module_list, t('After reset'));
}
/**
@@ -70,6 +76,7 @@ class ModuleUnitTest extends DrupalWebTestCase {
* The expected values, sorted by weight and file name.
*/
protected function assertModuleList(Array $expected_values, $condition) {
+ $expected_values = array_combine($expected_values, $expected_values);
$this->assertIdentical($expected_values, module_list(), t('@condition: module_list() returns correct results', array('@condition' => $condition)));
ksort($expected_values);
$this->assertIdentical($expected_values, module_list(FALSE, TRUE), t('@condition: module_list() returns correctly sorted results', array('@condition' => $condition)));