You are here

public function TransactionTest::assertRowPresent in Drupal 10

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

Asserts that a given row is present in the test table.

@internal

Parameters

string $name: The name of the row.

string $message: The message to log for the assertion.

File

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

Class

TransactionTest
Tests the transaction abstraction system.

Namespace

Drupal\KernelTests\Core\Database

Code

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