diff -u b/core/lib/Drupal/Core/Entity/EntityListController.php b/core/lib/Drupal/Core/Entity/EntityListController.php --- b/core/lib/Drupal/Core/Entity/EntityListController.php +++ b/core/lib/Drupal/Core/Entity/EntityListController.php @@ -93,7 +93,7 @@ * {@inheritdoc} */ public function getOperations(EntityInterface $entity) { - $operations = array_merge($this->moduleHandler->invokeAll('entity_operation', array($entity)), $this->getDefaultOperations($entity)); + $operations = array_merge($this->moduleHandler()->invokeAll('entity_operation', array($entity)), $this->getDefaultOperations($entity)); $this->moduleHandler->alter('entity_operation', $operations, $entity); uasort($operations, '\Drupal\Component\Utility\SortArray::sortByWeightElement'); 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 @@ -7,6 +7,7 @@ namespace Drupal\Tests\Core\Entity; +use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityListController; use Drupal\entity_test\EntityTestListController; @@ -22,6 +23,13 @@ class EntityListControllerTest extends UnitTestCase { /** + * The service container used for testing. + * + * @var \Drupal\Core\DependencyInjection\ContainerBuilder + */ + protected $container; + + /** * The entity used to construct the EntityListController. * * @var \Drupal\user\RoleInterface|\PHPUnit_Framework_MockObject_MockObject @@ -83,6 +91,8 @@ $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); + $this->container = new ContainerBuilder(); + \Drupal::setContainer($this->container); } /** @@ -102,10 +112,8 @@ ->method('alter') ->with('entity_operation'); - $map = array( - array('update', TRUE), - array('delete', TRUE), - ); + $this->container->set('module_handler', $this->moduleHandler); + $this->role->expects($this->any()) ->method('access') ->will($this->returnValue(TRUE));