View source  
  <?php
namespace Drupal\Tests\workflows\Functional\Rest;
use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
use Drupal\workflows\Entity\Workflow;
abstract class WorkflowResourceTestBase extends EntityResourceTestBase {
  
  public static $modules = [
    'workflows',
    'workflow_type_test',
  ];
  
  protected static $entityTypeId = 'workflow';
  
  protected static $patchProtectedFieldNames = [];
  
  protected $entity;
  
  protected function setUpAuthorization($method) {
    $this
      ->grantPermissionsToTestedRole([
      'administer workflows',
    ]);
  }
  
  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;
  }
  
  protected function getExpectedNormalizedEntity() {
    return [
      'dependencies' => [
        'module' => [
          'workflow_type_test',
        ],
      ],
      'id' => 'rest_workflow',
      'label' => 'REST Workflow',
      'langcode' => 'en',
      'status' => TRUE,
      'type' => 'workflow_type_complex_test',
      'type_settings' => [
        'states' => [
          'draft' => [
            'extra' => 'bar',
            'label' => 'Draft',
            'weight' => 0,
          ],
          'published' => [
            'label' => 'Published',
            'weight' => 1,
          ],
        ],
        'transitions' => [],
        'example_setting' => 'foo',
      ],
      'uuid' => $this->entity
        ->uuid(),
    ];
  }
  
  protected function getNormalizedPostEntity() {
    
  }
}