Update to Drupal 8.1.0. For more information, see https://www.drupal.org/drupal-8.1.0-release-notes
This commit is contained in:
parent
b11a755ba8
commit
c0a0d5a94c
6920 changed files with 64395 additions and 57312 deletions
|
@ -16,7 +16,7 @@ function hal_help($route_name, RouteMatchInterface $route_match) {
|
|||
$output = '';
|
||||
$output .= '<h3>' . t('About') . '</h3>';
|
||||
$output .= '<p>' . t('<a href=":hal_spec">Hypertext Application Language (HAL)</a> is a format that supports the linking required for hypermedia APIs.', array(':hal_spec' => 'http://stateless.co/hal_specification.html')) . '</p>';
|
||||
$output .= '<p>' . t('Hypermedia APIs are a style of Web API that uses URIs to identify resources and the <a href=":link_rel">link relations</a> between them, enabling API consumers to follow links to discover API functionality.', array(':link_rel' => 'http://en.wikipedia.org/wiki/Link_relation')) . '</p>';
|
||||
$output .= '<p>' . t('Hypermedia APIs are a style of Web API that uses URIs to identify resources and the <a href="http://wikipedia.org/wiki/Link_relation">link relations</a> between them, enabling API consumers to follow links to discover API functionality.') . '</p>';
|
||||
$output .= '<p>' . t('This module adds support for serializing entities (such as content items, taxonomy terms, etc.) to the JSON version of HAL. For more information, see the <a href=":hal_do">online documentation for the HAL module</a>.', array(':hal_do' => 'https://www.drupal.org/documentation/modules/hal')) . '</p>';
|
||||
return $output;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\hal\Encoder\JsonEncoder.
|
||||
*/
|
||||
|
||||
namespace Drupal\hal\Encoder;
|
||||
|
||||
use Symfony\Component\Serializer\Encoder\JsonEncoder as SymfonyJsonEncoder;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\hal\EventSubscriber\ExceptionHalJsonSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\hal\EventSubscriber;
|
||||
|
||||
use Drupal\Core\EventSubscriber\ExceptionJsonSubscriber;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\hal\HalServiceProvider.
|
||||
*/
|
||||
|
||||
namespace Drupal\hal;
|
||||
|
||||
use Drupal\Core\DependencyInjection\ContainerBuilder;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\hal\Normalizer\ContentEntityNormalizer.
|
||||
*/
|
||||
|
||||
namespace Drupal\hal\Normalizer;
|
||||
|
||||
use Drupal\Component\Utility\NestedArray;
|
||||
|
@ -83,7 +78,6 @@ class ContentEntityNormalizer extends NormalizerBase {
|
|||
);
|
||||
|
||||
// If the fields to use were specified, only output those field values.
|
||||
// Otherwise, output all field values except internal ID.
|
||||
if (isset($context['included_fields'])) {
|
||||
$fields = array();
|
||||
foreach ($context['included_fields'] as $field_name) {
|
||||
|
@ -93,12 +87,9 @@ class ContentEntityNormalizer extends NormalizerBase {
|
|||
else {
|
||||
$fields = $entity->getFields();
|
||||
}
|
||||
// Ignore the entity ID and revision ID.
|
||||
$exclude = array($entity->getEntityType()->getKey('id'), $entity->getEntityType()->getKey('revision'));
|
||||
foreach ($fields as $field) {
|
||||
// Continue if this is an excluded field or the current user does not have
|
||||
// access to view it.
|
||||
if (in_array($field->getFieldDefinition()->getName(), $exclude) || !$field->access('view', $context['account'])) {
|
||||
// Continue if the current user does not have access to view this field.
|
||||
if (!$field->access('view', $context['account'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\hal\Normalizer\EntityReferenceItemNormalizer.
|
||||
*/
|
||||
|
||||
namespace Drupal\hal\Normalizer;
|
||||
|
||||
use Drupal\Core\Entity\FieldableEntityInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\hal\Normalizer\FieldItemNormalizer.
|
||||
*/
|
||||
|
||||
namespace Drupal\hal\Normalizer;
|
||||
|
||||
use Drupal\Core\Field\FieldItemInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\hal\Normalizer\FieldNormalizer.
|
||||
*/
|
||||
|
||||
namespace Drupal\hal\Normalizer;
|
||||
|
||||
use Drupal\Component\Utility\NestedArray;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\hal\Normalizer\FileEntityNormalizer.
|
||||
*/
|
||||
|
||||
namespace Drupal\hal\Normalizer;
|
||||
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\hal\Normalizer\NormalizerBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\hal\Normalizer;
|
||||
|
||||
use Drupal\serialization\Normalizer\NormalizerBase as SerializationNormalizerBase;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\hal\Tests\FileDenormalizeTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\hal\Tests;
|
||||
|
||||
use Drupal\file\Entity\File;
|
||||
|
@ -36,7 +31,7 @@ class FileDenormalizeTest extends WebTestBase {
|
|||
'status' => FILE_STATUS_PERMANENT,
|
||||
);
|
||||
// Create a new file entity.
|
||||
$file = entity_create('file', $file_params);
|
||||
$file = File::create($file_params);
|
||||
file_put_contents($file->getFileUri(), 'hello world');
|
||||
$file->save();
|
||||
|
||||
|
@ -50,7 +45,7 @@ class FileDenormalizeTest extends WebTestBase {
|
|||
$this->assertTrue(file_exists($denormalized->getFileUri()), 'The temporary file was found.');
|
||||
|
||||
$this->assertIdentical($file->uuid(), $denormalized->uuid(), 'The expected UUID was found');
|
||||
$this->assertIdentical($file->getMimeType(), $denormalized->getMimeType(), 'The expected mime type was found.');
|
||||
$this->assertIdentical($file->getMimeType(), $denormalized->getMimeType(), 'The expected MIME type was found.');
|
||||
$this->assertIdentical($file->getFilename(), $denormalized->getFilename(), 'The expected filename was found.');
|
||||
$this->assertTrue($denormalized->isPermanent(), 'The file has a permanent status.');
|
||||
|
||||
|
@ -72,7 +67,7 @@ class FileDenormalizeTest extends WebTestBase {
|
|||
$this->assertIdentical('temporary://' . $file_name, $denormalized->getFileUri(), 'The expected file URI was found.');
|
||||
$this->assertTrue(file_exists($denormalized->getFileUri()), 'The temporary file was found.');
|
||||
|
||||
$this->assertIdentical('text/plain', $denormalized->getMimeType(), 'The expected mime type was found.');
|
||||
$this->assertIdentical('text/plain', $denormalized->getMimeType(), 'The expected MIME type was found.');
|
||||
$this->assertIdentical($file_name, $denormalized->getFilename(), 'The expected filename was found.');
|
||||
$this->assertFalse($denormalized->isPermanent(), 'The file has a permanent status.');
|
||||
}
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\hal\Tests\DenormalizeTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\hal\Tests;
|
||||
namespace Drupal\Tests\hal\Kernel;
|
||||
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\field\Entity\FieldConfig;
|
|
@ -1,20 +1,21 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\hal\Tests\EntityTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\hal\Tests;
|
||||
namespace Drupal\Tests\hal\Kernel;
|
||||
|
||||
use Drupal\comment\Tests\CommentTestTrait;
|
||||
use Drupal\comment\Entity\Comment;
|
||||
use Drupal\node\Entity\Node;
|
||||
use Drupal\user\Entity\User;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
use Drupal\taxonomy\Entity\Term;
|
||||
use Drupal\taxonomy\Entity\Vocabulary;
|
||||
|
||||
/**
|
||||
* Tests that nodes and terms are correctly normalized and denormalized.
|
||||
*
|
||||
* @group hal
|
||||
*/
|
||||
class EntityTest extends NormalizerTestBase {
|
||||
class EntityNormalizeTest extends NormalizerTestBase {
|
||||
|
||||
use CommentTestTrait;
|
||||
|
||||
|
@ -42,10 +43,10 @@ class EntityTest extends NormalizerTestBase {
|
|||
* Tests the normalization of nodes.
|
||||
*/
|
||||
public function testNode() {
|
||||
$node_type = entity_create('node_type', array('type' => 'example_type'));
|
||||
$node_type = NodeType::create(['type' => 'example_type']);
|
||||
$node_type->save();
|
||||
|
||||
$user = entity_create('user', array('name' => $this->randomMachineName()));
|
||||
$user = User::create(['name' => $this->randomMachineName()]);
|
||||
$user->save();
|
||||
|
||||
// Add comment type.
|
||||
|
@ -57,57 +58,49 @@ class EntityTest extends NormalizerTestBase {
|
|||
|
||||
$this->addDefaultCommentField('node', 'example_type');
|
||||
|
||||
$node = entity_create('node', array(
|
||||
$node = Node::create([
|
||||
'title' => $this->randomMachineName(),
|
||||
'uid' => $user->id(),
|
||||
'type' => $node_type->id(),
|
||||
'status' => NODE_PUBLISHED,
|
||||
'promote' => 1,
|
||||
'sticky' => 0,
|
||||
'body' => array(
|
||||
'body' => [
|
||||
'value' => $this->randomMachineName(),
|
||||
'format' => $this->randomMachineName(),
|
||||
),
|
||||
'format' => $this->randomMachineName()
|
||||
],
|
||||
'revision_log' => $this->randomString(),
|
||||
));
|
||||
]);
|
||||
$node->save();
|
||||
|
||||
$original_values = $node->toArray();
|
||||
unset($original_values['nid']);
|
||||
unset($original_values['vid']);
|
||||
|
||||
$normalized = $this->serializer->normalize($node, $this->format);
|
||||
|
||||
/** @var \Drupal\node\NodeInterface $denormalized_node */
|
||||
$denormalized_node = $this->serializer->denormalize($normalized, 'Drupal\node\Entity\Node', $this->format);
|
||||
|
||||
// Verify that the ID and revision ID were skipped by the normalizer.
|
||||
$this->assertEqual(NULL, $denormalized_node->id());
|
||||
$this->assertEqual(NULL, $denormalized_node->getRevisionId());
|
||||
|
||||
// Loop over the remaining fields and verify that they are identical.
|
||||
foreach ($original_values as $field_name => $field_values) {
|
||||
$this->assertEqual($field_values, $denormalized_node->get($field_name)->getValue());
|
||||
}
|
||||
$this->assertEqual($original_values, $denormalized_node->toArray(), 'Node values are restored after normalizing and denormalizing.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the normalization of terms.
|
||||
*/
|
||||
public function testTerm() {
|
||||
$vocabulary = entity_create('taxonomy_vocabulary', array('vid' => 'example_vocabulary'));
|
||||
$vocabulary = Vocabulary::create(['vid' => 'example_vocabulary']);
|
||||
$vocabulary->save();
|
||||
|
||||
$account = entity_create('user', array('name' => $this->randomMachineName()));
|
||||
$account = User::create(['name' => $this->randomMachineName()]);
|
||||
$account->save();
|
||||
|
||||
// @todo Until https://www.drupal.org/node/2327935 is fixed, if no parent is
|
||||
// set, the test fails because target_id => 0 is reserialized to NULL.
|
||||
$term_parent = entity_create('taxonomy_term', array(
|
||||
$term_parent = Term::create([
|
||||
'name' => $this->randomMachineName(),
|
||||
'vid' => $vocabulary->id(),
|
||||
));
|
||||
]);
|
||||
$term_parent->save();
|
||||
$term = entity_create('taxonomy_term', array(
|
||||
$term = Term::create([
|
||||
'name' => $this->randomMachineName(),
|
||||
'vid' => $vocabulary->id(),
|
||||
'description' => array(
|
||||
|
@ -115,33 +108,27 @@ class EntityTest extends NormalizerTestBase {
|
|||
'format' => $this->randomMachineName(),
|
||||
),
|
||||
'parent' => $term_parent->id(),
|
||||
));
|
||||
]);
|
||||
$term->save();
|
||||
|
||||
$original_values = $term->toArray();
|
||||
unset($original_values['tid']);
|
||||
|
||||
$normalized = $this->serializer->normalize($term, $this->format, ['account' => $account]);
|
||||
|
||||
/** @var \Drupal\taxonomy\TermInterface $denormalized_term */
|
||||
$denormalized_term = $this->serializer->denormalize($normalized, 'Drupal\taxonomy\Entity\Term', $this->format, ['account' => $account]);
|
||||
|
||||
// Verify that the ID and revision ID were skipped by the normalizer.
|
||||
$this->assertEqual(NULL, $denormalized_term->id());
|
||||
|
||||
// Loop over the remaining fields and verify that they are identical.
|
||||
foreach ($original_values as $field_name => $field_values) {
|
||||
$this->assertEqual($field_values, $denormalized_term->get($field_name)->getValue());
|
||||
}
|
||||
$this->assertEqual($original_values, $denormalized_term->toArray(), 'Term values are restored after normalizing and denormalizing.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the normalization of comments.
|
||||
*/
|
||||
public function testComment() {
|
||||
$node_type = entity_create('node_type', array('type' => 'example_type'));
|
||||
$node_type = NodeType::create(['type' => 'example_type']);
|
||||
$node_type->save();
|
||||
|
||||
$account = entity_create('user', array('name' => $this->randomMachineName()));
|
||||
$account = User::create(['name' => $this->randomMachineName()]);
|
||||
$account->save();
|
||||
|
||||
// Add comment type.
|
||||
|
@ -153,21 +140,21 @@ class EntityTest extends NormalizerTestBase {
|
|||
|
||||
$this->addDefaultCommentField('node', 'example_type');
|
||||
|
||||
$node = entity_create('node', array(
|
||||
$node = Node::create([
|
||||
'title' => $this->randomMachineName(),
|
||||
'uid' => $account->id(),
|
||||
'type' => $node_type->id(),
|
||||
'status' => NODE_PUBLISHED,
|
||||
'promote' => 1,
|
||||
'sticky' => 0,
|
||||
'body' => array(
|
||||
'body' => [[
|
||||
'value' => $this->randomMachineName(),
|
||||
'format' => $this->randomMachineName(),
|
||||
)
|
||||
));
|
||||
'format' => $this->randomMachineName()
|
||||
]],
|
||||
]);
|
||||
$node->save();
|
||||
|
||||
$parent_comment = entity_create('comment', array(
|
||||
$parent_comment = Comment::create(array(
|
||||
'uid' => $account->id(),
|
||||
'subject' => $this->randomMachineName(),
|
||||
'comment_body' => [
|
||||
|
@ -180,7 +167,7 @@ class EntityTest extends NormalizerTestBase {
|
|||
));
|
||||
$parent_comment->save();
|
||||
|
||||
$comment = entity_create('comment', array(
|
||||
$comment = Comment::create(array(
|
||||
'uid' => $account->id(),
|
||||
'subject' => $this->randomMachineName(),
|
||||
'comment_body' => [
|
||||
|
@ -197,9 +184,9 @@ class EntityTest extends NormalizerTestBase {
|
|||
$comment->save();
|
||||
|
||||
$original_values = $comment->toArray();
|
||||
// cid will not exist and hostname will always be denied view access.
|
||||
// Hostname will always be denied view access.
|
||||
// No value will exist for name as this is only for anonymous users.
|
||||
unset($original_values['cid'], $original_values['hostname'], $original_values['name']);
|
||||
unset($original_values['hostname'], $original_values['name']);
|
||||
|
||||
$normalized = $this->serializer->normalize($comment, $this->format, ['account' => $account]);
|
||||
|
||||
|
@ -207,19 +194,13 @@ class EntityTest extends NormalizerTestBase {
|
|||
// data.
|
||||
$this->assertFalse(array_key_exists('hostname', $normalized), 'Hostname was not found in normalized comment data.');
|
||||
|
||||
/** @var \Drupal\comment\CommentInterface $denormalized_comment */
|
||||
$denormalized_comment = $this->serializer->denormalize($normalized, 'Drupal\comment\Entity\Comment', $this->format, ['account' => $account]);
|
||||
|
||||
// Verify that the ID and revision ID were skipped by the normalizer.
|
||||
$this->assertEqual(NULL, $denormalized_comment->id());
|
||||
|
||||
// Loop over the remaining fields and verify that they are identical.
|
||||
foreach ($original_values as $field_name => $field_values) {
|
||||
// The target field comes with revision id which is not set.
|
||||
if (array_key_exists('revision_id', $field_values[0])) {
|
||||
unset($field_values[0]['revision_id']);
|
||||
}
|
||||
$this->assertEqual($field_values, $denormalized_comment->get($field_name)->getValue());
|
||||
}
|
||||
// Before comparing, unset values that are expected to differ.
|
||||
$denormalized_comment_values = $denormalized_comment->toArray();
|
||||
unset($denormalized_comment_values['hostname'], $denormalized_comment_values['name']);
|
||||
$this->assertEqual($original_values, $denormalized_comment_values, 'The expected comment values are restored after normalizing and denormalizing.');
|
||||
}
|
||||
|
||||
}
|
|
@ -1,13 +1,9 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\hal\Tests\FileNormalizeTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\hal\Tests;
|
||||
namespace Drupal\Tests\hal\Kernel;
|
||||
|
||||
use Drupal\Core\Cache\MemoryBackend;
|
||||
use Drupal\file\Entity\File;
|
||||
use Drupal\hal\Encoder\JsonEncoder;
|
||||
use Drupal\hal\Normalizer\FieldItemNormalizer;
|
||||
use Drupal\hal\Normalizer\FileEntityNormalizer;
|
||||
|
@ -65,7 +61,7 @@ class FileNormalizeTest extends NormalizerTestBase {
|
|||
'status' => FILE_STATUS_PERMANENT,
|
||||
);
|
||||
// Create a new file entity.
|
||||
$file = entity_create('file', $file_params);
|
||||
$file = File::create($file_params);
|
||||
file_put_contents($file->getFileUri(), 'hello world');
|
||||
$file->save();
|
||||
|
|
@ -1,14 +1,10 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\hal\Tests\NormalizeTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\hal\Tests;
|
||||
namespace Drupal\Tests\hal\Kernel;
|
||||
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\entity_test\Entity\EntityTest;
|
||||
|
||||
/**
|
||||
* Tests that entities can be normalized in HAL.
|
||||
|
@ -30,9 +26,9 @@ class NormalizeTest extends NormalizerTestBase {
|
|||
* Tests the normalize function.
|
||||
*/
|
||||
public function testNormalize() {
|
||||
$target_entity_de = entity_create('entity_test', (array('langcode' => 'de', 'field_test_entity_reference' => NULL)));
|
||||
$target_entity_de = EntityTest::create((array('langcode' => 'de', 'field_test_entity_reference' => NULL)));
|
||||
$target_entity_de->save();
|
||||
$target_entity_en = entity_create('entity_test', (array('langcode' => 'en', 'field_test_entity_reference' => NULL)));
|
||||
$target_entity_en = EntityTest::create((array('langcode' => 'en', 'field_test_entity_reference' => NULL)));
|
||||
$target_entity_en->save();
|
||||
|
||||
// Create a German entity.
|
||||
|
@ -55,7 +51,7 @@ class NormalizeTest extends NormalizerTestBase {
|
|||
)
|
||||
);
|
||||
|
||||
$entity = entity_create('entity_test', $values);
|
||||
$entity = EntityTest::create($values);
|
||||
$entity->save();
|
||||
// Add an English value for name and entity reference properties.
|
||||
$entity->addTranslation('en')->set('name', array(0 => array('value' => $translation_values['name'])));
|
||||
|
@ -127,6 +123,11 @@ class NormalizeTest extends NormalizerTestBase {
|
|||
),
|
||||
),
|
||||
),
|
||||
'id' => array(
|
||||
array(
|
||||
'value' => $entity->id(),
|
||||
),
|
||||
),
|
||||
'uuid' => array(
|
||||
array(
|
||||
'value' => $entity->uuid(),
|
||||
|
@ -159,7 +160,7 @@ class NormalizeTest extends NormalizerTestBase {
|
|||
$this->assertEqual($normalized['_links']['self'], $expected_array['_links']['self'], 'self link placed correctly.');
|
||||
// @todo Test curies.
|
||||
// @todo Test type.
|
||||
$this->assertFalse(isset($normalized['id']), 'Internal id is not exposed.');
|
||||
$this->assertEqual($normalized['id'], $expected_array['id'], 'Internal id is exposed.');
|
||||
$this->assertEqual($normalized['uuid'], $expected_array['uuid'], 'Non-translatable fields is normalized.');
|
||||
$this->assertEqual($normalized['name'], $expected_array['name'], 'Translatable field with multiple language values is normalized.');
|
||||
$this->assertEqual($normalized['field_test_text'], $expected_array['field_test_text'], 'Field with properties is normalized.');
|
|
@ -1,13 +1,9 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\hal\Tests\NormalizerTestBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\hal\Tests;
|
||||
namespace Drupal\Tests\hal\Kernel;
|
||||
|
||||
use Drupal\Core\Cache\MemoryBackend;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\hal\Encoder\JsonEncoder;
|
||||
use Drupal\hal\Normalizer\ContentEntityNormalizer;
|
||||
use Drupal\hal\Normalizer\EntityReferenceItemNormalizer;
|
||||
|
@ -20,8 +16,9 @@ use Drupal\rest\LinkManager\TypeLinkManager;
|
|||
use Drupal\serialization\EntityResolver\ChainEntityResolver;
|
||||
use Drupal\serialization\EntityResolver\TargetIdResolver;
|
||||
use Drupal\serialization\EntityResolver\UuidResolver;
|
||||
use Drupal\simpletest\KernelTestBase;
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
use Symfony\Component\Serializer\Serializer;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
|
||||
/**
|
||||
* Test the HAL normalizer.
|
||||
|
@ -61,7 +58,6 @@ abstract class NormalizerTestBase extends KernelTestBase {
|
|||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->installSchema('system', array('url_alias', 'router'));
|
||||
$this->installEntitySchema('user');
|
||||
$this->installEntitySchema('entity_test');
|
||||
// If the concrete test sub-class installs the Node or Comment modules,
|
||||
|
@ -93,33 +89,33 @@ abstract class NormalizerTestBase extends KernelTestBase {
|
|||
))->save();
|
||||
|
||||
// Create the test text field.
|
||||
entity_create('field_storage_config', array(
|
||||
FieldStorageConfig::create(array(
|
||||
'field_name' => 'field_test_text',
|
||||
'entity_type' => 'entity_test',
|
||||
'type' => 'text',
|
||||
))->save();
|
||||
entity_create('field_config', array(
|
||||
FieldConfig::create([
|
||||
'entity_type' => 'entity_test',
|
||||
'field_name' => 'field_test_text',
|
||||
'bundle' => 'entity_test',
|
||||
'translatable' => FALSE,
|
||||
))->save();
|
||||
])->save();
|
||||
|
||||
// Create the test translatable field.
|
||||
entity_create('field_storage_config', array(
|
||||
FieldStorageConfig::create(array(
|
||||
'field_name' => 'field_test_translatable_text',
|
||||
'entity_type' => 'entity_test',
|
||||
'type' => 'text',
|
||||
))->save();
|
||||
entity_create('field_config', array(
|
||||
FieldConfig::create([
|
||||
'entity_type' => 'entity_test',
|
||||
'field_name' => 'field_test_translatable_text',
|
||||
'bundle' => 'entity_test',
|
||||
'translatable' => TRUE,
|
||||
))->save();
|
||||
])->save();
|
||||
|
||||
// Create the test entity reference field.
|
||||
entity_create('field_storage_config', array(
|
||||
FieldStorageConfig::create(array(
|
||||
'field_name' => 'field_test_entity_reference',
|
||||
'entity_type' => 'entity_test',
|
||||
'type' => 'entity_reference',
|
||||
|
@ -127,12 +123,12 @@ abstract class NormalizerTestBase extends KernelTestBase {
|
|||
'target_type' => 'entity_test',
|
||||
),
|
||||
))->save();
|
||||
entity_create('field_config', array(
|
||||
FieldConfig::create([
|
||||
'entity_type' => 'entity_test',
|
||||
'field_name' => 'field_test_entity_reference',
|
||||
'bundle' => 'entity_test',
|
||||
'translatable' => TRUE,
|
||||
))->save();
|
||||
])->save();
|
||||
|
||||
$entity_manager = \Drupal::entityManager();
|
||||
$link_manager = new LinkManager(new TypeLinkManager(new MemoryBackend('default'), \Drupal::moduleHandler(), \Drupal::service('config.factory'), \Drupal::service('request_stack')), new RelationLinkManager(new MemoryBackend('default'), $entity_manager, \Drupal::moduleHandler(), \Drupal::service('config.factory'), \Drupal::service('request_stack')));
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\hal\Unit\FieldItemNormalizerDenormalizeExceptionsUnitTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\hal\Unit;
|
||||
|
||||
use Drupal\hal\Normalizer\FieldItemNormalizer;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\hal\Unit\FieldNormalizerDenormalizeExceptionsUnitTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\hal\Unit;
|
||||
|
||||
use Drupal\hal\Normalizer\FieldNormalizer;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\hal\Unit\NormalizerDenormalizeExceptionsUnitTestBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\hal\Unit;
|
||||
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
|
Reference in a new issue