function MenuTreeParametersTest::testSerialize

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Menu/MenuTreeParametersTest.php \Drupal\Tests\Core\Menu\MenuTreeParametersTest::testSerialize()
  2. 10 core/tests/Drupal/Tests/Core/Menu/MenuTreeParametersTest.php \Drupal\Tests\Core\Menu\MenuTreeParametersTest::testSerialize()
  3. 11.x core/tests/Drupal/Tests/Core/Menu/MenuTreeParametersTest.php \Drupal\Tests\Core\Menu\MenuTreeParametersTest::testSerialize()

@covers ::serialize @covers ::unserialize

File

core/tests/Drupal/Tests/Core/Menu/MenuTreeParametersTest.php, line 149

Class

MenuTreeParametersTest
Tests the menu link tree parameters value object.

Namespace

Drupal\Tests\Core\Menu

Code

public function testSerialize() {
    $parameters = new MenuTreeParameters();
    $parameters->setRoot(1);
    $parameters->setMinDepth('2');
    $parameters->setMaxDepth('9');
    $parameters->addExpandedParents([
        '',
        'foo',
    ]);
    $parameters->setActiveTrail([
        '',
        'bar',
    ]);
    $after_serialize = unserialize(serialize($parameters));
    $this->assertSame('1', $after_serialize->root);
    $this->assertSame(2, $after_serialize->minDepth);
    $this->assertSame(9, $after_serialize->maxDepth);
    $this->assertSame([
        '',
        'foo',
    ], $after_serialize->expandedParents);
    $this->assertSame([
        'bar',
    ], $after_serialize->activeTrail);
}

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