function TermTest::testReSavingTags
Same name and namespace in other branches
- 11.x core/modules/taxonomy/tests/src/Functional/TermTest.php \Drupal\Tests\taxonomy\Functional\TermTest::testReSavingTags()
- 10 core/modules/taxonomy/tests/src/Functional/TermTest.php \Drupal\Tests\taxonomy\Functional\TermTest::testReSavingTags()
- 9 core/modules/taxonomy/tests/src/Functional/TermTest.php \Drupal\Tests\taxonomy\Functional\TermTest::testReSavingTags()
- main core/modules/taxonomy/tests/src/Functional/TermTest.php \Drupal\Tests\taxonomy\Functional\TermTest::testReSavingTags()
Tests that editing and saving a node with no changes works correctly.
File
-
core/
modules/ taxonomy/ tests/ src/ Functional/ TermTest.php, line 558
Class
- TermTest
- Tests load, save and delete for taxonomy terms.
Namespace
Drupal\Tests\taxonomy\FunctionalCode
public function testReSavingTags() {
// Enable tags in the vocabulary.
$field = $this->field;
\Drupal::service('entity_display.repository')->getFormDisplay($field->getTargetEntityTypeId(), $field->getTargetBundle())
->setComponent($field->getName(), [
'type' => 'entity_reference_autocomplete_tags',
])
->save();
// Create a term and a node using it.
$term = $this->createTerm($this->vocabulary);
$edit = [];
$edit['title[0][value]'] = $this->randomMachineName(8);
$edit['body[0][value]'] = $this->randomMachineName(16);
$edit[$this->field
->getName() . '[target_id]'] = $term->getName();
$this->drupalPostForm('node/add/article', $edit, t('Save'));
// Check that the term is displayed when editing and saving the node with no
// changes.
$this->clickLink(t('Edit'));
$this->assertRaw($term->getName(), 'Term is displayed when editing the node.');
$this->drupalPostForm(NULL, [], t('Save'));
$this->assertRaw($term->getName(), 'Term is displayed after saving the node with no changes.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.