You are here

public function TransactionTest::assertRowAbsent in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php \Drupal\KernelTests\Core\Database\TransactionTest::assertRowAbsent()
  2. 10 core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php \Drupal\KernelTests\Core\Database\TransactionTest::assertRowAbsent()

Asserts that a given row is absent from the test table.

Parameters

$name: The name of the row.

$message: The message to log for the assertion.

2 calls to TransactionTest::assertRowAbsent()
TransactionTest::testTransactionStacking in core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php
Tests transaction stacking, commit, and rollback.
TransactionTest::testTransactionWithDdlStatement in core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php
Tests the compatibility of transactions with DDL statements.

File

core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php, line 340

Class

TransactionTest
Tests the transaction abstraction system.

Namespace

Drupal\KernelTests\Core\Database

Code

public function assertRowAbsent($name, $message = NULL) {
  if (!isset($message)) {
    $message = new FormattableMarkup('Row %name is absent.', [
      '%name' => $name,
    ]);
  }
  $present = (bool) $this->connection
    ->query('SELECT 1 FROM {test} WHERE [name] = :name', [
    ':name' => $name,
  ])
    ->fetchField();
  $this
    ->assertFalse($present, $message);
}