function NodeCreationTest::getWatchdogIdsForTestExceptionRollback
Same name in other branches
- 8.9.x core/modules/node/tests/src/Functional/NodeCreationTest.php \Drupal\Tests\node\Functional\NodeCreationTest::getWatchdogIdsForTestExceptionRollback()
- 10 core/modules/node/tests/src/Functional/NodeCreationTest.php \Drupal\Tests\node\Functional\NodeCreationTest::getWatchdogIdsForTestExceptionRollback()
- 11.x core/modules/node/tests/src/Functional/NodeCreationTest.php \Drupal\Tests\node\Functional\NodeCreationTest::getWatchdogIdsForTestExceptionRollback()
Gets the watchdog IDs of the records with the rollback exception message.
Return value
int[] Array containing the IDs of the log records with the rollback exception message.
1 call to NodeCreationTest::getWatchdogIdsForTestExceptionRollback()
- NodeCreationTest::testFailedPageCreation in core/
modules/ node/ tests/ src/ Functional/ NodeCreationTest.php - Verifies that a transaction rolls back the failed creation.
File
-
core/
modules/ node/ tests/ src/ Functional/ NodeCreationTest.php, line 317
Class
- NodeCreationTest
- Create a node and test saving it.
Namespace
Drupal\Tests\node\FunctionalCode
protected static function getWatchdogIdsForTestExceptionRollback() {
// PostgreSQL doesn't support bytea LIKE queries, so we need to unserialize
// first to check for the rollback exception message.
$matches = [];
$query = Database::getConnection()->select('watchdog', 'w')
->fields('w', [
'wid',
'variables',
])
->execute();
foreach ($query as $row) {
$variables = (array) unserialize($row->variables);
if (isset($variables['@message']) && $variables['@message'] === 'Test exception for rollback.') {
$matches[] = $row->wid;
}
}
return $matches;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.