diff options
author | Dries Buytaert <dries@buytaert.net> | 2011-02-28 20:36:37 -0500 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2011-02-28 20:36:37 -0500 |
commit | 768208f8ddb2d03bc1e6d484ecac6e78c5fa75a8 (patch) | |
tree | f7f428f07922e354fe47f169605e67d581c5f1ed /modules | |
parent | 540ee5f4400e33bb202835b61bdefc7f7a280d82 (diff) | |
download | brdo-768208f8ddb2d03bc1e6d484ecac6e78c5fa75a8.tar.gz brdo-768208f8ddb2d03bc1e6d484ecac6e78c5fa75a8.tar.bz2 |
- Patch #1076394 by pillarsdotnet: improved test code.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/comment/comment.test | 6 | ||||
-rw-r--r-- | modules/file/tests/file.test | 4 | ||||
-rw-r--r-- | modules/node/node.test | 4 | ||||
-rw-r--r-- | modules/poll/poll.test | 4 | ||||
-rw-r--r-- | modules/statistics/statistics.test | 2 | ||||
-rw-r--r-- | modules/system/system.test | 14 | ||||
-rw-r--r-- | modules/taxonomy/taxonomy.test | 10 | ||||
-rw-r--r-- | modules/user/user.test | 4 |
8 files changed, 24 insertions, 24 deletions
diff --git a/modules/comment/comment.test b/modules/comment/comment.test index b8fe105e3..26e9b283e 100644 --- a/modules/comment/comment.test +++ b/modules/comment/comment.test @@ -1698,7 +1698,7 @@ class CommentTokenReplaceTestCase extends CommentHelperCase { foreach ($tests as $input => $expected) { $output = token_replace($input, array('comment' => $comment), array('language' => $language)); - $this->assertFalse(strcmp($output, $expected), t('Sanitized comment token %token replaced.', array('%token' => $input))); + $this->assertEqual($output, $expected, t('Sanitized comment token %token replaced.', array('%token' => $input))); } // Generate and test unsanitized tokens. @@ -1714,7 +1714,7 @@ class CommentTokenReplaceTestCase extends CommentHelperCase { foreach ($tests as $input => $expected) { $output = token_replace($input, array('comment' => $comment), array('language' => $language, 'sanitize' => FALSE)); - $this->assertFalse(strcmp($output, $expected), t('Unsanitized comment token %token replaced.', array('%token' => $input))); + $this->assertEqual($output, $expected, t('Unsanitized comment token %token replaced.', array('%token' => $input))); } // Load node so comment_count gets computed. @@ -1727,7 +1727,7 @@ class CommentTokenReplaceTestCase extends CommentHelperCase { foreach ($tests as $input => $expected) { $output = token_replace($input, array('node' => $node), array('language' => $language)); - $this->assertFalse(strcmp($output, $expected), t('Node comment token %token replaced.', array('%token' => $input))); + $this->assertEqual($output, $expected, t('Node comment token %token replaced.', array('%token' => $input))); } } } diff --git a/modules/file/tests/file.test b/modules/file/tests/file.test index c8d8b3718..99f95b42f 100644 --- a/modules/file/tests/file.test +++ b/modules/file/tests/file.test @@ -1026,7 +1026,7 @@ class FileTokenReplaceTestCase extends FileFieldTestCase { foreach ($tests as $input => $expected) { $output = token_replace($input, array('file' => $file), array('language' => $language)); - $this->assertFalse(strcmp($output, $expected), t('Sanitized file token %token replaced.', array('%token' => $input))); + $this->assertEqual($output, $expected, t('Sanitized file token %token replaced.', array('%token' => $input))); } // Generate and test unsanitized tokens. @@ -1038,7 +1038,7 @@ class FileTokenReplaceTestCase extends FileFieldTestCase { foreach ($tests as $input => $expected) { $output = token_replace($input, array('file' => $file), array('language' => $language, 'sanitize' => FALSE)); - $this->assertFalse(strcmp($output, $expected), t('Unsanitized file token %token replaced.', array('%token' => $input))); + $this->assertEqual($output, $expected, t('Unsanitized file token %token replaced.', array('%token' => $input))); } } } diff --git a/modules/node/node.test b/modules/node/node.test index b2ee715c3..8a871c0c7 100644 --- a/modules/node/node.test +++ b/modules/node/node.test @@ -2130,7 +2130,7 @@ class NodeTokenReplaceTestCase extends DrupalWebTestCase { foreach ($tests as $input => $expected) { $output = token_replace($input, array('node' => $node), array('language' => $language)); - $this->assertFalse(strcmp($output, $expected), t('Sanitized node token %token replaced.', array('%token' => $input))); + $this->assertEqual($output, $expected, t('Sanitized node token %token replaced.', array('%token' => $input))); } // Generate and test unsanitized tokens. @@ -2142,7 +2142,7 @@ class NodeTokenReplaceTestCase extends DrupalWebTestCase { foreach ($tests as $input => $expected) { $output = token_replace($input, array('node' => $node), array('language' => $language, 'sanitize' => FALSE)); - $this->assertFalse(strcmp($output, $expected), t('Unsanitized node token %token replaced.', array('%token' => $input))); + $this->assertEqual($output, $expected, t('Unsanitized node token %token replaced.', array('%token' => $input))); } } } diff --git a/modules/poll/poll.test b/modules/poll/poll.test index 3ac5aefc2..6fabf9567 100644 --- a/modules/poll/poll.test +++ b/modules/poll/poll.test @@ -652,7 +652,7 @@ class PollTokenReplaceTestCase extends PollTestCase { foreach ($tests as $input => $expected) { $output = token_replace($input, array('node' => $poll), array('language' => $language)); - $this->assertFalse(strcmp($output, $expected), t('Sanitized poll token %token replaced.', array('%token' => $input))); + $this->assertEqual($output, $expected, t('Sanitized poll token %token replaced.', array('%token' => $input))); } // Generate and test unsanitized tokens. @@ -660,7 +660,7 @@ class PollTokenReplaceTestCase extends PollTestCase { foreach ($tests as $input => $expected) { $output = token_replace($input, array('node' => $poll), array('language' => $language, 'sanitize' => FALSE)); - $this->assertFalse(strcmp($output, $expected), t('Unsanitized poll token %token replaced.', array('%token' => $input))); + $this->assertEqual($output, $expected, t('Unsanitized poll token %token replaced.', array('%token' => $input))); } } } diff --git a/modules/statistics/statistics.test b/modules/statistics/statistics.test index 026fcf58b..126828f4a 100644 --- a/modules/statistics/statistics.test +++ b/modules/statistics/statistics.test @@ -438,7 +438,7 @@ class StatisticsTokenReplaceTestCase extends StatisticsTestCase { foreach ($tests as $input => $expected) { $output = token_replace($input, array('node' => $node), array('language' => $language)); - $this->assertFalse(strcmp($output, $expected), t('Statistics token %token replaced.', array('%token' => $input))); + $this->assertEqual($output, $expected, t('Statistics token %token replaced.', array('%token' => $input))); } } } diff --git a/modules/system/system.test b/modules/system/system.test index 304556988..fb6a6e867 100644 --- a/modules/system/system.test +++ b/modules/system/system.test @@ -1575,13 +1575,13 @@ class TokenReplaceTestCase extends DrupalWebTestCase { // Test that the clear parameter cleans out non-existent tokens. $result = token_replace($source, array('node' => $node), array('language' => $language, 'clear' => TRUE)); - $result = $this->assertFalse(strcmp($target, $result), 'Valid tokens replaced while invalid tokens cleared out.'); + $result = $this->assertEqual($target, $result, 'Valid tokens replaced while invalid tokens cleared out.'); // Test without using the clear parameter (non-existant token untouched). $target .= '[user:name]'; $target .= '[bogus:token]'; $result = token_replace($source, array('node' => $node), array('language' => $language)); - $this->assertFalse(strcmp($target, $result), 'Valid tokens replaced while invalid tokens ignored.'); + $this->assertEqual($target, $result, 'Valid tokens replaced while invalid tokens ignored.'); // Check that the results of token_generate are sanitized properly. This does NOT // test the cleanliness of every token -- just that the $sanitize flag is being @@ -1589,10 +1589,10 @@ class TokenReplaceTestCase extends DrupalWebTestCase { // token, [node:title]. $raw_tokens = array('title' => '[node:title]'); $generated = token_generate('node', $raw_tokens, array('node' => $node)); - $this->assertFalse(strcmp($generated['[node:title]'], check_plain($node->title)), t('Token sanitized.')); + $this->assertEqual($generated['[node:title]'], check_plain($node->title), t('Token sanitized.')); $generated = token_generate('node', $raw_tokens, array('node' => $node), array('sanitize' => FALSE)); - $this->assertFalse(strcmp($generated['[node:title]'], $node->title), t('Unsanitized token generated properly.')); + $this->assertEqual($generated['[node:title]'], $node->title, t('Unsanitized token generated properly.')); } /** @@ -1624,7 +1624,7 @@ class TokenReplaceTestCase extends DrupalWebTestCase { foreach ($tests as $input => $expected) { $output = token_replace($input, array(), array('language' => $language)); - $this->assertFalse(strcmp($output, $expected), t('Sanitized system site information token %token replaced.', array('%token' => $input))); + $this->assertEqual($output, $expected, t('Sanitized system site information token %token replaced.', array('%token' => $input))); } // Generate and test unsanitized tokens. @@ -1633,7 +1633,7 @@ class TokenReplaceTestCase extends DrupalWebTestCase { foreach ($tests as $input => $expected) { $output = token_replace($input, array(), array('language' => $language, 'sanitize' => FALSE)); - $this->assertFalse(strcmp($output, $expected), t('Unsanitized system site information token %token replaced.', array('%token' => $input))); + $this->assertEqual($output, $expected, t('Unsanitized system site information token %token replaced.', array('%token' => $input))); } } @@ -1660,7 +1660,7 @@ class TokenReplaceTestCase extends DrupalWebTestCase { foreach ($tests as $input => $expected) { $output = token_replace($input, array('date' => $date), array('language' => $language)); - $this->assertFalse(strcmp($output, $expected), t('Date token %token replaced.', array('%token' => $input))); + $this->assertEqual($output, $expected, t('Date token %token replaced.', array('%token' => $input))); } } } diff --git a/modules/taxonomy/taxonomy.test b/modules/taxonomy/taxonomy.test index 1456af307..a6ac332dc 100644 --- a/modules/taxonomy/taxonomy.test +++ b/modules/taxonomy/taxonomy.test @@ -1107,7 +1107,7 @@ class TaxonomyTokenReplaceTestCase extends TaxonomyWebTestCase { foreach ($tests as $input => $expected) { $output = token_replace($input, array('term' => $term1), array('language' => $language)); - $this->assertFalse(strcmp($output, $expected), t('Sanitized taxonomy term token %token replaced.', array('%token' => $input))); + $this->assertEqual($output, $expected, t('Sanitized taxonomy term token %token replaced.', array('%token' => $input))); } // Generate and test sanitized tokens for term2. @@ -1127,7 +1127,7 @@ class TaxonomyTokenReplaceTestCase extends TaxonomyWebTestCase { foreach ($tests as $input => $expected) { $output = token_replace($input, array('term' => $term2), array('language' => $language)); - $this->assertFalse(strcmp($output, $expected), t('Sanitized taxonomy term token %token replaced.', array('%token' => $input))); + $this->assertEqual($output, $expected, t('Sanitized taxonomy term token %token replaced.', array('%token' => $input))); } // Generate and test unsanitized tokens. @@ -1138,7 +1138,7 @@ class TaxonomyTokenReplaceTestCase extends TaxonomyWebTestCase { foreach ($tests as $input => $expected) { $output = token_replace($input, array('term' => $term2), array('language' => $language, 'sanitize' => FALSE)); - $this->assertFalse(strcmp($output, $expected), t('Unsanitized taxonomy term token %token replaced.', array('%token' => $input))); + $this->assertEqual($output, $expected, t('Unsanitized taxonomy term token %token replaced.', array('%token' => $input))); } // Generate and test sanitized tokens. @@ -1154,7 +1154,7 @@ class TaxonomyTokenReplaceTestCase extends TaxonomyWebTestCase { foreach ($tests as $input => $expected) { $output = token_replace($input, array('vocabulary' => $this->vocabulary), array('language' => $language)); - $this->assertFalse(strcmp($output, $expected), t('Sanitized taxonomy vocabulary token %token replaced.', array('%token' => $input))); + $this->assertEqual($output, $expected, t('Sanitized taxonomy vocabulary token %token replaced.', array('%token' => $input))); } // Generate and test unsanitized tokens. @@ -1163,7 +1163,7 @@ class TaxonomyTokenReplaceTestCase extends TaxonomyWebTestCase { foreach ($tests as $input => $expected) { $output = token_replace($input, array('vocabulary' => $this->vocabulary), array('language' => $language, 'sanitize' => FALSE)); - $this->assertFalse(strcmp($output, $expected), t('Unsanitized taxonomy vocabulary token %token replaced.', array('%token' => $input))); + $this->assertEqual($output, $expected, t('Unsanitized taxonomy vocabulary token %token replaced.', array('%token' => $input))); } } } diff --git a/modules/user/user.test b/modules/user/user.test index 0dfb25b28..3c453a8b0 100644 --- a/modules/user/user.test +++ b/modules/user/user.test @@ -1904,7 +1904,7 @@ class UserTokenReplaceTestCase extends DrupalWebTestCase { foreach ($tests as $input => $expected) { $output = token_replace($input, array('user' => $account), array('language' => $language)); - $this->assertFalse(strcmp($output, $expected), t('Sanitized user token %token replaced.', array('%token' => $input))); + $this->assertEqual($output, $expected, t('Sanitized user token %token replaced.', array('%token' => $input))); } // Generate and test unsanitized tokens. @@ -1914,7 +1914,7 @@ class UserTokenReplaceTestCase extends DrupalWebTestCase { foreach ($tests as $input => $expected) { $output = token_replace($input, array('user' => $account), array('language' => $language, 'sanitize' => FALSE)); - $this->assertFalse(strcmp($output, $expected), t('Unsanitized user token %token replaced.', array('%token' => $input))); + $this->assertEqual($output, $expected, t('Unsanitized user token %token replaced.', array('%token' => $input))); } } } |