You are here

public function FieldLinkTest::testCanonicalizeUriSerialized in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/link/tests/src/Unit/Plugin/migrate/process/FieldLinkTest.php \Drupal\Tests\link\Unit\Plugin\migrate\process\FieldLinkTest::testCanonicalizeUriSerialized()
  2. 9 core/modules/link/tests/src/Unit/Plugin/migrate/process/FieldLinkTest.php \Drupal\Tests\link\Unit\Plugin\migrate\process\FieldLinkTest::testCanonicalizeUriSerialized()

Tests the attributes that are deeply serialized are discarded.

File

core/modules/link/tests/src/Unit/Plugin/migrate/process/FieldLinkTest.php, line 111

Class

FieldLinkTest
@group Link

Namespace

Drupal\Tests\link\Unit\Plugin\migrate\process

Code

public function testCanonicalizeUriSerialized() {
  $link_plugin = new FieldLink([], '', [], $this
    ->createMock(MigrationInterface::class));
  $migrate_executable = $this
    ->createMock(MigrateExecutableInterface::class);
  $row = new Row();
  $transformed = $link_plugin
    ->transform([
    'url' => '',
    'title' => '',
    'attributes' => serialize(serialize([
      'not too deep',
    ])),
  ], $migrate_executable, $row, NULL);
  $this
    ->assertEquals([
    'not too deep',
  ], $transformed['options']['attributes']);
  $transformed = $link_plugin
    ->transform([
    'url' => '',
    'title' => '',
    'attributes' => serialize(serialize(serialize([
      'too deep',
    ]))),
  ], $migrate_executable, $row, NULL);
  $this
    ->assertEmpty($transformed['options']['attributes']);
}