summaryrefslogtreecommitdiff
path: root/modules/node/node.test
diff options
context:
space:
mode:
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 {