function TagsTest::assertTags

Same name and namespace in other branches
  1. 8.9.x 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));
  }
}

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