Skip to content
Snippets Groups Projects
Commit 02a9d564 authored by Björn Brala's avatar Björn Brala
Browse files

Test placeholder to validate the events work.

parent 75bb6a24
No related branches found
No related tags found
No related merge requests found
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Drupal\Tests\jsonapi_extras\Functional; namespace Drupal\Tests\jsonapi_extras\Functional;
use Drupal\Component\Serialization\Json; use Drupal\Component\Serialization\Json;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Url; use Drupal\Core\Url;
use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldConfig;
...@@ -29,6 +30,7 @@ class JsonApiExtrasFunctionalTest extends JsonApiFunctionalTestBase { ...@@ -29,6 +30,7 @@ class JsonApiExtrasFunctionalTest extends JsonApiFunctionalTestBase {
public static $modules = [ public static $modules = [
'jsonapi_extras', 'jsonapi_extras',
'basic_auth', 'basic_auth',
'jsonapi_test_resource_type_building',
]; ];
/** /**
...@@ -179,10 +181,39 @@ class JsonApiExtrasFunctionalTest extends JsonApiFunctionalTestBase { ...@@ -179,10 +181,39 @@ class JsonApiExtrasFunctionalTest extends JsonApiFunctionalTestBase {
} }
/**
* Tests that resource type fields can be aliased per resource type.
* @todo Create a test similar to this
*/
public function testResourceTypeFieldAliasing() {
$resourceTypeRepository = $this->container->get('jsonapi.resource_type.repository');
$this->assertSame($resourceTypeRepository->getByTypeName('node--article')->getPublicName('uid'), 'uid');
$this->assertSame($resourceTypeRepository->getByTypeName('node--page')->getPublicName('uid'), 'uid');
$resource_type_field_aliases = [
'node--article' => [
'uid' => 'author',
],
'node--page' => [
'uid' => 'owner',
],
];
\Drupal::state()->set('jsonapi_test_resource_type_builder.resource_type_field_aliases', $resource_type_field_aliases);
Cache::invalidateTags(['jsonapi_resource_types']);
$this->assertSame($resourceTypeRepository->getByTypeName('node--article')->getPublicName('uid'), 'author');
$this->assertSame($resourceTypeRepository->getByTypeName('node--page')->getPublicName('uid'), 'owner');
}
/** /**
* Test the GET method. * Test the GET method.
*/ */
public function testRead() { public function testRead() {
$num_articles = 61; $num_articles = 61;
$this->createDefaultContent($num_articles, 5, TRUE, TRUE, static::IS_NOT_MULTILINGUAL); $this->createDefaultContent($num_articles, 5, TRUE, TRUE, static::IS_NOT_MULTILINGUAL);
// Make the link for node/3 to point to an entity. // Make the link for node/3 to point to an entity.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment