diff --git a/core/modules/user/tests/Drupal/Tests/user/Views/Argument/RolesRidTest.php b/core/modules/user/tests/Drupal/Tests/user/Views/Argument/RolesRidTest.php index 6aafbd0..762558a 100644 --- a/core/modules/user/tests/Drupal/Tests/user/Views/Argument/RolesRidTest.php +++ b/core/modules/user/tests/Drupal/Tests/user/Views/Argument/RolesRidTest.php @@ -60,9 +60,11 @@ public function testTitleQuery() { $config_factory = $this->getConfigFactoryStub($config); $config_storage = $this->getConfigStorageStub($config); - // NULL forces to disable mocking on any method by default. + // Creates a stub roles storage controller and replace the attachLoad method + // with a empty version, because attachLoad calls module_implements. $role_storage_controller = $this->getMock('Drupal\user\RoleStorageController', array('attachLoad'), array('user_role', static::$entityInfo, $config_factory, $config_storage)); + $entity_manager = $this->getMockBuilder('Drupal\Core\Entity\EntityManager') ->disableOriginalConstructor() ->getMock(); @@ -72,15 +74,19 @@ public function testTitleQuery() { ->with($this->equalTo('user_role')) ->will($this->returnValue(static::$entityInfo)); - $container = new ContainerBuilder(); - $container->set('plugin.manager.entity', $entity_manager); - \Drupal::setContainer($container); - $entity_manager ->expects($this->once()) ->method('getStorageController') ->with($this->equalTo('user_role')) ->will($this->returnValue($role_storage_controller)); + + // \Drupal\Core\Entity\Entity::entityInfo() uses an not injected global + // call so set it until entity has the entity info injected. + + $container = new ContainerBuilder(); + $container->set('plugin.manager.entity', $entity_manager); + \Drupal::setContainer($container); + $roles_rid_argument = new RolesRid($config, 'users_roles_rid', array(), $entity_manager); $roles_rid_argument->value = array();