public function MenuTreeParametersTest::testAddExpanded in Zircon Profile 8
Same name and namespace in other branches
- 8.0 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 63 - Contains \Drupal\Tests\Core\Menu\MenuTreeParametersTest.
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(array(), $parameters->expandedParents);
// Add actual menu link plugin IDs to be expanded.
$parameters
->addExpandedParents(array(
'foo',
'bar',
'baz',
));
$this
->assertEquals(array(
'foo',
'bar',
'baz',
), $parameters->expandedParents);
// Add additional menu link plugin IDs; they should be merged, not replacing
// the old ones.
$parameters
->addExpandedParents(array(
'qux',
'quux',
));
$this
->assertEquals(array(
'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(array(
'bar',
'quux',
));
$this
->assertEquals(array(
'foo',
'bar',
'baz',
'qux',
'quux',
), $parameters->expandedParents);
}