You are here

protected function WorkflowTest::getExpectedDocument in JSON:API 8.2

Same name and namespace in other branches
  1. 8 tests/src/Functional/WorkflowTest.php \Drupal\Tests\jsonapi\Functional\WorkflowTest::getExpectedDocument()

Returns the expected JSON:API document for the entity.

Return value

array A JSON:API response document.

Overrides ResourceTestBase::getExpectedDocument

See also

::createEntity()

File

tests/src/Functional/WorkflowTest.php, line 68

Class

WorkflowTest
JSON:API integration test for the "Workflow" config entity type.

Namespace

Drupal\Tests\jsonapi\Functional

Code

protected function getExpectedDocument() {
  $self_url = Url::fromUri('base:/jsonapi/workflow/workflow/' . $this->entity
    ->uuid())
    ->setAbsolute()
    ->toString(TRUE)
    ->getGeneratedUrl();
  return [
    'jsonapi' => [
      'meta' => [
        'links' => [
          'self' => [
            'href' => 'http://jsonapi.org/format/1.0/',
          ],
        ],
      ],
      'version' => '1.0',
    ],
    'links' => [
      'self' => [
        'href' => $self_url,
      ],
    ],
    'data' => [
      'id' => $this->entity
        ->uuid(),
      'type' => 'workflow--workflow',
      'links' => [
        'self' => [
          'href' => $self_url,
        ],
      ],
      'attributes' => [
        'dependencies' => [
          'module' => [
            'workflow_type_test',
          ],
        ],
        'label' => 'REST Worklow',
        'langcode' => 'en',
        'status' => TRUE,
        'workflow_type' => 'workflow_type_complex_test',
        'type_settings' => [
          'states' => [
            'draft' => [
              'extra' => 'bar',
              'label' => 'Draft',
              'weight' => 0,
            ],
            'published' => [
              'label' => 'Published',
              'weight' => 1,
            ],
          ],
          'transitions' => [],
          'example_setting' => 'foo',
        ],
        'drupal_internal__id' => 'rest_workflow',
      ],
    ],
  ];
}