comparison core/modules/link/tests/src/Kernel/LinkItemTest.php @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents c75dbcec494b
children
comparison
equal deleted inserted replaced
4:a9cd425dd02b 5:12f9dff5fda9
136 $entity->field_test = ['uri' => 'internal:/node/add']; 136 $entity->field_test = ['uri' => 'internal:/node/add'];
137 $this->assertEqual($entity->field_test->uri, 'internal:/node/add'); 137 $this->assertEqual($entity->field_test->uri, 'internal:/node/add');
138 $this->assertNull($entity->field_test->title); 138 $this->assertNull($entity->field_test->title);
139 $this->assertIdentical($entity->field_test->options, []); 139 $this->assertIdentical($entity->field_test->options, []);
140 140
141 // Check that if set uri and serialize options then the default values are 141 // Check that if we set uri and options then the default values are properly
142 // properly initialized. 142 // initialized.
143 $entity->field_test = [ 143 $entity->field_test = [
144 'uri' => 'internal:/node/add', 144 'uri' => 'internal:/node/add',
145 'options' => serialize(['query' => NULL]), 145 'options' => ['query' => NULL],
146 ]; 146 ];
147 $this->assertEqual($entity->field_test->uri, 'internal:/node/add'); 147 $this->assertEqual($entity->field_test->uri, 'internal:/node/add');
148 $this->assertNull($entity->field_test->title); 148 $this->assertNull($entity->field_test->title);
149 $this->assertNull($entity->field_test->options['query']); 149 $this->assertNull($entity->field_test->options['query']);
150 150
172 $entity->field_test_external->generateSampleItems(); 172 $entity->field_test_external->generateSampleItems();
173 $entity->field_test_internal->generateSampleItems(); 173 $entity->field_test_internal->generateSampleItems();
174 $this->entityValidateAndSave($entity); 174 $this->entityValidateAndSave($entity);
175 } 175 }
176 176
177 /**
178 * Tests the deprecated behavior of LinkItem::setValue().
179 *
180 * @group legacy
181 * @expectedDeprecation Support for passing options as a serialized string is deprecated in 8.7.0 and will be removed before Drupal 9.0.0. Pass them as an array instead. See https://www.drupal.org/node/2961643.
182 */
183 public function testSerializedOptions() {
184 // Check that if we set uri and options then the default values are
185 // properly initialized.
186 $entity = EntityTest::create();
187 $entity->set('field_test', [
188 'uri' => 'internal:/node/add',
189 'options' => serialize(['query' => NULL]),
190 ]);
191 $this->assertEquals('internal:/node/add', $entity->get('field_test')->uri);
192 $this->assertNull($entity->get('field_test')->title);
193 $this->assertNull($entity->get('field_test')->options['query']);
194 }
195
177 } 196 }