function StateTransitionValidationTest::setUp

Same name in other branches
  1. 9 core/modules/content_moderation/tests/src/Unit/StateTransitionValidationTest.php \Drupal\Tests\content_moderation\Unit\StateTransitionValidationTest::setUp()
  2. 8.9.x core/modules/content_moderation/tests/src/Unit/StateTransitionValidationTest.php \Drupal\Tests\content_moderation\Unit\StateTransitionValidationTest::setUp()
  3. 11.x core/modules/content_moderation/tests/src/Unit/StateTransitionValidationTest.php \Drupal\Tests\content_moderation\Unit\StateTransitionValidationTest::setUp()

Overrides UnitTestCase::setUp

File

core/modules/content_moderation/tests/src/Unit/StateTransitionValidationTest.php, line 34

Class

StateTransitionValidationTest
@coversDefaultClass \Drupal\content_moderation\StateTransitionValidation @group content_moderation

Namespace

Drupal\Tests\content_moderation\Unit

Code

protected function setUp() : void {
    parent::setUp();
    // Create a container so that the plugin manager and workflow type can be
    // mocked.
    $container = new ContainerBuilder();
    $workflow_manager = $this->prophesize(WorkflowTypeManager::class);
    $workflow_manager->createInstance('content_moderation', Argument::any())
        ->willReturn(new TestType([], '', []));
    $container->set('plugin.manager.workflows.type', $workflow_manager->reveal());
    \Drupal::setContainer($container);
    $this->workflow = new Workflow([
        'id' => 'process',
        'type' => 'content_moderation',
    ], 'workflow');
    $this->workflow
        ->getTypePlugin()
        ->addState('draft', 'draft')
        ->addState('needs_review', 'needs_review')
        ->addState('published', 'published')
        ->addTransition('draft', 'draft', [
        'draft',
    ], 'draft')
        ->addTransition('review', 'review', [
        'draft',
    ], 'needs_review')
        ->addTransition('publish', 'publish', [
        'needs_review',
        'published',
    ], 'published');
}

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