diff --git a/src/Entity/Workspace.php b/src/Entity/Workspace.php index 3b90272..5e917b8 100644 --- a/src/Entity/Workspace.php +++ b/src/Entity/Workspace.php @@ -38,7 +38,6 @@ use Drupal\workspace\UpstreamPluginInterface; * "deploy" = "\Drupal\workspace\Form\WorkspaceDeployForm", * }, * }, - * admin_permission = "administer workspaces", * base_table = "workspace", * revision_table = "workspace_revision", * data_table = "workspace_field_data", diff --git a/tests/src/Functional/EntityResource/WorkspaceJsonBasicAuthTest.php b/tests/src/Functional/EntityResource/WorkspaceJsonBasicAuthTest.php index e69de29..b4ccc3f 100644 --- a/tests/src/Functional/EntityResource/WorkspaceJsonBasicAuthTest.php +++ b/tests/src/Functional/EntityResource/WorkspaceJsonBasicAuthTest.php @@ -0,0 +1,34 @@ +grantPermissionsToTestedRole(['administer workspaces', 'view_workspace_layla']); + $this->grantPermissionsToTestedRole(['administer workspaces', 'create workspace', 'update_workspace_layla', 'delete_workspace_layla', 'view_workspace_layla']); } /** * @inheritDoc */ protected function createEntity() { - $workspace = Workspace::create(['id' => 'layla', 'label' => 'Layla']); + $workspace = Workspace::create(['id' => 'layla', 'label' => 'Layla', 'upstream' => 'local_workspace:live']); $workspace->save(); return $workspace; } @@ -43,7 +49,46 @@ abstract class WorkspaceResourceTestBase extends EntityResourceTestBase { * @inheritDoc */ protected function getExpectedNormalizedEntity() { - throw new \Exception('Not yet supported.'); + $author = User::load($this->entity->getOwnerId()); + return [ + 'created' => [ + $this->formatExpectedTimestampItemValues((int) $this->entity->getStartTime()), + ], + 'changed' => [ + $this->formatExpectedTimestampItemValues($this->entity->getChangedTime()), + ], + 'id' => [ + [ + 'value' => 'layla', + ], + ], + 'label' => [ + [ + 'value' => 'Layla', + ], + ], + 'revision_id' => [ + [ + 'value' => 3 + ], + ], + 'uid' => [ + [ + 'target_id' => (int) $author->id(), + 'target_type' => 'user', + 'target_uuid' => $author->uuid(), + 'url' => base_path() . 'user/' . $author->id(), + ], + ], + 'upstream' => [ + [ + 'value' => 'local_workspace:live', + ], + ], + 'uuid' => [ + ['value' => $this->entity->uuid()], + ], + ]; } /** @@ -53,12 +98,17 @@ abstract class WorkspaceResourceTestBase extends EntityResourceTestBase { return [ 'id' => [ [ - 'value' => 'layla', + 'value' => 'running_on_faith', ], ], 'label' => [ [ - 'value' => 'Layla', + 'value' => 'Running on faith', + ], + ], + 'upstream' => [ + [ + 'value' => 'local_workspace:stage', ], ], ]; @@ -71,6 +121,14 @@ abstract class WorkspaceResourceTestBase extends EntityResourceTestBase { return parent::getExpectedUnauthorizedAccessMessage($method); // TODO: Change the autogenerated stub } + /** + * {@inheritdoc} + */ + protected function getExpectedUnauthorizedAccessCacheability() { + return parent::getExpectedUnauthorizedAccessCacheability()->addCacheTags($this->entity->getCacheTags()); + } + + /** * @inheritDoc */ diff --git a/tests/src/Functional/EntityResource/WorkspaceXmlAnonTest.php b/tests/src/Functional/EntityResource/WorkspaceXmlAnonTest.php index e69de29..966159d 100644 --- a/tests/src/Functional/EntityResource/WorkspaceXmlAnonTest.php +++ b/tests/src/Functional/EntityResource/WorkspaceXmlAnonTest.php @@ -0,0 +1,34 @@ +markTestSkipped(); + } + +} diff --git a/tests/src/Functional/EntityResource/WorkspaceXmlBasicAuthTest.php b/tests/src/Functional/EntityResource/WorkspaceXmlBasicAuthTest.php index e69de29..372c496 100644 --- a/tests/src/Functional/EntityResource/WorkspaceXmlBasicAuthTest.php +++ b/tests/src/Functional/EntityResource/WorkspaceXmlBasicAuthTest.php @@ -0,0 +1,44 @@ +markTestSkipped(); + } + +} diff --git a/tests/src/Functional/EntityResource/WorkspaceXmlCookieTest.php b/tests/src/Functional/EntityResource/WorkspaceXmlCookieTest.php index e69de29..d64834a 100644 --- a/tests/src/Functional/EntityResource/WorkspaceXmlCookieTest.php +++ b/tests/src/Functional/EntityResource/WorkspaceXmlCookieTest.php @@ -0,0 +1,39 @@ +markTestSkipped(); + } + +} diff --git a/workspace.link_relation_types.yml b/workspace.link_relation_types.yml index e69de29..9791baa 100644 --- a/workspace.link_relation_types.yml +++ b/workspace.link_relation_types.yml @@ -0,0 +1,8 @@ +# Workspace extension relation types. +# See https://tools.ietf.org/html/rfc5988#section-4.2. +activate-form: + uri: https://drupal.org/link-relations/activate-form + description: A form where a workspace can be activated. +deploy-form: + uri: https://drupal.org/link-relations/deploy-form + description: A form where a workspace can be deployed. \ No newline at end of file