public function IntegrationTest::testRegression2976174 in Term Merge 8
Tests that a merge with multiple references succeeds.
File
- tests/
src/ Functional/ IntegrationTest.php, line 89
Class
- IntegrationTest
- Tests the Term Merge module.
Namespace
Drupal\Tests\term_merge\FunctionalCode
public function testRegression2976174() {
$this
->createEntityReferenceField('node', $this->contentType
->id(), 'field_other_tags', 'Other tags', 'taxonomy_term', 'default', [], -1);
$this
->createEntityReferenceField('node', $this->contentType
->id(), 'field_empty_tags', 'Empty tags', 'taxonomy_term', 'default', [], -1);
$a = $this
->createTerm($this->vocabulary);
$b = $this
->createTerm($this->vocabulary);
$node = $this
->drupalCreateNode([
'type' => $this->contentType
->id(),
'field_tags' => [
[
'target_id' => $a
->id(),
],
[
'target_id' => $b
->id(),
],
],
'field_other_tags' => [
[
'target_id' => $a
->id(),
],
],
]);
$this
->mergeAintoB($a, $b);
/** @var \Drupal\node\NodeInterface $loadedNode */
$loadedNode = \Drupal::entityTypeManager()
->getStorage('node')
->load($node
->id());
$expected = [
[
'target_id' => $b
->id(),
],
];
$this
->assertEquals($expected, $loadedNode
->get('field_tags')
->getValue());
$this
->assertEquals($expected, $loadedNode
->get('field_other_tags')
->getValue());
$this
->assertTrue($loadedNode
->get('field_empty_tags')
->isEmpty());
}