You are here

public function EntityOperationsTest::testPublishedCreation in Workbench Moderation 8.2

Same name and namespace in other branches
  1. 8 tests/src/Kernel/EntityOperationsTest.php \Drupal\Tests\workbench_moderation\Kernel\EntityOperationsTest::testPublishedCreation()

Verifies that a newly-created node can go straight to published.

File

tests/src/Kernel/EntityOperationsTest.php, line 126

Class

EntityOperationsTest
Class EntityOperationsTest

Namespace

Drupal\Tests\workbench_moderation\Kernel

Code

public function testPublishedCreation() {

  // Create a new node in draft.
  $page = Node::create([
    'type' => 'page',
    'title' => 'A',
  ]);
  $page->moderation_state->target_id = 'published';
  $page
    ->save();
  $id = $page
    ->id();

  // Verify the entity saved correctly.

  /** @var Node $page */
  $page = Node::load($id);
  $this
    ->assertEquals('A', $page
    ->getTitle());
  $this
    ->assertTrue($page
    ->isDefaultRevision());
  $this
    ->assertTrue($page
    ->isPublished());
}