You are here

public function StaticMenuLinkOverridesTest::testSaveOverride in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Menu/StaticMenuLinkOverridesTest.php \Drupal\Tests\Core\Menu\StaticMenuLinkOverridesTest::testSaveOverride()

Tests the saveOverride method.

@covers ::saveOverride @covers ::loadOverride @covers ::getConfig

File

core/tests/Drupal/Tests/Core/Menu/StaticMenuLinkOverridesTest.php, line 104
Contains \Drupal\Tests\Core\Menu\StaticMenuLinkOverridesTest.

Class

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

Namespace

Drupal\Tests\Core\Menu

Code

public function testSaveOverride() {
  $config = $this
    ->getMockBuilder('Drupal\\Core\\Config\\Config')
    ->disableOriginalConstructor()
    ->getMock();
  $config
    ->expects($this
    ->at(0))
    ->method('get')
    ->with('definitions')
    ->will($this
    ->returnValue(array()));
  $config
    ->expects($this
    ->at(1))
    ->method('get')
    ->with('definitions')
    ->will($this
    ->returnValue(array()));
  $definition_save_1 = array(
    'definitions' => array(
      'test1' => array(
        'parent' => 'test0',
        'menu_name' => '',
        'weight' => 0,
        'expanded' => FALSE,
        'enabled' => FALSE,
      ),
    ),
  );
  $definitions_save_2 = array(
    'definitions' => array(
      'test1' => array(
        'parent' => 'test0',
        'menu_name' => '',
        'weight' => 0,
        'expanded' => FALSE,
        'enabled' => FALSE,
      ),
      'test1__la___ma' => array(
        'parent' => 'test1',
        'menu_name' => '',
        'weight' => 0,
        'expanded' => FALSE,
        'enabled' => FALSE,
      ),
    ),
  );
  $config
    ->expects($this
    ->at(2))
    ->method('set')
    ->with('definitions', $definition_save_1['definitions'])
    ->will($this
    ->returnSelf());
  $config
    ->expects($this
    ->at(3))
    ->method('save');
  $config
    ->expects($this
    ->at(4))
    ->method('get')
    ->with('definitions')
    ->will($this
    ->returnValue($definition_save_1['definitions']));
  $config
    ->expects($this
    ->at(5))
    ->method('get')
    ->with('definitions')
    ->will($this
    ->returnValue($definition_save_1['definitions']));
  $config
    ->expects($this
    ->at(6))
    ->method('set')
    ->with('definitions', $definitions_save_2['definitions'])
    ->will($this
    ->returnSelf());
  $config
    ->expects($this
    ->at(7))
    ->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);
  $static_override
    ->saveOverride('test1', array(
    'parent' => 'test0',
  ));
  $static_override
    ->saveOverride('test1.la__ma', array(
    'parent' => 'test1',
  ));
}