function WorkflowTest::testDeleteTransition

Same name in other branches
  1. 9 core/modules/workflows/tests/src/Unit/WorkflowTest.php \Drupal\Tests\workflows\Unit\WorkflowTest::testDeleteTransition()
  2. 8.9.x core/modules/workflows/tests/src/Unit/WorkflowTest.php \Drupal\Tests\workflows\Unit\WorkflowTest::testDeleteTransition()
  3. 10 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 678

Class

WorkflowTest
@coversDefaultClass \Drupal\workflows\Plugin\WorkflowTypeBase

Namespace

Drupal\Tests\workflows\Unit

Code

public function testDeleteTransition() : void {
    $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'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.