public function StaticMenuLinkOverridesTest::testDeleteOverrides in Zircon Profile 8
Same name and namespace in other branches
- 8.0 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 172 - Contains \Drupal\Tests\Core\Menu\StaticMenuLinkOverridesTest.
Class
- StaticMenuLinkOverridesTest
- @coversDefaultClass \Drupal\Core\Menu\StaticMenuLinkOverrides @group Menu
Namespace
Drupal\Tests\Core\MenuCode
public function testDeleteOverrides($ids, array $old_definitions, array $new_definitions) {
$config = $this
->getMockBuilder('Drupal\\Core\\Config\\Config')
->disableOriginalConstructor()
->getMock();
$config
->expects($this
->at(0))
->method('get')
->with('definitions')
->will($this
->returnValue($old_definitions));
// Only save if the definitions changes.
if ($old_definitions != $new_definitions) {
$config
->expects($this
->at(1))
->method('set')
->with('definitions', $new_definitions)
->will($this
->returnSelf());
$config
->expects($this
->at(2))
->method('save');
}
$config_factory = $this
->getMock('Drupal\\Core\\Config\\ConfigFactoryInterface');
$config_factory
->expects($this
->once())
->method('getEditable')
->will($this
->returnValue($config));
$static_override = new StaticMenuLinkOverrides($config_factory);
if (is_array($ids)) {
$static_override
->deleteMultipleOverrides($ids);
}
else {
$static_override
->deleteOverride($ids);
}
}