diff --git a/core/modules/node/tests/Drupal/node/Tests/Plugin/views/field/NodeBulkFormTest.php b/core/modules/node/tests/Drupal/node/Tests/Plugin/views/field/NodeBulkFormTest.php index aec235c..7e1a95e 100644 --- a/core/modules/node/tests/Drupal/node/Tests/Plugin/views/field/NodeBulkFormTest.php +++ b/core/modules/node/tests/Drupal/node/Tests/Plugin/views/field/NodeBulkFormTest.php @@ -7,6 +7,7 @@ namespace Drupal\node\Tests\Plugin\views\field; +use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\node\Plugin\views\field\NodeBulkForm; use Drupal\Tests\UnitTestCase; @@ -26,40 +27,70 @@ public static function getInfo() { } /** + * {@inheritdoc} + */ + protected function tearDown() { + parent::tearDown(); + $container = new ContainerBuilder(); + \Drupal::setContainer($container); + } + + /** * Tests the constructor assignment of actions. */ public function testConstructor() { $actions = array(); for ($i = 1; $i <= 2; $i++) { - $action = $this->getMockBuilder('Drupal\system\Entity\Action') - ->disableOriginalConstructor() - ->getMock(); + $action = $this->getMock('\Drupal\system\ActionConfigEntityInterface'); $action->expects($this->any()) ->method('getType') ->will($this->returnValue('node')); $actions[$i] = $action; } - $action = $this->getMockBuilder('Drupal\system\Entity\Action') - ->disableOriginalConstructor() - ->getMock(); + $action = $this->getMock('\Drupal\system\ActionConfigEntityInterface'); $action->expects($this->any()) ->method('getType') ->will($this->returnValue('user')); $actions[] = $action; - $entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface'); $storage_controller = $this->getMock('Drupal\Core\Entity\EntityStorageControllerInterface'); $storage_controller->expects($this->any()) ->method('loadMultiple') ->will($this->returnValue($actions)); - $entity_manager->expects($this->any()) - ->method('getStorageController') - ->with('action') - ->will($this->returnValue($storage_controller)); - $node_bulk_form = new NodeBulkForm(array(), 'node_bulk_form', array(), $entity_manager); + $views_data = $this->getMockBuilder('Drupal\views\ViewsData') + ->disableOriginalConstructor() + ->getMock(); + $views_data->expects($this->any()) + ->method('get') + ->with('node') + ->will($this->returnValue(array('table' => array('entity type' => 'node')))); + $container = new ContainerBuilder(); + $container->set('views.views_data', $views_data); + \Drupal::setContainer($container); + + $storage = $this->getMock('Drupal\views\ViewStorageInterface'); + $storage->expects($this->any()) + ->method('get') + ->with('base_table') + ->will($this->returnValue('node')); + + $executable = $this->getMockBuilder('Drupal\views\ViewExecutable') + ->disableOriginalConstructor() + ->getMock(); + $executable->storage = $storage; + + $display = $this->getMockBuilder('Drupal\views\Plugin\views\display\DisplayPluginBase') + ->disableOriginalConstructor() + ->getMock(); + + $definition['title'] = ''; + $options = array(); + + $node_bulk_form = new NodeBulkForm(array(), 'node_bulk_form', $definition, $storage_controller); + $node_bulk_form->init($executable, $display, $options); $this->assertAttributeEquals(array_slice($actions, 0, -1, TRUE), 'actions', $node_bulk_form); } diff --git a/core/modules/system/lib/Drupal/system/Plugin/views/field/BulkFormBase.php b/core/modules/system/lib/Drupal/system/Plugin/views/field/BulkFormBase.php index 06ff295..e6100be 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/views/field/BulkFormBase.php +++ b/core/modules/system/lib/Drupal/system/Plugin/views/field/BulkFormBase.php @@ -43,7 +43,7 @@ * The plugin ID for the plugin instance. * @param array $plugin_definition * The plugin implementation definition. - * @param \Drupal\Core\Entity\EntityManagerInterface $storage + * @param \Drupal\Core\Entity\EntityStorageControllerInterface $storage * The action storage controller. */ public function __construct(array $configuration, $plugin_id, array $plugin_definition, EntityStorageControllerInterface $storage) { diff --git a/core/modules/user/tests/Drupal/user/Tests/Plugin/views/field/UserBulkFormTest.php b/core/modules/user/tests/Drupal/user/Tests/Plugin/views/field/UserBulkFormTest.php index 74897b3..5f8ec1f 100644 --- a/core/modules/user/tests/Drupal/user/Tests/Plugin/views/field/UserBulkFormTest.php +++ b/core/modules/user/tests/Drupal/user/Tests/Plugin/views/field/UserBulkFormTest.php @@ -7,6 +7,7 @@ namespace Drupal\user\Tests\Plugin\views\field; +use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Tests\UnitTestCase; use Drupal\user\Plugin\views\field\UserBulkForm; @@ -26,41 +27,70 @@ public static function getInfo() { } /** + * {@inheritdoc} + */ + protected function tearDown() { + parent::tearDown(); + $container = new ContainerBuilder(); + \Drupal::setContainer($container); + } + + /** * Tests the constructor assignment of actions. */ public function testConstructor() { $actions = array(); for ($i = 1; $i <= 2; $i++) { - $action = $this->getMockBuilder('Drupal\system\Entity\Action') - ->disableOriginalConstructor() - ->getMock(); + $action = $this->getMock('\Drupal\system\ActionConfigEntityInterface'); $action->expects($this->any()) ->method('getType') ->will($this->returnValue('user')); $actions[$i] = $action; } - $action = $this->getMockBuilder('Drupal\system\Entity\Action') - ->disableOriginalConstructor() - ->getMock(); + $action = $this->getMock('\Drupal\system\ActionConfigEntityInterface'); $action->expects($this->any()) ->method('getType') ->will($this->returnValue('node')); $actions[] = $action; - $entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface'); $storage_controller = $this->getMock('Drupal\Core\Entity\EntityStorageControllerInterface'); $storage_controller->expects($this->any()) ->method('loadMultiple') ->will($this->returnValue($actions)); - $entity_manager->expects($this->any()) - ->method('getStorageController') - ->with('action') - ->will($this->returnValue($storage_controller)); + $views_data = $this->getMockBuilder('Drupal\views\ViewsData') + ->disableOriginalConstructor() + ->getMock(); + $views_data->expects($this->any()) + ->method('get') + ->with('users') + ->will($this->returnValue(array('table' => array('entity type' => 'user')))); + $container = new ContainerBuilder(); + $container->set('views.views_data', $views_data); + \Drupal::setContainer($container); - $user_bulk_form = new UserBulkForm(array(), 'user_bulk_form', array(), $entity_manager); + $storage = $this->getMock('Drupal\views\ViewStorageInterface'); + $storage->expects($this->any()) + ->method('get') + ->with('base_table') + ->will($this->returnValue('users')); + + $executable = $this->getMockBuilder('Drupal\views\ViewExecutable') + ->disableOriginalConstructor() + ->getMock(); + $executable->storage = $storage; + + $display = $this->getMockBuilder('Drupal\views\Plugin\views\display\DisplayPluginBase') + ->disableOriginalConstructor() + ->getMock(); + + $definition['title'] = ''; + $options = array(); + + $user_bulk_form = new UserBulkForm(array(), 'user_bulk_form', $definition, $storage_controller); + $user_bulk_form->init($executable, $display, $options); $this->assertAttributeEquals(array_slice($actions, 0, -1, TRUE), 'actions', $user_bulk_form); } diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/HandlerBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/HandlerBase.php index 9590e1c..cf3d41d 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/HandlerBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/HandlerBase.php @@ -721,7 +721,7 @@ public function getEntityType() { return $views_data['table']['entity type']; } else { - throw new \Exception(format_string('No entity type for field @field on view @view', array('@field' => $this->options['id'], '@view' => $this->view->storage->id()))); + throw new \Exception(String::format('No entity type for field @field on view @view', array('@field' => $this->options['id'], '@view' => $this->view->storage->id()))); } }