/** * @covers ::delete * @covers ::doDelete */ public function testDeleteNothing() { $this->setUpKeyValueEntityStorage(); $this->moduleHandler->expects($this->never())->method($this->anything()); $this->keyValueStore->expects($this->never())->method('delete'); $this->keyValueStore->expects($this->never())->method('deleteMultiple'); $this->entityStorage->delete(array()); }
/** * Tests fetching the derivatives on a view with a local task and a parent. * * The parent is defined by another module, not views. */ public function testGetDerivativeDefinitionsWithExistingLocalTask() { $executable = $this->getMockBuilder('Drupal\\views\\ViewExecutable')->disableOriginalConstructor()->getMock(); $storage = $this->getMockBuilder('Drupal\\views\\Entity\\View')->disableOriginalConstructor()->getMock(); $storage->expects($this->any())->method('id')->will($this->returnValue('example_view')); $storage->expects($this->any())->method('getExecutable')->willReturn($executable); $executable->storage = $storage; $this->viewStorage->expects($this->any())->method('load')->with('example_view')->willReturn($storage); $display_plugin = $this->getMockBuilder('Drupal\\views\\Plugin\\views\\display\\PathPluginBase')->setMethods(array('getOption', 'getPath'))->disableOriginalConstructor()->getMockForAbstractClass(); $display_plugin->expects($this->exactly(2))->method('getOption')->with('menu')->will($this->returnValue(array('type' => 'tab', 'weight' => 12, 'title' => 'Example title'))); $display_plugin->expects($this->once())->method('getPath')->will($this->returnValue('path/example')); $executable->display_handler = $display_plugin; $result = [['example_view', 'page_1']]; $this->localTaskDerivative->setApplicableMenuViews($result); // Mock the view route names state. $view_route_names = array(); $view_route_names['example_view.page_1'] = 'view.example_view.page_1'; $this->state->expects($this->exactly(2))->method('get')->with('views.view_route_names')->will($this->returnValue($view_route_names)); // Mock the route provider. $route_collection = new RouteCollection(); $route_collection->add('test_route', new Route('/path')); $this->routeProvider->expects($this->any())->method('getRoutesByPattern')->with('/path')->will($this->returnValue($route_collection)); // Setup the existing local task of the test_route. $definitions['test_route_tab'] = $other_tab = array('route_name' => 'test_route', 'title' => 'Test route', 'base_route' => 'test_route'); $definitions += $this->localTaskDerivative->getDerivativeDefinitions($this->baseDefinition); // Setup the prefix of the derivative. $definitions['views_view:view.example_view.page_1'] = $definitions['view.example_view.page_1']; unset($definitions['view.example_view.page_1']); $this->localTaskDerivative->alterLocalTasks($definitions); $plugin = $definitions['views_view:view.example_view.page_1']; $this->assertCount(2, $definitions); // Ensure the other local task was not changed. $this->assertEquals($other_tab, $definitions['test_route_tab']); $this->assertEquals('view.example_view.page_1', $plugin['route_name']); $this->assertEquals(12, $plugin['weight']); $this->assertEquals('Example title', $plugin['title']); $this->assertEquals($this->baseDefinition['class'], $plugin['class']); $this->assertEquals('test_route', $plugin['base_route']); }