X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2Fcore%2Fmodules%2Flanguage%2Ftests%2Fsrc%2FFunctional%2FRest%2FConfigurableLanguageResourceTestBase.php;fp=web%2Fcore%2Fmodules%2Flanguage%2Ftests%2Fsrc%2FFunctional%2FRest%2FConfigurableLanguageResourceTestBase.php;h=a0dd46054109bdbabc5f3fbc05ee2720ac926359;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hp=0000000000000000000000000000000000000000;hpb=74df008bdbb3a11eeea356744f39b802369bda3c;p=yaffs-website diff --git a/web/core/modules/language/tests/src/Functional/Rest/ConfigurableLanguageResourceTestBase.php b/web/core/modules/language/tests/src/Functional/Rest/ConfigurableLanguageResourceTestBase.php new file mode 100644 index 000000000..a0dd46054 --- /dev/null +++ b/web/core/modules/language/tests/src/Functional/Rest/ConfigurableLanguageResourceTestBase.php @@ -0,0 +1,95 @@ +grantPermissionsToTestedRole(['administer languages']); + } + + /** + * {@inheritdoc} + */ + protected function createEntity() { + $configurable_language = ConfigurableLanguage::create([ + 'id' => 'll', + 'label' => 'Llama Language', + ]); + $configurable_language->save(); + + return $configurable_language; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedNormalizedEntity() { + return [ + 'dependencies' => [], + 'direction' => 'ltr', + 'id' => 'll', + 'label' => 'Llama Language', + 'langcode' => 'en', + 'locked' => FALSE, + 'status' => TRUE, + 'uuid' => $this->entity->uuid(), + 'weight' => 0, + ]; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedCacheContexts() { + return Cache::mergeContexts(parent::getExpectedCacheContexts(), ['languages:language_interface']); + } + + /** + * {@inheritdoc} + */ + protected function getNormalizedPostEntity() { + // @todo Update in https://www.drupal.org/node/2300677. + } + + /** + * Test a GET request for a default config entity, which has a _core key. + * + * @see https://www.drupal.org/node/2915414 + */ + public function testGetDefaultConfig() { + $this->initAuthentication(); + $url = Url::fromUri('base:/entity/configurable_language/en')->setOption('query', ['_format' => static::$format]);; + $request_options = $this->getAuthenticationRequestOptions('GET'); + $this->provisionEntityResource(); + $this->setUpAuthorization('GET'); + $response = $this->request('GET', $url, $request_options); + + $normalization = $this->serializer->decode((string) $response->getBody(), static::$format); + $this->assertArrayNotHasKey('_core', $normalization); + } + +}