diff options
-rw-r--r-- | modules/comment/comment.test | 18 | ||||
-rw-r--r-- | modules/simpletest/drupal_web_test_case.php | 35 | ||||
-rw-r--r-- | modules/user/user.test | 24 |
3 files changed, 44 insertions, 33 deletions
diff --git a/modules/comment/comment.test b/modules/comment/comment.test index 6fd91907f..8a4373ef1 100644 --- a/modules/comment/comment.test +++ b/modules/comment/comment.test @@ -17,15 +17,17 @@ class CommentHelperCase extends DrupalWebTestCase { /** * Post comment. * - * @param object $node Node to post comment on. - * @param string $comment Comment body. - * @param string $subject Comment subject. - * @param mixed $contact Set to NULL for no contact info, TRUE to ignore success checking, and array of values to set contact info. - * - * This needs to be static to be invoked via CommentHelperCase::postComment() - * in other tests. + * @param $node + * Node to post comment on. + * @param $comment + * Comment body. + * @param $subject + * Comment subject. + * @param $contact + * Set to NULL for no contact info, TRUE to ignore success checking, and + * array of values to set contact info. */ - public static function postComment($node, $comment, $subject = '', $contact = NULL) { + function postComment($node, $comment, $subject = '', $contact = NULL) { $edit = array(); $edit['comment'] = $comment; diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php index 09c192376..646eb64b4 100644 --- a/modules/simpletest/drupal_web_test_case.php +++ b/modules/simpletest/drupal_web_test_case.php @@ -430,20 +430,22 @@ abstract class DrupalTestCase { * @see set_error_handler */ public function errorHandler($severity, $message, $file = NULL, $line = NULL) { - $error_map = array( - E_STRICT => 'Run-time notice', - E_WARNING => 'Warning', - E_NOTICE => 'Notice', - E_CORE_ERROR => 'Core error', - E_CORE_WARNING => 'Core warning', - E_USER_ERROR => 'User error', - E_USER_WARNING => 'User warning', - E_USER_NOTICE => 'User notice', - E_RECOVERABLE_ERROR => 'Recoverable error', - ); + if ($severity & error_reporting()) { + $error_map = array( + E_STRICT => 'Run-time notice', + E_WARNING => 'Warning', + E_NOTICE => 'Notice', + E_CORE_ERROR => 'Core error', + E_CORE_WARNING => 'Core warning', + E_USER_ERROR => 'User error', + E_USER_WARNING => 'User warning', + E_USER_NOTICE => 'User notice', + E_RECOVERABLE_ERROR => 'Recoverable error', + ); - $backtrace = debug_backtrace(); - $this->error($message, $error_map[$severity], _drupal_get_last_caller($backtrace)); + $backtrace = debug_backtrace(); + $this->error($message, $error_map[$severity], _drupal_get_last_caller($backtrace)); + } return TRUE; } @@ -536,11 +538,6 @@ class DrupalUnitTestCase extends DrupalTestCase { $this->originalPrefix = $db_prefix; $this->originalFileDirectory = file_directory_path(); - // Log fatal errors. - ini_set('log_errors', 1); - // Make all errors visible. - error_reporting(E_ALL); - // Reset all statics so that test is performed with a clean environment. drupal_static_reset(); @@ -1057,8 +1054,6 @@ class DrupalWebTestCase extends DrupalTestCase { // Log fatal errors. ini_set('log_errors', 1); ini_set('error_log', $directory . '/error.log'); - // Make all errors visible. - error_reporting(E_ALL); // Reset all statics so that test is performed with a clean environment. drupal_static_reset(); diff --git a/modules/user/user.test b/modules/user/user.test index 1365f2f6e..975324b45 100644 --- a/modules/user/user.test +++ b/modules/user/user.test @@ -302,6 +302,9 @@ class UserLoginTestCase extends DrupalWebTestCase { } } +/** + * Test cancelling a user. + */ class UserCancelTestCase extends DrupalWebTestCase { public static function getInfo() { return array( @@ -311,6 +314,10 @@ class UserCancelTestCase extends DrupalWebTestCase { ); } + function setUp() { + parent::setUp('comment'); + } + /** * Attempt to cancel account without permission. */ @@ -521,7 +528,7 @@ class UserCancelTestCase extends DrupalWebTestCase { variable_set('user_cancel_method', 'user_cancel_delete'); // Create a user. - $account = $this->drupalCreateUser(array('cancel account')); + $account = $this->drupalCreateUser(array('cancel account', 'post comments', 'post comments without approval')); $this->drupalLogin($account); // Load real user object. $account = user_load($account->uid, TRUE); @@ -530,9 +537,16 @@ class UserCancelTestCase extends DrupalWebTestCase { $node = $this->drupalCreateNode(array('uid' => $account->uid)); // Create comment. - module_load_include('test', 'comment'); - $comment = CommentHelperCase::postComment($node, $this->randomName(32), '', TRUE); - $this->assertTrue(comment_load($comment->id), t('Comment found.')); + $edit = array( + 'subject' => $this->randomString(), + 'comment' => $this->randomString(), + ); + $this->drupalPost('comment/reply/' . $node->nid, $edit, t('Preview')); + $this->drupalPost(NULL, array(), t('Save')); + $this->assertText(t('Your comment has been posted.')); + $comments = comment_load_multiple(array(), array('subject' => $edit['subject'])); + $comment = reset($comments); + $this->assertTrue($comment->cid, t('Comment found.')); // Create a node with two revisions, the initial one belonging to the // cancelling user. @@ -562,7 +576,7 @@ class UserCancelTestCase extends DrupalWebTestCase { $this->assertFalse(node_load($node->nid, NULL, TRUE), t('Node of the user has been deleted.')); $this->assertFalse(node_load($node->nid, $revision, TRUE), t('Node revision of the user has been deleted.')); $this->assertTrue(node_load($revision_node->nid, NULL, TRUE), t("Current revision of the user's node was not deleted.")); - $this->assertFalse(comment_load($comment->id), t('Comment of the user has been deleted.')); + $this->assertFalse(comment_load($comment->cid), t('Comment of the user has been deleted.')); // Confirm that user is logged out. $this->assertNoText($account->name, t('Logged out.')); |