function MenuTreeParametersTest::testAddExpanded
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Menu/MenuTreeParametersTest.php \Drupal\Tests\Core\Menu\MenuTreeParametersTest::testAddExpanded()
- 8.9.x core/tests/Drupal/Tests/Core/Menu/MenuTreeParametersTest.php \Drupal\Tests\Core\Menu\MenuTreeParametersTest::testAddExpanded()
- 10 core/tests/Drupal/Tests/Core/Menu/MenuTreeParametersTest.php \Drupal\Tests\Core\Menu\MenuTreeParametersTest::testAddExpanded()
Tests addExpandedParents().
@covers ::addExpandedParents
File
-
core/
tests/ Drupal/ Tests/ Core/ Menu/ MenuTreeParametersTest.php, line 60
Class
- MenuTreeParametersTest
- Tests the menu link tree parameters value object.
Namespace
Drupal\Tests\Core\MenuCode
public function testAddExpanded() : void {
$parameters = new MenuTreeParameters();
// Verify default value.
$this->assertEquals([], $parameters->expandedParents);
// Add actual menu link plugin IDs to be expanded.
$parameters->addExpandedParents([
'foo',
'bar',
'baz',
]);
$this->assertEquals([
'foo',
'bar',
'baz',
], $parameters->expandedParents);
// Add additional menu link plugin IDs; they should be merged, not replacing
// the old ones.
$parameters->addExpandedParents([
'qux',
'foobar',
]);
$this->assertEquals([
'foo',
'bar',
'baz',
'qux',
'foobar',
], $parameters->expandedParents);
// Add pre-existing menu link plugin IDs; they should not be added again;
// this is a set.
$parameters->addExpandedParents([
'bar',
'foobar',
]);
$this->assertEquals([
'foo',
'bar',
'baz',
'qux',
'foobar',
], $parameters->expandedParents);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.