function FieldLinkTest::testCanonicalizeUriSerialized

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

Class

FieldLinkTest
@group Link

Namespace

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

Code

public function testCanonicalizeUriSerialized() : void {
    $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.