ConfigurableLanguageResourceTestBase.php in Drupal 8
File
core/modules/language/tests/src/Functional/Rest/ConfigurableLanguageResourceTestBase.php
View source
<?php
namespace Drupal\Tests\language\Functional\Rest;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Url;
use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
use Drupal\language\Entity\ConfigurableLanguage;
abstract class ConfigurableLanguageResourceTestBase extends EntityResourceTestBase {
public static $modules = [
'language',
];
protected static $entityTypeId = 'configurable_language';
protected $entity;
protected function setUpAuthorization($method) {
$this
->grantPermissionsToTestedRole([
'administer languages',
]);
}
protected function createEntity() {
$configurable_language = ConfigurableLanguage::create([
'id' => 'll',
'label' => 'Llama Language',
]);
$configurable_language
->save();
return $configurable_language;
}
protected function getExpectedNormalizedEntity() {
return [
'dependencies' => [],
'direction' => 'ltr',
'id' => 'll',
'label' => 'Llama Language',
'langcode' => 'en',
'locked' => FALSE,
'status' => TRUE,
'uuid' => $this->entity
->uuid(),
'weight' => 0,
];
}
protected function getExpectedCacheContexts() {
return Cache::mergeContexts(parent::getExpectedCacheContexts(), [
'languages:language_interface',
]);
}
protected function getNormalizedPostEntity() {
}
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);
}
}