function StaticMenuLinkOverridesTest::testDeleteOverrides
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Menu/StaticMenuLinkOverridesTest.php \Drupal\Tests\Core\Menu\StaticMenuLinkOverridesTest::testDeleteOverrides()
- 8.9.x core/tests/Drupal/Tests/Core/Menu/StaticMenuLinkOverridesTest.php \Drupal\Tests\Core\Menu\StaticMenuLinkOverridesTest::testDeleteOverrides()
- 11.x core/tests/Drupal/Tests/Core/Menu/StaticMenuLinkOverridesTest.php \Drupal\Tests\Core\Menu\StaticMenuLinkOverridesTest::testDeleteOverrides()
Tests the deleteOverride and deleteOverrides method.
@dataProvider providerTestDeleteOverrides
Parameters
array|string $ids: Either a single ID or multiple ones as array.
array $old_definitions: The definitions before the deleting
array $new_definitions: The definitions after the deleting.
File
-
core/
tests/ Drupal/ Tests/ Core/ Menu/ StaticMenuLinkOverridesTest.php, line 149
Class
- StaticMenuLinkOverridesTest
- @coversDefaultClass \Drupal\Core\Menu\StaticMenuLinkOverrides @group Menu
Namespace
Drupal\Tests\Core\MenuCode
public function testDeleteOverrides($ids, array $old_definitions, array $new_definitions) : void {
$config = $this->getMockBuilder('Drupal\\Core\\Config\\Config')
->disableOriginalConstructor()
->getMock();
$config->expects($this->once())
->method('get')
->with('definitions')
->willReturn($old_definitions);
// Only save if the definitions changes.
$config->expects($old_definitions != $new_definitions ? $this->once() : $this->never())
->method('set')
->with('definitions', $new_definitions)
->willReturnSelf();
$config->expects($old_definitions != $new_definitions ? $this->once() : $this->never())
->method('save');
$config_factory = $this->createMock('Drupal\\Core\\Config\\ConfigFactoryInterface');
$config_factory->expects($this->once())
->method('getEditable')
->willReturn($config);
$static_override = new StaticMenuLinkOverrides($config_factory);
if (is_array($ids)) {
$static_override->deleteMultipleOverrides($ids);
}
else {
$static_override->deleteOverride($ids);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.