diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-10-13 16:38:43 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-10-13 16:38:43 +0000 |
commit | fbfa7a4150a40d6df9347692bb6681f45f804c7d (patch) | |
tree | 425db0f6cc7b72b8a9350c5a462fe718e0ed2877 /modules/simpletest/tests/common.test | |
parent | f67e438b4196a6bc79c0da576da0a9e09fedb612 (diff) | |
download | brdo-fbfa7a4150a40d6df9347692bb6681f45f804c7d.tar.gz brdo-fbfa7a4150a40d6df9347692bb6681f45f804c7d.tar.bz2 |
- Patch #593522 by sun: a better and faster drupal_alter().
Diffstat (limited to 'modules/simpletest/tests/common.test')
-rw-r--r-- | modules/simpletest/tests/common.test | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test index 53d493210..55b4b4332 100644 --- a/modules/simpletest/tests/common.test +++ b/modules/simpletest/tests/common.test @@ -2,6 +2,59 @@ // $Id$ /** + * @file + * Tests for common.inc functionality. + */ + +/** + * Tests for URL generation functions. + */ +class DrupalAlterTestCase extends DrupalWebTestCase { + public static function getInfo() { + return array( + 'name' => 'drupal_alter() tests', + 'description' => 'Confirm that alteration of arguments passed to drupal_alter() works correctly.', + 'group' => 'System', + ); + } + + function setUp() { + parent::setUp('common_test'); + } + + function testDrupalAlter() { + $array = array('foo' => 'bar'); + $object = new stdClass; + $object->foo = 'bar'; + + // Verify alteration of a single argument. + $array_copy = $array; + $array_expected = array('foo' => 'Drupal'); + drupal_alter('drupal_alter', $array_copy); + $this->assertEqual($array_copy, $array_expected, t('Single array was altered.')); + + $object_copy = clone $object; + $object_expected = clone $object; + $object_expected->foo = 'Drupal'; + drupal_alter('drupal_alter', $object_copy); + $this->assertEqual($object_copy, $object_expected, t('Single object was altered.')); + + // Verify alteration of multiple arguments. + $array_copy = $array; + $array_expected = array('foo' => 'Drupal'); + $object_copy = clone $object; + $object_expected = clone $object; + $object_expected->foo = 'Drupal'; + $array2_copy = $array; + $array2_expected = array('foo' => 'Drupal'); + drupal_alter('drupal_alter', $array_copy, $object_copy, $array2_copy); + $this->assertEqual($array_copy, $array_expected, t('First argument to drupal_alter() was altered.')); + $this->assertEqual($object_copy, $object_expected, t('Second argument to drupal_alter() was altered.')); + $this->assertEqual($array2_copy, $array2_expected, t('Third argument to drupal_alter() was altered.')); + } +} + +/** * Tests for URL generation functions. */ class CommonURLUnitTest extends DrupalUnitTestCase { |