EntityFormModeResourceTestBase.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace Drupal\FunctionalTests\Rest;
  3. use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
  4. use Drupal\Core\Entity\Entity\EntityFormMode;
  5. abstract class EntityFormModeResourceTestBase extends EntityResourceTestBase {
  6. /**
  7. * {@inheritdoc}
  8. *
  9. * @todo: Remove 'field_ui' when https://www.drupal.org/node/2867266.
  10. */
  11. public static $modules = ['user', 'field_ui'];
  12. /**
  13. * {@inheritdoc}
  14. */
  15. protected static $entityTypeId = 'entity_form_mode';
  16. /**
  17. * @var \Drupal\Core\Entity\EntityFormModeInterface
  18. */
  19. protected $entity;
  20. /**
  21. * {@inheritdoc}
  22. */
  23. protected function setUpAuthorization($method) {
  24. $this->grantPermissionsToTestedRole(['administer display modes']);
  25. }
  26. /**
  27. * {@inheritdoc}
  28. */
  29. protected function createEntity() {
  30. $entity_form_mode = EntityFormMode::create([
  31. 'id' => 'user.test',
  32. 'label' => 'Test',
  33. 'targetEntityType' => 'user',
  34. ]);
  35. $entity_form_mode->save();
  36. return $entity_form_mode;
  37. }
  38. /**
  39. * {@inheritdoc}
  40. */
  41. protected function getExpectedNormalizedEntity() {
  42. return [
  43. 'cache' => TRUE,
  44. 'dependencies' => [
  45. 'module' => [
  46. 'user',
  47. ],
  48. ],
  49. 'id' => 'user.test',
  50. 'label' => 'Test',
  51. 'langcode' => 'en',
  52. 'status' => TRUE,
  53. 'targetEntityType' => 'user',
  54. 'uuid' => $this->entity->uuid(),
  55. ];
  56. }
  57. /**
  58. * {@inheritdoc}
  59. */
  60. protected function getNormalizedPostEntity() {
  61. // @todo Update in https://www.drupal.org/node/2300677.
  62. }
  63. }