function TrackChangesTest::termExists

Same name in other branches
  1. 9 core/modules/migrate/tests/src/Kernel/TrackChangesTest.php \Drupal\Tests\migrate\Kernel\TrackChangesTest::termExists()
  2. 8.9.x core/modules/migrate/tests/src/Kernel/TrackChangesTest.php \Drupal\Tests\migrate\Kernel\TrackChangesTest::termExists()
  3. 11.x core/modules/migrate/tests/src/Kernel/TrackChangesTest.php \Drupal\Tests\migrate\Kernel\TrackChangesTest::termExists()

Checks if term with given name exists.

Parameters

string $property: Property to evaluate.

string $value: Value to evaluate.

Return value

bool

2 calls to TrackChangesTest::termExists()
TrackChangesTest::assertTermDoesNotExist in core/modules/migrate/tests/src/Kernel/TrackChangesTest.php
Assert that term with given title does not exist.
TrackChangesTest::assertTermExists in core/modules/migrate/tests/src/Kernel/TrackChangesTest.php
Assert that term with given name exists.

File

core/modules/migrate/tests/src/Kernel/TrackChangesTest.php, line 229

Class

TrackChangesTest
Tests migration track changes property.

Namespace

Drupal\Tests\migrate\Kernel

Code

protected function termExists($property, $value) {
    $property = $property === 'description' ? 'description__value' : $property;
    $query = \Drupal::entityQuery('taxonomy_term')->accessCheck(FALSE);
    $result = $query->condition($property, $value)
        ->range(0, 1)
        ->execute();
    return !empty($result);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.