a11f8ef54d0b67214f3dc7ef5ee030af4da8bbbb
[yaffs-website] / web / core / modules / media / tests / src / Functional / Rest / MediaTypeResourceTestBase.php
1 <?php
2
3 namespace Drupal\Tests\media\Functional\Rest;
4
5 use Drupal\media\Entity\MediaType;
6 use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
7
8 abstract class MediaTypeResourceTestBase extends EntityResourceTestBase {
9
10   /**
11    * {@inheritdoc}
12    */
13   public static $modules = ['media'];
14
15   /**
16    * {@inheritdoc}
17    */
18   protected static $entityTypeId = 'media_type';
19
20   /**
21    * @var \Drupal\media\MediaTypeInterface
22    */
23   protected $entity;
24
25   /**
26    * {@inheritdoc}
27    */
28   protected function setUpAuthorization($method) {
29     $this->grantPermissionsToTestedRole(['administer media types']);
30   }
31
32   /**
33    * {@inheritdoc}
34    */
35   protected function createEntity() {
36     // Create a "Camelids" media type.
37     $camelids = MediaType::create([
38       'name' => 'Camelids',
39       'id' => 'camelids',
40       'description' => 'Camelids are large, strictly herbivorous animals with slender necks and long legs.',
41       'source' => 'file',
42     ]);
43
44     $camelids->save();
45
46     return $camelids;
47   }
48
49   /**
50    * {@inheritdoc}
51    */
52   protected function getExpectedNormalizedEntity() {
53     return [
54       'dependencies' => [],
55       'description' => 'Camelids are large, strictly herbivorous animals with slender necks and long legs.',
56       'field_map' => [],
57       'id' => 'camelids',
58       'label' => NULL,
59       'langcode' => 'en',
60       'new_revision' => FALSE,
61       'queue_thumbnail_downloads' => FALSE,
62       'source' => 'file',
63       'source_configuration' => [
64         'source_field' => '',
65       ],
66       'status' => TRUE,
67       'uuid' => $this->entity->uuid(),
68     ];
69   }
70
71   /**
72    * {@inheritdoc}
73    */
74   protected function getNormalizedPostEntity() {
75     // @todo Update in https://www.drupal.org/node/2300677.
76   }
77
78 }