You are here

protected static function SupportTicketCreationTest::getWatchdogIdsForTestExceptionRollback in Support Ticketing System 8

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 SupportTicketCreationTest::getWatchdogIdsForTestExceptionRollback()
SupportTicketCreationTest::testFailedTicketCreation in modules/support_ticket/src/Tests/SupportTicketCreationTest.php
Verifies that a transaction rolls back the failed creation.

File

modules/support_ticket/src/Tests/SupportTicketCreationTest.php, line 207
Contains \Drupal\support_ticket\Tests\SupportTicketCreationTest.

Class

SupportTicketCreationTest
Create a support ticket and test saving it.

Namespace

Drupal\support_ticket\Tests

Code

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 = array();
  $query = db_query("SELECT wid, variables FROM {watchdog}");
  foreach ($query as $row) {
    $variables = (array) unserialize($row->variables);
    if (isset($variables['@message']) && $variables['@message'] === 'Test exception for rollback.') {
      $matches[] = $row->wid;
    }
  }
  return $matches;
}