You are here

protected function TagsTest::assertTags in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Common/TagsTest.php \Drupal\Tests\Core\Common\TagsTest::assertTags()
  2. 9 core/tests/Drupal/Tests/Core/Common/TagsTest.php \Drupal\Tests\Core\Common\TagsTest::assertTags()

Helper function: asserts that the ending array of tags is what we wanted.

@internal

2 calls to TagsTest::assertTags()
TagsTest::explodeTags in core/tests/Drupal/Tests/Core/Common/TagsTest.php
Explodes a series of tags.
TagsTest::testImplodeTags in core/tests/Drupal/Tests/Core/Common/TagsTest.php
Implodes a series of tags.

File

core/tests/Drupal/Tests/Core/Common/TagsTest.php, line 49

Class

TagsTest
Tests explosion and implosion of autocomplete tags.

Namespace

Drupal\Tests\Core\Common

Code

protected function assertTags(array $tags) : void {
  $original = $this->validTags;
  foreach ($tags as $tag) {
    $key = array_search($tag, $original);
    $this
      ->assertTrue((bool) $key, $tag, sprintf('Make sure tag %s shows up in the final tags array (originally %s)', $tag, $key));
    unset($original[$key]);
  }
  foreach ($original as $leftover) {
    $this
      ->fail(sprintf('Leftover tag %s was left over.', $leftover));
  }
}