diff options
Diffstat (limited to 'modules/simpletest/tests')
-rw-r--r-- | modules/simpletest/tests/batch.test | 4 | ||||
-rw-r--r-- | modules/simpletest/tests/image.test | 6 | ||||
-rw-r--r-- | modules/simpletest/tests/module.test | 4 | ||||
-rw-r--r-- | modules/simpletest/tests/registry.test | 42 | ||||
-rw-r--r-- | modules/simpletest/tests/xmlrpc.test | 6 |
5 files changed, 53 insertions, 9 deletions
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'); } /** |