summaryrefslogtreecommitdiff
path: root/modules/node/node.test
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2009-11-19 04:00:47 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2009-11-19 04:00:47 +0000
commitcb98091e1b677476b873dd3d557200576b32559e (patch)
tree29c602772b3bf757ec0530ec90c4aa334f14193c /modules/node/node.test
parentbf703452de025483a9a8b8721068f28edcf81893 (diff)
downloadbrdo-cb98091e1b677476b873dd3d557200576b32559e.tar.gz
brdo-cb98091e1b677476b873dd3d557200576b32559e.tar.bz2
#108818 by David Strauss, chx, Crell: Add transactions to key X_save() routines.
Diffstat (limited to 'modules/node/node.test')
-rw-r--r--modules/node/node.test34
1 files changed, 33 insertions, 1 deletions
diff --git a/modules/node/node.test b/modules/node/node.test
index 807dc5f65..2fd36a97c 100644
--- a/modules/node/node.test
+++ b/modules/node/node.test
@@ -329,7 +329,8 @@ class PageCreationTestCase extends DrupalWebTestCase {
}
function setUp() {
- parent::setUp();
+ // Enable dummy module that implements hook_node_post_save for exceptions.
+ parent::setUp('node_test_exception');
$web_user = $this->drupalCreateUser(array('create page content', 'edit own page content'));
$this->drupalLogin($web_user);
@@ -353,6 +354,37 @@ class PageCreationTestCase extends DrupalWebTestCase {
$node = $this->drupalGetNodeByTitle($edit["title[$langcode][0][value]"]);
$this->assertTrue($node, t('Node found in database.'));
}
+
+ /**
+ * Create a page node and verify that a transaction rolls back the failed creation
+ */
+ function testFailedPageCreation() {
+ // Create a node.
+ $edit = array();
+ $langcode = FIELD_LANGUAGE_NONE;
+ $edit["title[$langcode][0][value]"] = 'testing_transaction_exception';
+ $edit["body[$langcode][0][value]"] = $this->randomName(16);
+ $this->drupalPost('node/add/page', $edit, t('Save'));
+
+ if (Database::getConnection()->supportsTransactions()) {
+ // Check that the node does not exist in the database.
+ $node = $this->drupalGetNodeByTitle($edit["title[$langcode][0][value]"]);
+ $this->assertFalse($node, t('Transactions supported, and node not found in database.'));
+ }
+ else {
+ // Check that the node exists in the database.
+ $node = $this->drupalGetNodeByTitle($edit["title[$langcode][0][value]"]);
+ $this->assertTrue($node, t('Transactions not supported, and node found in database.'));
+
+ // Check that the failed rollback was logged.
+ $records = db_query("SELECT wid FROM {watchdog} WHERE message LIKE 'Explicit rollback failed%'")->fetchAll();
+ $this->assertTrue(count($records) > 0, t('Transactions not supported, and rollback error logged to watchdog.'));
+ }
+
+ // Check that the rollback error was logged.
+ $records = db_query("SELECT wid FROM {watchdog} WHERE message LIKE 'Test exception for rollback.'")->fetchAll();
+ $this->assertTrue(count($records) > 0, t('Rollback explanatory error logged to watchdog.'));
+ }
}
class PageViewTestCase extends DrupalWebTestCase {