Mercurial > hg > isophonics-drupal-site
comparison core/modules/link/tests/src/Kernel/LinkItemSerializationTest.php @ 18:af1871eacc83
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:33:08 +0100 |
parents | 129ea1e6d783 |
children |
comparison
equal
deleted
inserted
replaced
17:129ea1e6d783 | 18:af1871eacc83 |
---|---|
78 'attributes' => ['class' => $class], | 78 'attributes' => ['class' => $class], |
79 ]; | 79 ]; |
80 $this->assertSame($options_expected, $deserialized->field_test->options); | 80 $this->assertSame($options_expected, $deserialized->field_test->options); |
81 } | 81 } |
82 | 82 |
83 /** | |
84 * Tests the deserialization. | |
85 */ | |
86 public function testLinkDeserialization() { | |
87 // Create entity. | |
88 $entity = EntityTest::create(); | |
89 $url = 'https://www.drupal.org?test_param=test_value'; | |
90 $parsed_url = UrlHelper::parse($url); | |
91 $title = $this->randomMachineName(); | |
92 $entity->field_test->uri = $parsed_url['path']; | |
93 $entity->field_test->title = $title; | |
94 $entity->field_test->first() | |
95 ->get('options') | |
96 ->set('query', $parsed_url['query']); | |
97 $json = json_decode($this->serializer->serialize($entity, 'json'), TRUE); | |
98 $json['field_test'][0]['options'] = 'string data'; | |
99 $serialized = json_encode($json, TRUE); | |
100 $this->setExpectedException(\LogicException::class, 'The generic FieldItemNormalizer cannot denormalize string values for "options" properties of the "field_test" field (field item class: Drupal\link\Plugin\Field\FieldType\LinkItem).'); | |
101 $this->serializer->deserialize($serialized, EntityTest::class, 'json'); | |
102 } | |
103 | |
83 } | 104 } |