ContentLanguageSettingsResourceTestBase.php in Drupal 10
File
core/modules/language/tests/src/Functional/Rest/ContentLanguageSettingsResourceTestBase.php
View source
<?php
namespace Drupal\Tests\language\Functional\Rest;
use Drupal\language\Entity\ContentLanguageSettings;
use Drupal\node\Entity\NodeType;
use Drupal\Tests\rest\Functional\EntityResource\ConfigEntityResourceTestBase;
abstract class ContentLanguageSettingsResourceTestBase extends ConfigEntityResourceTestBase {
protected static $modules = [
'language',
'node',
];
protected static $entityTypeId = 'language_content_settings';
protected $entity;
protected function setUpAuthorization($method) {
$this
->grantPermissionsToTestedRole([
'administer languages',
]);
}
protected function createEntity() {
$camelids = NodeType::create([
'name' => 'Camelids',
'type' => 'camelids',
]);
$camelids
->save();
$entity = ContentLanguageSettings::create([
'target_entity_type_id' => 'node',
'target_bundle' => 'camelids',
]);
$entity
->setDefaultLangcode('site_default')
->save();
return $entity;
}
protected function getExpectedNormalizedEntity() {
return [
'default_langcode' => 'site_default',
'dependencies' => [
'config' => [
'node.type.camelids',
],
],
'id' => 'node.camelids',
'langcode' => 'en',
'language_alterable' => FALSE,
'status' => TRUE,
'target_bundle' => 'camelids',
'target_entity_type_id' => 'node',
'uuid' => $this->entity
->uuid(),
];
}
protected function getNormalizedPostEntity() {
return [];
}
protected function getExpectedCacheContexts() {
return [
'languages:language_interface',
'user.permissions',
];
}
}