You are here

protected function WorkflowCollectorTest::assertWorkflow in Workbench Moderation to Content Moderation 8.2

Asserts various aspects of a workflow.

Parameters

string $id: The workflow ID.

string[] $expected_node_types: The content types that the workflow is expected to support.

string[] $expected_states: The state IDs that the workflow is expected to have.

string[] $unexpected_states: The state IDs that the workflow specifically should not have.

string[] $expected_transitions: The transition IDs that the workflow is expected to have.

string[] $unexpected_transitions: The transition IDs that the workflow specifically should not have.

1 call to WorkflowCollectorTest::assertWorkflow()
WorkflowCollectorTest::testWorkflowCollection in tests/src/Kernel/WorkflowCollectorTest.php

File

tests/src/Kernel/WorkflowCollectorTest.php, line 172

Class

WorkflowCollectorTest
@covers \Drupal\wbm2cm\WorkflowCollector @group wbm2cm

Namespace

Drupal\Tests\wbm2cm\Kernel

Code

protected function assertWorkflow($id, array $expected_node_types, array $expected_states, array $unexpected_states, array $expected_transitions, array $unexpected_transitions) {
  $workflow = Workflow::load($id);
  $this
    ->assertInstanceOf(Workflow::class, $workflow);

  /** @var ContentModeration $plugin */
  $plugin = $workflow
    ->getTypePlugin();
  $this
    ->assertInstanceOf(ContentModeration::class, $plugin);
  $actual_node_types = $plugin
    ->getBundlesForEntityType('node');
  foreach ($expected_node_types as $node_type) {
    $this
      ->assertContains($node_type, $actual_node_types);
  }
  foreach ($expected_states as $state_id) {
    $this
      ->assertState($plugin, $state_id);
  }
  foreach ($unexpected_states as $state_id) {
    $this
      ->assertNoState($plugin, $state_id);
  }
  foreach ($expected_transitions as $transition_id) {
    $this
      ->assertTransition($plugin, $transition_id);
  }
  foreach ($unexpected_transitions as $transition_id) {
    $this
      ->assertNoTransition($plugin, $transition_id);
  }
}