Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / system / tests / src / Functional / Rest / ActionResourceTestBase.php
diff --git a/web/core/modules/system/tests/src/Functional/Rest/ActionResourceTestBase.php b/web/core/modules/system/tests/src/Functional/Rest/ActionResourceTestBase.php
new file mode 100644 (file)
index 0000000..5134e91
--- /dev/null
@@ -0,0 +1,89 @@
+<?php
+
+namespace Drupal\Tests\system\Functional\Rest;
+
+use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
+use Drupal\system\Entity\Action;
+use Drupal\user\RoleInterface;
+
+abstract class ActionResourceTestBase extends EntityResourceTestBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public static $modules = ['user'];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $entityTypeId = 'action';
+
+  /**
+   * @var \Drupal\system\ActionConfigEntityInterface
+   */
+  protected $entity;
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUpAuthorization($method) {
+    $this->grantPermissionsToTestedRole(['administer actions']);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function createEntity() {
+    $action = Action::create([
+      'id' => 'user_add_role_action.' . RoleInterface::ANONYMOUS_ID,
+      'type' => 'user',
+      'label' => t('Add the anonymous role to the selected users'),
+      'configuration' => [
+        'rid' => RoleInterface::ANONYMOUS_ID,
+      ],
+      'plugin' => 'user_add_role_action',
+    ]);
+    $action->save();
+
+    return $action;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function getExpectedNormalizedEntity() {
+    return [
+      'configuration' => [
+        'rid' => 'anonymous',
+      ],
+      'dependencies' => [
+        'config' => ['user.role.anonymous'],
+        'module' => ['user'],
+      ],
+      'id' => 'user_add_role_action.anonymous',
+      'label' => 'Add the anonymous role to the selected users',
+      'langcode' => 'en',
+      'plugin' => 'user_add_role_action',
+      'status' => TRUE,
+      'type' => 'user',
+      'uuid' => $this->entity->uuid(),
+    ];
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function getExpectedCacheContexts() {
+    return [
+      'user.permissions',
+    ];
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function getNormalizedPostEntity() {
+    // @todo Update in https://www.drupal.org/node/2300677.
+  }
+
+}