a8b3f8ca35df4e12e0a4d160d0da8bde29c31056
[yaffs-website] / web / core / modules / rest / tests / src / Functional / EntityResource / ContentLanguageSettings / ContentLanguageSettingsResourceTestBase.php
1 <?php
2
3 namespace Drupal\Tests\rest\Functional\EntityResource\ContentLanguageSettings;
4
5 use Drupal\language\Entity\ContentLanguageSettings;
6 use Drupal\node\Entity\NodeType;
7 use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
8
9 abstract class ContentLanguageSettingsResourceTestBase extends EntityResourceTestBase {
10
11   /**
12    * {@inheritdoc}
13    */
14   public static $modules = ['language', 'node'];
15
16   /**
17    * {@inheritdoc}
18    */
19   protected static $entityTypeId = 'language_content_settings';
20
21   /**
22    * @var \Drupal\language\ContentLanguageSettingsInterface
23    */
24   protected $entity;
25
26   /**
27    * {@inheritdoc}
28    */
29   protected function setUpAuthorization($method) {
30     $this->grantPermissionsToTestedRole(['administer languages']);
31   }
32
33   /**
34    * {@inheritdoc}
35    */
36   protected function createEntity() {
37     // Create a "Camelids" node type.
38     $camelids = NodeType::create([
39       'name' => 'Camelids',
40       'type' => 'camelids',
41     ]);
42     $camelids->save();
43
44     $entity = ContentLanguageSettings::create([
45       'target_entity_type_id' => 'node',
46       'target_bundle' => 'camelids',
47     ]);
48     $entity->setDefaultLangcode('site_default')
49       ->save();
50
51     return $entity;
52   }
53
54   /**
55    * {@inheritdoc}
56    */
57   protected function getExpectedNormalizedEntity() {
58     return [
59       'default_langcode' => 'site_default',
60       'dependencies' => [
61         'config' => [
62           'node.type.camelids',
63         ],
64       ],
65       'id' => 'node.camelids',
66       'langcode' => 'en',
67       'language_alterable' => FALSE,
68       'status' => TRUE,
69       'target_bundle' => 'camelids',
70       'target_entity_type_id' => 'node',
71       'uuid' => $this->entity->uuid(),
72     ];
73   }
74
75   /**
76    * {@inheritdoc}
77    */
78   protected function getNormalizedPostEntity() {
79     // @todo Update in https://www.drupal.org/node/2300677.
80   }
81
82   /**
83    * {@inheritdoc}
84    */
85   protected function getExpectedCacheContexts() {
86     return [
87       'languages:language_interface',
88       'user.permissions',
89     ];
90   }
91
92 }