public function MenuTreeParametersTest::testAddExpanded in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Menu/MenuTreeParametersTest.php \Drupal\Tests\Core\Menu\MenuTreeParametersTest::testAddExpanded()
- 9 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 58
Class
- MenuTreeParametersTest
- Tests the menu link tree parameters value object.
Namespace
Drupal\Tests\Core\MenuCode
public function testAddExpanded() {
$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',
'quux',
]);
$this
->assertEquals([
'foo',
'bar',
'baz',
'qux',
'quux',
], $parameters->expandedParents);
// Add pre-existing menu link plugin IDs; they should not be added again;
// this is a set.
$parameters
->addExpandedParents([
'bar',
'quux',
]);
$this
->assertEquals([
'foo',
'bar',
'baz',
'qux',
'quux',
], $parameters->expandedParents);
}