function FieldLinkTest::testCanonicalizeUriSerialized

Same name in other branches
  1. 8.9.x core/modules/link/tests/src/Unit/Plugin/migrate/process/FieldLinkTest.php \Drupal\Tests\link\Unit\Plugin\migrate\process\FieldLinkTest::testCanonicalizeUriSerialized()
  2. 10 core/modules/link/tests/src/Unit/Plugin/migrate/process/FieldLinkTest.php \Drupal\Tests\link\Unit\Plugin\migrate\process\FieldLinkTest::testCanonicalizeUriSerialized()
  3. 11.x 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']);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.