function TaxonomyTermContentModerationTest::testTaxonomyTermPendingRevisions
Same name in other branches
- 10 core/modules/taxonomy/tests/src/Functional/TaxonomyTermContentModerationTest.php \Drupal\Tests\taxonomy\Functional\TaxonomyTermContentModerationTest::testTaxonomyTermPendingRevisions()
Tests changing field values in pending revisions of taxonomy terms.
File
-
core/
modules/ taxonomy/ tests/ src/ Functional/ TaxonomyTermContentModerationTest.php, line 177
Class
- TaxonomyTermContentModerationTest
- Tests taxonomy terms with Content Moderation.
Namespace
Drupal\Tests\taxonomy\FunctionalCode
public function testTaxonomyTermPendingRevisions() : void {
$assert_session = $this->assertSession();
$default_term_name = 'term - default revision';
$default_term_description = 'The default revision of a term.';
$term = $this->createTerm($this->vocabulary, [
'name' => $default_term_name,
'description' => $default_term_description,
'langcode' => 'en',
'moderation_state' => 'published',
]);
// Add a pending revision without changing the term parent.
$this->drupalGet($term->toUrl('edit-form'));
$assert_session->pageTextContains($default_term_name);
$assert_session->pageTextContains($default_term_description);
// Check the revision log message field appears on the term edit page.
$this->drupalGet($term->toUrl('edit-form'));
$assert_session->fieldExists('revision_log_message[0][value]');
$pending_term_name = 'term - pending revision';
$pending_term_description = 'The pending revision of a term.';
$edit = [
'name[0][value]' => $pending_term_name,
'description[0][value]' => $pending_term_description,
'moderation_state[0][state]' => 'draft',
];
$this->drupalGet($term->toUrl('edit-form'));
$this->submitForm($edit, 'Save');
$assert_session->pageTextContains($pending_term_name);
$assert_session->pageTextContains($pending_term_description);
$assert_session->pageTextNotContains($default_term_description);
// Check that the default revision of the term contains the correct values.
$this->drupalGet('taxonomy/term/' . $term->id());
$assert_session->pageTextContains($default_term_name);
$assert_session->pageTextContains($default_term_description);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.