public function ModerationStateNodeTest::testFormSaveDestination in Workbench Moderation 8.2
Tests edit form destinations.
File
- src/
Tests/ ModerationStateNodeTest.php, line 70
Class
- ModerationStateNodeTest
- Tests general content moderation workflow for nodes.
Namespace
Drupal\workbench_moderation\TestsCode
public function testFormSaveDestination() {
// Create new moderated content in draft.
$this
->drupalPostForm('node/add/moderated_content', [
'title[0][value]' => 'Some moderated content',
'body[0][value]' => 'First version of the content.',
], t('Save and Create New Draft'));
$node = $this
->drupalGetNodeByTitle('Some moderated content');
$edit_path = sprintf('node/%d/edit', $node
->id());
// After saving, we should be at the canonical URL and viewing the first
// revision.
$this
->assertUrl(Url::fromRoute('entity.node.canonical', [
'node' => $node
->id(),
]));
$this
->assertText('First version of the content.');
// Update the draft to review; after saving, we should still be on the
// canonical URL, but viewing the second revision.
$this
->drupalPostForm($edit_path, [
'body[0][value]' => 'Second version of the content.',
], t('Save and Request Review'));
$this
->assertUrl(Url::fromRoute('entity.node.canonical', [
'node' => $node
->id(),
]));
$this
->assertText('Second version of the content.');
// Make a new published revision; after saving, we should be at the
// canonical URL.
$this
->drupalPostForm($edit_path, [
'body[0][value]' => 'Third version of the content.',
], t('Save and Publish'));
$this
->assertUrl(Url::fromRoute('entity.node.canonical', [
'node' => $node
->id(),
]));
$this
->assertText('Third version of the content.');
// Make a new forward revision; after saving, we should be on the "Latest
// version" tab.
$this
->drupalPostForm($edit_path, [
'body[0][value]' => 'Fourth version of the content.',
], t('Save and Create New Draft'));
$this
->assertUrl(Url::fromRoute('entity.node.latest_version', [
'node' => $node
->id(),
]));
$this
->assertText('Fourth version of the content.');
}