You are here

public function TaggingTest::testExtenderHasAnyTag in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Database/TaggingTest.php \Drupal\KernelTests\Core\Database\TaggingTest::testExtenderHasAnyTag()

Tests extended query tagging for "has at least one of these tags".

File

core/tests/Drupal/KernelTests/Core/Database/TaggingTest.php, line 94

Class

TaggingTest
Tests the tagging capabilities of the Select builder.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testExtenderHasAnyTag() {
  $query = $this->connection
    ->select('test')
    ->extend(SelectExtender::class);
  $query
    ->addField('test', 'name');
  $query
    ->addField('test', 'age', 'age');
  $query
    ->addTag('test');
  $this
    ->assertTrue($query
    ->hasAnyTag('test', 'other'), 'hasAnyTag() returned true.');
  $this
    ->assertFalse($query
    ->hasAnyTag('other', 'stuff'), 'hasAnyTag() returned false.');
}