diff -u b/core/tests/Drupal/Tests/Core/Entity/EntityListControllerTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityListControllerTest.php --- b/core/tests/Drupal/Tests/Core/Entity/EntityListControllerTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityListControllerTest.php @@ -50,6 +50,13 @@ protected $moduleHandler; /** + * The translation manager. + * + * @var \Drupal\Core\StringTranslation\TranslationInterface + */ + protected $translationManager; + + /** * The role storage used for testing. * * @var \Drupal\user\RoleStorageControllerInterface|\PHPUnit_Framework_MockObject_MockObject @@ -74,15 +81,16 @@ $this->roleStorage = $this->getMock('\Drupal\user\RoleStorageControllerInterface'); $this->moduleHandler = $this->getMock('\Drupal\Core\Extension\ModuleHandlerInterface'); $this->entityType = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface'); + $this->translationManager = $this->getMock('\Drupal\Core\StringTranslation\TranslationInterface'); $this->entityListController = new TestEntityListController($this->entityType, $this->roleStorage, $this->moduleHandler); } /** - * Tests getOperations(). + * @covers \Drupal\Core\Entity\EntityListController::getOperations */ public function testGetOperations() { $operations = array( - array( + $this->randomName() => array( 'title' => $this->randomName(), ), ); @@ -92,11 +100,27 @@ ->will($this->returnValue($operations)); $this->moduleHandler->expects($this->once()) ->method('alter') - ->with('entity_operation', $operations, $this->role); + ->with('entity_operation'); + + $map = array( + array('update', TRUE), + array('delete', TRUE), + ); + $this->role->expects($this->any()) + ->method('access') + ->will($this->returnValue(TRUE)); $list = new EntityListController($this->entityType, $this->roleStorage, $this->moduleHandler); + $list->setTranslationManager($this->translationManager); - $list->getOperations($this->role); + $operations = $list->getOperations($this->role); + $this->assertInternalType('array', $operations); + $this->assertArrayHasKey('edit', $operations); + $this->assertInternalType('array', $operations['edit']); + $this->assertArrayHasKey('title', $operations['edit']); + $this->assertArrayHasKey('delete', $operations); + $this->assertInternalType('array', $operations['delete']); + $this->assertArrayHasKey('title', $operations['delete']); } /**