You are here

public function WorkflowTest::testDeleteTransition in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/workflows/tests/src/Unit/WorkflowTest.php \Drupal\Tests\workflows\Unit\WorkflowTest::testDeleteTransition()

@covers ::deleteTransition

File

core/modules/workflows/tests/src/Unit/WorkflowTest.php, line 676

Class

WorkflowTest
@coversDefaultClass \Drupal\workflows\Plugin\WorkflowTypeBase

Namespace

Drupal\Tests\workflows\Unit

Code

public function testDeleteTransition() {
  $workflow_type = new TestType([], '', []);
  $workflow_type
    ->addState('draft', 'Draft')
    ->addState('published', 'Published')
    ->addTransition('create_new_draft', 'Create new draft', [
    'draft',
  ], 'draft')
    ->addTransition('publish', 'Publish', [
    'draft',
  ], 'published');
  $this
    ->assertTrue($workflow_type
    ->getState('draft')
    ->canTransitionTo('published'));
  $workflow_type
    ->deleteTransition('publish');
  $this
    ->assertFalse($workflow_type
    ->getState('draft')
    ->canTransitionTo('published'));
  $this
    ->assertTrue($workflow_type
    ->getState('draft')
    ->canTransitionTo('draft'));
}