You are here

public function TaxonomyUniqueTest::testDuplicateTermWithTuEnabled in Taxonomy unique 8.2

Tests the basic functionality with taxonomy_unique turned on in the vocabulary settings.

File

tests/src/Kernel/TaxonomyUniqueTest.php, line 36

Class

TaxonomyUniqueTest
Tests for taxonomy unique module.

Namespace

Drupal\Tests\taxonomy_unique\Kernel

Code

public function testDuplicateTermWithTuEnabled() {
  $vocabulary = $this
    ->createVocabulary();
  $GLOBALS['config']['taxonomy_unique.settings'] = [
    $vocabulary
      ->id() => TRUE,
  ];
  $t1 = $this
    ->createTerm($vocabulary, [
    'name' => 'Term 1',
  ]);
  $t1_violations = $t1
    ->validate();
  $this
    ->assertEquals(0, $t1_violations
    ->count());
  $t2 = $this
    ->createTerm($vocabulary, [
    'name' => 'Term 1',
  ]);
  $t2_violations = $t2
    ->validate();
  $this
    ->assertEquals(1, $t2_violations
    ->count());
  $t3 = $this
    ->createTerm($vocabulary, [
    'name' => 'Term 2',
  ]);
  $t3_violations = $t3
    ->validate();
  $this
    ->assertEquals(0, $t3_violations
    ->count());
}