function WorkflowResourceTestBase::createEntity

Same name in other branches
  1. 9 core/modules/workflows/tests/src/Functional/Rest/WorkflowResourceTestBase.php \Drupal\Tests\workflows\Functional\Rest\WorkflowResourceTestBase::createEntity()
  2. 8.9.x core/modules/workflows/tests/src/Functional/Rest/WorkflowResourceTestBase.php \Drupal\Tests\workflows\Functional\Rest\WorkflowResourceTestBase::createEntity()
  3. 10 core/modules/workflows/tests/src/Functional/Rest/WorkflowResourceTestBase.php \Drupal\Tests\workflows\Functional\Rest\WorkflowResourceTestBase::createEntity()

Overrides EntityResourceTestBase::createEntity

File

core/modules/workflows/tests/src/Functional/Rest/WorkflowResourceTestBase.php, line 50

Class

WorkflowResourceTestBase
ResourceTestBase for Workflow entity.

Namespace

Drupal\Tests\workflows\Functional\Rest

Code

protected function createEntity() {
    $workflow = Workflow::create([
        'id' => 'rest_workflow',
        'label' => 'REST Workflow',
        'type' => 'workflow_type_complex_test',
    ]);
    $workflow->getTypePlugin()
        ->addState('draft', 'Draft')
        ->addState('published', 'Published');
    $configuration = $workflow->getTypePlugin()
        ->getConfiguration();
    $configuration['example_setting'] = 'foo';
    $configuration['states']['draft']['extra'] = 'bar';
    $workflow->getTypePlugin()
        ->setConfiguration($configuration);
    $workflow->save();
    return $workflow;
}

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