diff --git a/core/modules/system/tests/Drupal/system/Tests/Plugin/Type/MenuLocalTaskManagerTest.php b/core/modules/system/tests/Drupal/system/Tests/Plugin/Type/MenuLocalTaskManagerTest.php index caf0598..876f03d 100644 --- a/core/modules/system/tests/Drupal/system/Tests/Plugin/Type/MenuLocalTaskManagerTest.php +++ b/core/modules/system/tests/Drupal/system/Tests/Plugin/Type/MenuLocalTaskManagerTest.php @@ -62,6 +62,13 @@ class MenuLocalTaskManagerTest extends UnitTestCase { */ protected $factory; + /** + * The mocked local task plugin base class. + * + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $basePlugin; + public static function getInfo() { return array( 'name' => 'Local tasks manager.', @@ -70,7 +77,6 @@ public static function getInfo() { ); } - /** * {@inheritdoc} */ @@ -83,6 +89,11 @@ protected function setUp() { $this->pluginDiscovery = $this->getMock('Drupal\Component\Plugin\Discovery\DiscoveryInterface'); $this->factory = $this->getMock('Drupal\Component\Plugin\Factory\FactoryInterface'); + $this->basePlugin = $this + ->getMockBuilder('Drupal\system\Plugin\MenuLocalTaskBase') + ->disableOriginalConstructor() + ->getMock(); + $this->setupLocalTaskManager(); } @@ -142,21 +153,50 @@ public function testGetLocalTasksForRouteSingleLevelTitle() { } /** + * Tests that an exception is thrown when the getTitle method is missing. + * + * @see \Drupal\system\Plugin\Type\MenuLocalTaskManager::getTitle() + * + * @expectedException \BadMethodCallException + */ + public function testGetTitleException() { + $menu_local_task = $this->getMock('Drupal\system\Plugin\MenuLocalTaskInterface'); + $menu_local_task->expects($this->never()) + ->method('getTitle'); + + $this->manager->getTitle($menu_local_task); + } + + /** * Tests the getTitle method. * * @see \Drupal\system\Plugin\Type\MenuLocalTaskManager::getTitle() */ public function testGetTitle() { - $menu_local_task = $this->getMock('Drupal\system\Plugin\MenuLocalTaskInterface'); - $menu_local_task->expects($this->once()) + $this->basePlugin->expects($this->once()) ->method('getTitle'); $this->controllerResolver->expects($this->once()) ->method('getArguments') - ->with($this->request, array($menu_local_task, 'getTitle')) + ->with($this->request, array($this->basePlugin, 'getTitle')) ->will($this->returnValue(array())); - $this->manager->getTitle($menu_local_task); + $this->manager->getTitle($this->basePlugin); + } + + /** + * Tests that an exception is thrown when the getPath method is missing. + * + * @see \Drupal\system\Plugin\Type\MenuLocalTaskManager::getPath() + * + * @expectedException \BadMethodCallException + */ + public function testGetPathException() { + $menu_local_task = $this->getMock('Drupal\system\Plugin\MenuLocalTaskInterface'); + $menu_local_task->expects($this->never()) + ->method('getPath'); + + $this->manager->getPath($menu_local_task); } /** @@ -165,16 +205,15 @@ public function testGetTitle() { * @see \Drupal\system\Plugin\Type\MenuLocalTaskManager::getPath() */ public function testGetPath() { - $menu_local_task = $this->getMock('Drupal\system\Plugin\MenuLocalTaskInterface'); - $menu_local_task->expects($this->once()) + $this->basePlugin->expects($this->once()) ->method('getPath'); $this->controllerResolver->expects($this->once()) ->method('getArguments') - ->with($this->request, array($menu_local_task, 'getPath')) + ->with($this->request, array($this->basePlugin, 'getPath')) ->will($this->returnValue(array())); - $this->manager->getPath($menu_local_task); + $this->manager->getPath($this->basePlugin); } /**