function StaticMenuLinkOverridesTest::testDeleteOverrides

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Menu/StaticMenuLinkOverridesTest.php \Drupal\Tests\Core\Menu\StaticMenuLinkOverridesTest::testDeleteOverrides()
  2. 10 core/tests/Drupal/Tests/Core/Menu/StaticMenuLinkOverridesTest.php \Drupal\Tests\Core\Menu\StaticMenuLinkOverridesTest::testDeleteOverrides()
  3. 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 167

Class

StaticMenuLinkOverridesTest
@coversDefaultClass \Drupal\Core\Menu\StaticMenuLinkOverrides @group Menu

Namespace

Drupal\Tests\Core\Menu

Code

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->createMock('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);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.