Commit 768208f8 authored by Dries's avatar Dries

- Patch #1076394 by pillarsdotnet: improved test code.

parent 540ee5f4
......@@ -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)));
}
}
}
......
......@@ -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)));
}
}
}
......@@ -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)));
}
}
}
......@@ -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)));
}
}
}
......
......@@ -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)));
}
}
}
......@@ -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)));
}
}
}
......
......@@ -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)));
}
}
}
......
......@@ -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)));
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment