You are here

public function ModerationContext::assertAtContentInState in Lightning Workflow 8.2

Creates a node in a specific workflow state and visits it.

@When I am viewing a :content_type in the :state_label state

Parameters

string $content_type: The content type of the node to create.

string $state_label: The label of the workflow state in which to create the node.

File

tests/contexts/ModerationContext.behat.inc, line 97

Class

ModerationContext
Contains miscellaneous step definitions for testing moderation UIs.

Namespace

Acquia\LightningExtension\Context

Code

public function assertAtContentInState($content_type, $state_label) {
  $this->node = entity_create('node', [
    'type' => $content_type,
    'title' => (new Random())
      ->string(),
  ]);
  $current_user = $this
    ->getUserManager()
    ->getCurrentUser();
  if ($current_user) {
    $this->node
      ->setOwnerId($current_user->uid);
  }
  $this->node
    ->set('moderation_state', $this
    ->getStateId($state_label))
    ->save();
  $this
    ->visitPath($this->node
    ->toUrl()
    ->toString());
  $assert = $this
    ->assertSession();
  $assert
    ->statusCodeEquals(200);
  $assert
    ->pageTextContains($this->node
    ->getTitle());
}