summaryrefslogtreecommitdiff
path: root/modules/simpletest
diff options
context:
space:
mode:
Diffstat (limited to 'modules/simpletest')
-rw-r--r--modules/simpletest/drupal_web_test_case.php8
-rw-r--r--modules/simpletest/simpletest.module3
-rw-r--r--modules/simpletest/tests/batch.test4
-rw-r--r--modules/simpletest/tests/image.test6
-rw-r--r--modules/simpletest/tests/module.test4
-rw-r--r--modules/simpletest/tests/registry.test42
-rw-r--r--modules/simpletest/tests/xmlrpc.test6
7 files changed, 57 insertions, 16 deletions
diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php
index 8ef61367a..c23081467 100644
--- a/modules/simpletest/drupal_web_test_case.php
+++ b/modules/simpletest/drupal_web_test_case.php
@@ -519,7 +519,7 @@ abstract class DrupalTestCase {
*
* These tests can not access the database nor files. Calling any Drupal
* function that needs the database will throw exceptions. These include
- * watchdog(), function_exists(), module_implements(),
+ * watchdog(), drupal_function_exists(), module_implements(),
* module_invoke_all() etc.
*/
class DrupalUnitTestCase extends DrupalTestCase {
@@ -549,7 +549,7 @@ class DrupalUnitTestCase extends DrupalTestCase {
if (isset($module_list['locale'])) {
$this->originalModuleList = $module_list;
unset($module_list['locale']);
- module_list(TRUE, FALSE, FALSE, $module_list);
+ module_list(TRUE, FALSE, $module_list);
}
}
@@ -561,7 +561,7 @@ class DrupalUnitTestCase extends DrupalTestCase {
$db_prefix = $this->originalPrefix;
// Restore modules if necessary.
if (isset($this->originalModuleList)) {
- module_list(TRUE, FALSE, FALSE, $this->originalModuleList);
+ module_list(TRUE, FALSE, $this->originalModuleList);
}
}
}
@@ -1203,7 +1203,7 @@ class DrupalWebTestCase extends DrupalTestCase {
// Reload module list and implementations to ensure that test module hooks
// aren't called after tests.
module_list(TRUE);
- module_implements('', FALSE, TRUE);
+ module_implements(MODULE_IMPLEMENTS_CLEAR_CACHE);
// Reset the Field API.
field_cache_clear();
diff --git a/modules/simpletest/simpletest.module b/modules/simpletest/simpletest.module
index af176b031..cbbd45388 100644
--- a/modules/simpletest/simpletest.module
+++ b/modules/simpletest/simpletest.module
@@ -31,7 +31,6 @@ function simpletest_menu() {
'page arguments' => array('simpletest_test_form'),
'description' => 'Run tests against Drupal core and your active modules. These tests help assure that your site code is working as designed.',
'access arguments' => array('administer unit tests'),
- 'file' => 'simpletest.pages.inc',
);
$items['admin/config/development/testing/list'] = array(
'title' => 'List',
@@ -43,7 +42,6 @@ function simpletest_menu() {
'page arguments' => array('simpletest_settings_form'),
'access arguments' => array('administer unit tests'),
'type' => MENU_LOCAL_TASK,
- 'file' => 'simpletest.pages.inc',
);
$items['admin/config/development/testing/results/%'] = array(
'title' => 'Test result',
@@ -52,7 +50,6 @@ function simpletest_menu() {
'description' => 'View result of tests.',
'access arguments' => array('administer unit tests'),
'type' => MENU_CALLBACK,
- 'file' => 'simpletest.pages.inc',
);
return $items;
}
diff --git a/modules/simpletest/tests/batch.test b/modules/simpletest/tests/batch.test
index a3ace7b9e..65c5309ff 100644
--- a/modules/simpletest/tests/batch.test
+++ b/modules/simpletest/tests/batch.test
@@ -69,6 +69,8 @@ class BatchAPIPercentagesTestCase extends DrupalWebTestCase {
* testCases class variable.
*/
function testBatchAPIPercentages() {
+ // Include batch.inc if it's not already included.
+ drupal_function_exists('_batch_api_percentage');
foreach ($this->testCases as $expected_result => $arguments) {
// PHP sometimes casts numeric strings that are array keys to integers,
// cast them back here.
@@ -84,4 +86,4 @@ class BatchAPIPercentagesTestCase extends DrupalWebTestCase {
}
}
}
-}
+} \ No newline at end of file
diff --git a/modules/simpletest/tests/image.test b/modules/simpletest/tests/image.test
index 3eeb602a8..7047576b6 100644
--- a/modules/simpletest/tests/image.test
+++ b/modules/simpletest/tests/image.test
@@ -255,7 +255,7 @@ class ImageToolkitGdTestCase extends DrupalWebTestCase {
*/
function testManipulations() {
// If GD isn't available don't bother testing this.
- if (!function_exists('image_gd_check_settings') || !image_gd_check_settings()) {
+ if (!drupal_function_exists('image_gd_check_settings') || !image_gd_check_settings()) {
$this->pass(t('Image manipulations for the GD toolkit were skipped because the GD toolkit is not available.'));
return;
}
@@ -325,7 +325,7 @@ class ImageToolkitGdTestCase extends DrupalWebTestCase {
);
// Systems using non-bundled GD2 don't have imagerotate. Test if available.
- if (function_exists('imagerotate')) {
+ if (drupal_function_exists('imagerotate')) {
$operations += array(
'rotate_5' => array(
'function' => 'rotate',
@@ -359,7 +359,7 @@ class ImageToolkitGdTestCase extends DrupalWebTestCase {
}
// Systems using non-bundled GD2 don't have imagefilter. Test if available.
- if (function_exists('imagefilter')) {
+ if (drupal_function_exists('imagefilter')) {
$operations += array(
'desaturate' => array(
'function' => 'desaturate',
diff --git a/modules/simpletest/tests/module.test b/modules/simpletest/tests/module.test
index a157c957a..5c703c287 100644
--- a/modules/simpletest/tests/module.test
+++ b/modules/simpletest/tests/module.test
@@ -60,7 +60,7 @@ class ModuleUnitTest extends DrupalWebTestCase {
'system' => array('filename' => drupal_get_path('module', 'system')),
'menu' => array('filename' => drupal_get_path('module', 'menu')),
);
- module_list(FALSE, FALSE, FALSE, $fixed_list);
+ module_list(FALSE, FALSE, $fixed_list);
$new_module_list = array_combine(array_keys($fixed_list), array_keys($fixed_list));
$this->assertModuleList($new_module_list, t('When using a fixed list'));
@@ -79,7 +79,7 @@ class ModuleUnitTest extends DrupalWebTestCase {
$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, FALSE, TRUE), t('@condition: module_list() returns correctly sorted results', array('@condition' => $condition)));
+ $this->assertIdentical($expected_values, module_list(FALSE, TRUE), t('@condition: module_list() returns correctly sorted results', array('@condition' => $condition)));
}
}
diff --git a/modules/simpletest/tests/registry.test b/modules/simpletest/tests/registry.test
index 09464922c..53ee3127f 100644
--- a/modules/simpletest/tests/registry.test
+++ b/modules/simpletest/tests/registry.test
@@ -12,6 +12,7 @@ class RegistryParseFileTestCase extends DrupalWebTestCase {
function setUp() {
$this->fileName = 'registry_test_' . md5(rand());
+ $this->functionName = 'registry_test_function' . md5(rand());
$this->className = 'registry_test_class' . md5(rand());
$this->interfaceName = 'registry_test_interface' . md5(rand());
parent::setUp();
@@ -22,7 +23,7 @@ class RegistryParseFileTestCase extends DrupalWebTestCase {
*/
function testRegistryParseFile() {
_registry_parse_file($this->fileName, $this->getFileContents());
- foreach (array('className', 'interfaceName') as $resource) {
+ foreach (array('functionName', 'className', 'interfaceName') as $resource) {
$foundName = db_query('SELECT name FROM {registry} WHERE name = :name', array(':name' => $this->$resource))->fetchField();
$this->assertTrue($this->$resource == $foundName, t('Resource "@resource" found.', array('@resource' => $this->$resource)));
}
@@ -35,6 +36,8 @@ class RegistryParseFileTestCase extends DrupalWebTestCase {
$file_contents = <<<CONTENTS
<?php
+function {$this->functionName}() {}
+
class {$this->className} {}
interface {$this->interfaceName} {}
@@ -63,6 +66,7 @@ class RegistryParseFilesTestCase extends DrupalWebTestCase {
foreach ($this->fileTypes as $fileType) {
$this->$fileType = new stdClass();
$this->$fileType->fileName = file_directory_path() . '/registry_test_' . md5(rand());
+ $this->$fileType->functionName = 'registry_test_function' . md5(rand());
$this->$fileType->className = 'registry_test_class' . md5(rand());
$this->$fileType->interfaceName = 'registry_test_interface' . md5(rand());
$this->$fileType->contents = $this->getFileContents($fileType);
@@ -78,7 +82,7 @@ class RegistryParseFilesTestCase extends DrupalWebTestCase {
->execute();
// Insert some fake resource records.
- foreach (array('class', 'interface') as $type) {
+ foreach (array('function', 'class', 'interface') as $type) {
db_insert('registry')
->fields(array(
'name' => $type . md5(rand()),
@@ -98,7 +102,7 @@ class RegistryParseFilesTestCase extends DrupalWebTestCase {
_registry_parse_files($this->getFiles());
foreach ($this->fileTypes as $fileType) {
// Test that we have all the right resources.
- foreach (array('className', 'interfaceName') as $resource) {
+ foreach (array('functionName', 'className', 'interfaceName') as $resource) {
$foundName = db_query('SELECT name FROM {registry} WHERE name = :name', array(':name' => $this->$fileType->$resource))->fetchField();
$this->assertTrue($this->$fileType->$resource == $foundName, t('Resource "@resource" found.', array('@resource' => $this->$fileType->$resource)));
}
@@ -131,6 +135,8 @@ class RegistryParseFilesTestCase extends DrupalWebTestCase {
$file_contents = <<<CONTENTS
<?php
+function {$this->$fileType->functionName}() {}
+
class {$this->$fileType->className} {}
interface {$this->$fileType->interfaceName} {}
@@ -140,3 +146,33 @@ CONTENTS;
}
}
+
+class RegistrySkipBodyTestCase extends DrupalUnitTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Skip function body test',
+ 'description' => 'Tokenize a simple function and check that the body is skipped right',
+ 'group' => 'System',
+ );
+ }
+
+ function testRegistrySkipBody() {
+ // This string contains all three kinds of opening braces.
+ $function = '<?php function foo () { $x = "{$y}"; $x = "${y}"; }';
+ $tokens = token_get_all($function);
+ require_once DRUPAL_ROOT . '/includes/registry.inc';
+ _registry_skip_body($tokens);
+ // Consume the last }
+ each($tokens);
+ $this->assertIdentical(each($tokens), FALSE, t('Tokens skipped'));
+
+ // Check workaround for PHP < 5.2.3 regarding tokenization of strings
+ // containing variables. The { contained in the string should not be
+ // treated as a separate token.
+ $function = '<?php function foo() { $x = "$y {"; $x = `$y {`; $x = ' . "<<<EOD\n\$y {\nEOD\n; } function bar() {}";
+ $tokens = token_get_all($function);
+ _registry_skip_body($tokens);
+ $this->assertTrue(each($tokens), t('Tokens not skipped to end of file.'));
+ }
+
+}
diff --git a/modules/simpletest/tests/xmlrpc.test b/modules/simpletest/tests/xmlrpc.test
index 232665a95..8cdaec1d5 100644
--- a/modules/simpletest/tests/xmlrpc.test
+++ b/modules/simpletest/tests/xmlrpc.test
@@ -12,6 +12,9 @@ class XMLRPCValidator1IncTestCase extends DrupalWebTestCase {
function setUp() {
parent::setUp('xmlrpc_test');
+
+ // Force loading the xmlrpc.inc to have the xmlrpc() function.
+ drupal_function_exists('xmlrpc');
}
/**
@@ -132,6 +135,9 @@ class XMLRPCMessagesTestCase extends DrupalWebTestCase {
function setUp() {
parent::setUp('xmlrpc_test');
+
+ // Force loading the xmlrpc.inc to have the xmlrpc() function.
+ drupal_function_exists('xmlrpc');
}
/**