Mercurial > hg > cmmr2012-drupal-site
diff 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 |
line wrap: on
line diff
--- a/core/modules/link/tests/src/Kernel/LinkItemTest.php Thu Feb 28 13:11:55 2019 +0000 +++ b/core/modules/link/tests/src/Kernel/LinkItemTest.php Thu May 09 15:34:47 2019 +0100 @@ -138,11 +138,11 @@ $this->assertNull($entity->field_test->title); $this->assertIdentical($entity->field_test->options, []); - // Check that if set uri and serialize options then the default values are - // properly initialized. + // Check that if we set uri and options then the default values are properly + // initialized. $entity->field_test = [ 'uri' => 'internal:/node/add', - 'options' => serialize(['query' => NULL]), + 'options' => ['query' => NULL], ]; $this->assertEqual($entity->field_test->uri, 'internal:/node/add'); $this->assertNull($entity->field_test->title); @@ -174,4 +174,23 @@ $this->entityValidateAndSave($entity); } + /** + * Tests the deprecated behavior of LinkItem::setValue(). + * + * @group legacy + * @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. + */ + public function testSerializedOptions() { + // Check that if we set uri and options then the default values are + // properly initialized. + $entity = EntityTest::create(); + $entity->set('field_test', [ + 'uri' => 'internal:/node/add', + 'options' => serialize(['query' => NULL]), + ]); + $this->assertEquals('internal:/node/add', $entity->get('field_test')->uri); + $this->assertNull($entity->get('field_test')->title); + $this->assertNull($entity->get('field_test')->options['query']); + } + }