From ea2e91a320f48e069ab3ec9e280ac4c30fa084c7 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Wed, 18 Feb 2015 09:30:40 +0000 Subject: [PATCH] Issue #2426659 by chx: NodeCreationTest is not reusable --- .../node/src/Tests/NodeCreationTest.php | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/core/modules/node/src/Tests/NodeCreationTest.php b/core/modules/node/src/Tests/NodeCreationTest.php index 3caf0bd1d8f..96ee49a3a61 100644 --- a/core/modules/node/src/Tests/NodeCreationTest.php +++ b/core/modules/node/src/Tests/NodeCreationTest.php @@ -105,12 +105,12 @@ class NodeCreationTest extends NodeTestBase { $this->assertTrue($node, '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(); + $records = static::getWatchdogIdsForFailedExplicitRollback(); $this->assertTrue(count($records) > 0, 'Transactions not supported, and rollback error logged to watchdog.'); } // Check that the rollback error was logged. - $records = db_query("SELECT wid FROM {watchdog} WHERE variables LIKE '%Test exception for rollback.%'")->fetchAll(); + $records = static::getWatchdogIdsForTestExceptionRollback(); $this->assertTrue(count($records) > 0, 'Rollback explanatory error logged to watchdog.'); } @@ -185,4 +185,23 @@ class NodeCreationTest extends NodeTestBase { $this->assertLinkByHref('/admin/structure/types/add'); } + + /** + * Returns log records with the rollback exception message. + * + * @return array + */ + protected static function getWatchdogIdsForTestExceptionRollback() { + return db_query("SELECT wid FROM {watchdog} WHERE variables LIKE '%Test exception for rollback.%'")->fetchAll(); + } + + /** + * Returns log records with the explicit rollback failed exception message. + * + * @return array + */ + protected static function getWatchdogIdsForFailedExplicitRollback() { + return db_query("SELECT wid FROM {watchdog} WHERE message LIKE 'Explicit rollback failed%'")->fetchAll(); + } + }