diff --git a/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityNormalizer.php b/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityNormalizer.php index 5fb5afb..c466952 100644 --- a/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityNormalizer.php +++ b/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityNormalizer.php @@ -57,7 +57,7 @@ public function denormalize($data, $class, $format = null) { ); // If the data specifies a default language, use it to create the entity. if (isset($data['langcode'])) { - $values['langcode'] = $data['langcode']; + $values['langcode'] = $data['langcode'][LANGUAGE_NOT_SPECIFIED][0]['value']; } // Otherwise, if the default language is not specified but there are // translations of field values, explicitly set the entity's default diff --git a/core/modules/jsonld/tests/modules/jsonld_test/jsonld_test.routing.yml b/core/modules/jsonld/tests/modules/jsonld_test/jsonld_test.routing.yml index d02494d..e1584f5 100644 --- a/core/modules/jsonld/tests/modules/jsonld_test/jsonld_test.routing.yml +++ b/core/modules/jsonld/tests/modules/jsonld_test/jsonld_test.routing.yml @@ -2,3 +2,5 @@ jsonld_test_bundle_schema: pattern: 'jsonld-test/content-staging/entity_test/entity_test' defaults: _controller: 'Drupal\jsonld_test\MockSiteSchema::bundle' + requirements: + _access: 'TRUE' diff --git a/core/modules/rest/lib/Drupal/rest/Tests/CreateTest.php b/core/modules/rest/lib/Drupal/rest/Tests/CreateTest.php index 61301a1..bde0a02 100644 --- a/core/modules/rest/lib/Drupal/rest/Tests/CreateTest.php +++ b/core/modules/rest/lib/Drupal/rest/Tests/CreateTest.php @@ -17,9 +17,11 @@ class CreateTest extends RESTTestBase { /** * Modules to enable. * + * @todo Remove jsonld_test once the site schema routes from RDF module work. + * * @var array */ - public static $modules = array('rest', 'entity_test'); + public static $modules = array('rest', 'entity_test', 'jsonld_test'); public static function getInfo() { return array( @@ -47,6 +49,8 @@ public function testCreate() { $entity_values = $this->entityValues($entity_type); $entity = entity_create($entity_type, $entity_values); $serialized = $serializer->serialize($entity, 'drupal_jsonld'); + // @todo HACK: remove once the site schema routes from RDF module work. + $serialized = str_replace('site-schema\\/content-staging\\/entity_test\\/entity_test', 'jsonld-test\\/content-staging\\/entity_test\\/entity_test', $serialized); // Create the entity over the web API. $response = $this->httpRequest('entity/' . $entity_type, 'POST', $serialized, 'application/vnd.drupal.ld+json'); $this->assertResponse('201', 'HTTP response code is correct.'); @@ -59,6 +63,9 @@ public function testCreate() { $loaded_entity = entity_load($entity_type, $id); $this->assertNotIdentical(FALSE, $loaded_entity, 'The new ' . $entity_type . ' was found in the database.'); $this->assertEqual($entity->uuid(), $loaded_entity->uuid(), 'UUID of created entity is correct.'); + // @todo Remove the user reference field for now until deserialization for + // entity references is implemented. + unset($entity_values['user_id']); foreach ($entity_values as $property => $value) { $actual_value = $loaded_entity->get($property); $this->assertEqual($value, $actual_value->value, 'Created property ' . $property . ' expected: ' . $value . ', actual: ' . $actual_value->value);