diff --git a/core/modules/hal/tests/src/Functional/EntityResource/ContentLanguageSettings/ContentLanguageSettingsHalJsonAnonTest.php b/core/modules/hal/tests/src/Functional/EntityResource/ContentLanguageSettings/ContentLanguageSettingsHalJsonAnonTest.php new file mode 100644 index 0000000000000000000000000000000000000000..e90485d30c0430198db2b6612addd45b7d9826b1 --- /dev/null +++ b/core/modules/hal/tests/src/Functional/EntityResource/ContentLanguageSettings/ContentLanguageSettingsHalJsonAnonTest.php @@ -0,0 +1,30 @@ +<?php + +namespace Drupal\Tests\hal\Functional\EntityResource\ContentLanguageSettings; + +use Drupal\Tests\rest\Functional\AnonResourceTestTrait; +use Drupal\Tests\rest\Functional\EntityResource\ContentLanguageSettings\ContentLanguageSettingsResourceTestBase; + +/** + * @group hal + */ +class ContentLanguageSettingsHalJsonAnonTest extends ContentLanguageSettingsResourceTestBase { + + use AnonResourceTestTrait; + + /** + * {@inheritdoc} + */ + public static $modules = ['hal']; + + /** + * {@inheritdoc} + */ + protected static $format = 'hal_json'; + + /** + * {@inheritdoc} + */ + protected static $mimeType = 'application/hal+json'; + +} diff --git a/core/modules/hal/tests/src/Functional/EntityResource/ContentLanguageSettings/ContentLanguageSettingsHalJsonBasicAuthTest.php b/core/modules/hal/tests/src/Functional/EntityResource/ContentLanguageSettings/ContentLanguageSettingsHalJsonBasicAuthTest.php new file mode 100644 index 0000000000000000000000000000000000000000..942901bb232f0d7859059d799f2c2f0de5ee5680 --- /dev/null +++ b/core/modules/hal/tests/src/Functional/EntityResource/ContentLanguageSettings/ContentLanguageSettingsHalJsonBasicAuthTest.php @@ -0,0 +1,35 @@ +<?php + +namespace Drupal\Tests\hal\Functional\EntityResource\ContentLanguageSettings; + +use Drupal\Tests\rest\Functional\BasicAuthResourceTestTrait; +use Drupal\Tests\rest\Functional\EntityResource\ContentLanguageSettings\ContentLanguageSettingsResourceTestBase; + +/** + * @group hal + */ +class ContentLanguageSettingsHalJsonBasicAuthTest extends ContentLanguageSettingsResourceTestBase { + + use BasicAuthResourceTestTrait; + + /** + * {@inheritdoc} + */ + public static $modules = ['hal', 'basic_auth']; + + /** + * {@inheritdoc} + */ + protected static $format = 'hal_json'; + + /** + * {@inheritdoc} + */ + protected static $mimeType = 'application/hal+json'; + + /** + * {@inheritdoc} + */ + protected static $auth = 'basic_auth'; + +} diff --git a/core/modules/hal/tests/src/Functional/EntityResource/ContentLanguageSettings/ContentLanguageSettingsHalJsonCookieTest.php b/core/modules/hal/tests/src/Functional/EntityResource/ContentLanguageSettings/ContentLanguageSettingsHalJsonCookieTest.php new file mode 100644 index 0000000000000000000000000000000000000000..4cc572f11ed8fcc15309a9c2ec10b757e8b42e5c --- /dev/null +++ b/core/modules/hal/tests/src/Functional/EntityResource/ContentLanguageSettings/ContentLanguageSettingsHalJsonCookieTest.php @@ -0,0 +1,35 @@ +<?php + +namespace Drupal\Tests\hal\Functional\EntityResource\ContentLanguageSettings; + +use Drupal\Tests\rest\Functional\CookieResourceTestTrait; +use Drupal\Tests\rest\Functional\EntityResource\ContentLanguageSettings\ContentLanguageSettingsResourceTestBase; + +/** + * @group hal + */ +class ContentLanguageSettingsHalJsonCookieTest extends ContentLanguageSettingsResourceTestBase { + + use CookieResourceTestTrait; + + /** + * {@inheritdoc} + */ + public static $modules = ['hal']; + + /** + * {@inheritdoc} + */ + protected static $format = 'hal_json'; + + /** + * {@inheritdoc} + */ + protected static $mimeType = 'application/hal+json'; + + /** + * {@inheritdoc} + */ + protected static $auth = 'cookie'; + +} diff --git a/core/modules/rest/tests/src/Functional/EntityResource/ContentLanguageSettings/ContentLanguageSettingsJsonAnonTest.php b/core/modules/rest/tests/src/Functional/EntityResource/ContentLanguageSettings/ContentLanguageSettingsJsonAnonTest.php new file mode 100644 index 0000000000000000000000000000000000000000..344c7335e5b2780543cedc2996c2669fddbd0ae4 --- /dev/null +++ b/core/modules/rest/tests/src/Functional/EntityResource/ContentLanguageSettings/ContentLanguageSettingsJsonAnonTest.php @@ -0,0 +1,24 @@ +<?php + +namespace Drupal\Tests\rest\Functional\EntityResource\ContentLanguageSettings; + +use Drupal\Tests\rest\Functional\AnonResourceTestTrait; + +/** + * @group rest + */ +class ContentLanguageSettingsJsonAnonTest extends ContentLanguageSettingsResourceTestBase { + + use AnonResourceTestTrait; + + /** + * {@inheritdoc} + */ + protected static $format = 'json'; + + /** + * {@inheritdoc} + */ + protected static $mimeType = 'application/json'; + +} diff --git a/core/modules/rest/tests/src/Functional/EntityResource/ContentLanguageSettings/ContentLanguageSettingsJsonBasicAuthTest.php b/core/modules/rest/tests/src/Functional/EntityResource/ContentLanguageSettings/ContentLanguageSettingsJsonBasicAuthTest.php new file mode 100644 index 0000000000000000000000000000000000000000..392213f881666358da7a0d238f24554270be03fd --- /dev/null +++ b/core/modules/rest/tests/src/Functional/EntityResource/ContentLanguageSettings/ContentLanguageSettingsJsonBasicAuthTest.php @@ -0,0 +1,34 @@ +<?php + +namespace Drupal\Tests\rest\Functional\EntityResource\ContentLanguageSettings; + +use Drupal\Tests\rest\Functional\BasicAuthResourceTestTrait; + +/** + * @group rest + */ +class ContentLanguageSettingsJsonBasicAuthTest extends ContentLanguageSettingsResourceTestBase { + + use BasicAuthResourceTestTrait; + + /** + * {@inheritdoc} + */ + public static $modules = ['basic_auth']; + + /** + * {@inheritdoc} + */ + protected static $format = 'json'; + + /** + * {@inheritdoc} + */ + protected static $mimeType = 'application/json'; + + /** + * {@inheritdoc} + */ + protected static $auth = 'basic_auth'; + +} diff --git a/core/modules/rest/tests/src/Functional/EntityResource/ContentLanguageSettings/ContentLanguageSettingsJsonCookieTest.php b/core/modules/rest/tests/src/Functional/EntityResource/ContentLanguageSettings/ContentLanguageSettingsJsonCookieTest.php new file mode 100644 index 0000000000000000000000000000000000000000..b0af52987b06d21284e31ea1bb042aaca9aa0e76 --- /dev/null +++ b/core/modules/rest/tests/src/Functional/EntityResource/ContentLanguageSettings/ContentLanguageSettingsJsonCookieTest.php @@ -0,0 +1,29 @@ +<?php + +namespace Drupal\Tests\rest\Functional\EntityResource\ContentLanguageSettings; + +use Drupal\Tests\rest\Functional\CookieResourceTestTrait; + +/** + * @group rest + */ +class ContentLanguageSettingsJsonCookieTest extends ContentLanguageSettingsResourceTestBase { + + use CookieResourceTestTrait; + + /** + * {@inheritdoc} + */ + protected static $format = 'json'; + + /** + * {@inheritdoc} + */ + protected static $mimeType = 'application/json'; + + /** + * {@inheritdoc} + */ + protected static $auth = 'cookie'; + +} diff --git a/core/modules/rest/tests/src/Functional/EntityResource/ContentLanguageSettings/ContentLanguageSettingsResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/ContentLanguageSettings/ContentLanguageSettingsResourceTestBase.php new file mode 100644 index 0000000000000000000000000000000000000000..a8b3f8ca35df4e12e0a4d160d0da8bde29c31056 --- /dev/null +++ b/core/modules/rest/tests/src/Functional/EntityResource/ContentLanguageSettings/ContentLanguageSettingsResourceTestBase.php @@ -0,0 +1,92 @@ +<?php + +namespace Drupal\Tests\rest\Functional\EntityResource\ContentLanguageSettings; + +use Drupal\language\Entity\ContentLanguageSettings; +use Drupal\node\Entity\NodeType; +use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase; + +abstract class ContentLanguageSettingsResourceTestBase extends EntityResourceTestBase { + + /** + * {@inheritdoc} + */ + public static $modules = ['language', 'node']; + + /** + * {@inheritdoc} + */ + protected static $entityTypeId = 'language_content_settings'; + + /** + * @var \Drupal\language\ContentLanguageSettingsInterface + */ + protected $entity; + + /** + * {@inheritdoc} + */ + protected function setUpAuthorization($method) { + $this->grantPermissionsToTestedRole(['administer languages']); + } + + /** + * {@inheritdoc} + */ + protected function createEntity() { + // Create a "Camelids" node type. + $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; + } + + /** + * {@inheritdoc} + */ + 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(), + ]; + } + + /** + * {@inheritdoc} + */ + protected function getNormalizedPostEntity() { + // @todo Update in https://www.drupal.org/node/2300677. + } + + /** + * {@inheritdoc} + */ + protected function getExpectedCacheContexts() { + return [ + 'languages:language_interface', + 'user.permissions', + ]; + } + +}