You are here

private function IntegrationTest::mergeAintoB in Term Merge 8

Merges term A into term B.

Parameters

\Drupal\taxonomy\TermInterface $a: Term A.

\Drupal\taxonomy\TermInterface $b: Term B.

Throws

\Behat\Mink\Exception\ElementNotFoundException

\Behat\Mink\Exception\ExpectationException

\Behat\Mink\Exception\ResponseTextException

2 calls to IntegrationTest::mergeAintoB()
IntegrationTest::testMergeSucceeds in tests/src/Functional/IntegrationTest.php
Tests that a simple merge succeeds.
IntegrationTest::testRegression2976174 in tests/src/Functional/IntegrationTest.php
Tests that a merge with multiple references succeeds.

File

tests/src/Functional/IntegrationTest.php, line 59

Class

IntegrationTest
Tests the Term Merge module.

Namespace

Drupal\Tests\term_merge\Functional

Code

private function mergeAintoB(TermInterface $a, TermInterface $b) {
  $this
    ->drupalGet("/admin/structure/taxonomy/manage/{$this->vocabulary->id()}/merge");
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->getSession()
    ->getPage()
    ->selectFieldOption('Terms to merge', $a
    ->id());
  $this
    ->getSession()
    ->getPage()
    ->pressButton('Merge');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->getSession()
    ->getPage()
    ->selectFieldOption('Existing term', $b
    ->id());
  $this
    ->getSession()
    ->getPage()
    ->pressButton('Submit');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->pageTextContains("You are about to merge 1 terms into existing term {$b->label()}. This action can't be undone. Are you sure you wish to continue with merging the terms below?");
  $this
    ->getSession()
    ->getPage()
    ->pressButton('Confirm merge');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->pageTextContains("Successfully merged 1 terms into {$b->label()}");

  // The message below is printed to the screen by an event subscriber
  // located in the term_merge_test_events test module.
  $this
    ->assertSession()
    ->pageTextContains('The TermsMergedEvent was triggered.');
}