public function ModerationStateNodeTest::testCreatingContent in Workbench Moderation 8
Tests creating and deleting content.
File
- tests/
src/ Functional/ ModerationStateNodeTest.php, line 32
Class
- ModerationStateNodeTest
- Tests general content moderation workflow for nodes.
Namespace
Drupal\Tests\workbench_moderation\FunctionalCode
public function testCreatingContent() {
$this
->drupalPostForm('node/add/moderated_content', [
'title[0][value]' => 'moderated content',
], t('Save and Create New Draft'));
$nodes = \Drupal::entityTypeManager()
->getStorage('node')
->loadByProperties([
'title' => 'moderated content',
]);
if (!$nodes) {
$this
->fail('Test node was not saved correctly.');
return;
}
$node = reset($nodes);
$path = 'node/' . $node
->id() . '/edit';
// Set up needs review revision.
$this
->drupalPostForm($path, [], t('Save and Request Review'));
// Set up published revision.
$this
->drupalPostForm($path, [], t('Save and Publish'));
\Drupal::entityTypeManager()
->getStorage('node')
->resetCache([
$node
->id(),
]);
/* @var \Drupal\node\NodeInterface $node */
$node = \Drupal::entityTypeManager()
->getStorage('node')
->load($node
->id());
$this
->assertTrue($node
->isPublished());
// Verify that the state field is not shown.
$this
->assertNoText('Published');
// Delete the node.
$this
->drupalPostForm('node/' . $node
->id() . '/delete', [], t('Delete'));
$this
->assertSession()
->pageTextContains(t('The Moderated content moderated content has been deleted.'));
}