public function LinkItemTest::testSerializedOptions in Drupal 8
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.
File
- core/
modules/ link/ tests/ src/ Kernel/ LinkItemTest.php, line 183
Class
- LinkItemTest
- Tests the new entity API for the link field type.
Namespace
Drupal\Tests\link\KernelCode
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']);
}