301beb2f06832dc17034b5c15ff8544742ea9aba
[yaffs-website] / web / core / modules / rest / tests / src / Functional / EntityResource / ConfigurableLanguage / ConfigurableLanguageResourceTestBase.php
1 <?php
2
3 namespace Drupal\Tests\rest\Functional\EntityResource\ConfigurableLanguage;
4
5 use Drupal\Core\Cache\Cache;
6 use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
7 use Drupal\language\Entity\ConfigurableLanguage;
8
9 abstract class ConfigurableLanguageResourceTestBase extends EntityResourceTestBase {
10
11   /**
12    * {@inheritdoc}
13    */
14   public static $modules = ['language'];
15
16   /**
17    * {@inheritdoc}
18    */
19   protected static $entityTypeId = 'configurable_language';
20
21   /**
22    * @var \Drupal\language\ConfigurableLanguageInterface
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     $configurable_language = ConfigurableLanguage::create([
38       'id' => 'll',
39       'label' => 'Llama Language',
40     ]);
41     $configurable_language->save();
42
43     return $configurable_language;
44   }
45
46   /**
47    * {@inheritdoc}
48    */
49   protected function getExpectedNormalizedEntity() {
50     return [
51       'dependencies' => [],
52       'direction' => 'ltr',
53       'id' => 'll',
54       'label' => 'Llama Language',
55       'langcode' => 'en',
56       'locked' => FALSE,
57       'status' => TRUE,
58       'uuid' => $this->entity->uuid(),
59       'weight' => 0,
60     ];
61   }
62
63   /**
64    * {@inheritdoc}
65    */
66   protected function getExpectedCacheContexts() {
67     return Cache::mergeContexts(parent::getExpectedCacheContexts(), ['languages:language_interface']);
68   }
69
70   /**
71    * {@inheritdoc}
72    */
73   protected function getNormalizedPostEntity() {
74     // @todo Update in https://www.drupal.org/node/2300677.
75   }
76
77 }