You are here

public function MenuTreeParametersTest::testSerialize in Drupal 9

Same name and namespace in other branches
  1. 8 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);
}