DateFormatResourceTestBase.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace Drupal\FunctionalTests\Rest;
  3. use Drupal\Core\Datetime\Entity\DateFormat;
  4. use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
  5. /**
  6. * ResourceTestBase for DateFormat entity.
  7. */
  8. abstract class DateFormatResourceTestBase extends EntityResourceTestBase {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public static $modules = [];
  13. /**
  14. * {@inheritdoc}
  15. */
  16. protected static $entityTypeId = 'date_format';
  17. /**
  18. * The DateFormat entity.
  19. *
  20. * @var \Drupal\Core\Datetime\DateFormatInterface
  21. */
  22. protected $entity;
  23. /**
  24. * {@inheritdoc}
  25. */
  26. protected function setUpAuthorization($method) {
  27. $this->grantPermissionsToTestedRole(['administer site configuration']);
  28. }
  29. /**
  30. * {@inheritdoc}
  31. */
  32. protected function createEntity() {
  33. // Create a date format.
  34. $date_format = DateFormat::create([
  35. 'id' => 'llama',
  36. 'label' => 'Llama',
  37. 'pattern' => 'F d, Y',
  38. ]);
  39. $date_format->save();
  40. return $date_format;
  41. }
  42. /**
  43. * {@inheritdoc}
  44. */
  45. protected function getExpectedNormalizedEntity() {
  46. return [
  47. 'dependencies' => [],
  48. 'id' => 'llama',
  49. 'label' => 'Llama',
  50. 'langcode' => 'en',
  51. 'locked' => FALSE,
  52. 'pattern' => 'F d, Y',
  53. 'status' => TRUE,
  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. }