diff --git a/core/modules/node/lib/Drupal/node/Plugin/views/field/NodeBulkForm.php b/core/modules/node/lib/Drupal/node/Plugin/views/field/NodeBulkForm.php index 68441f68265..4ae0bef5918 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/views/field/NodeBulkForm.php +++ b/core/modules/node/lib/Drupal/node/Plugin/views/field/NodeBulkForm.php @@ -7,8 +7,8 @@ namespace Drupal\node\Plugin\views\field; +use Drupal\views\Plugin\views\field\ActionBulkForm; use Drupal\Component\Annotation\PluginID; -use Drupal\system\Plugin\views\field\BulkFormBase; use Drupal\Core\Cache\Cache; use Drupal\Core\Entity\EntityManager; @@ -17,7 +17,7 @@ use Drupal\Core\Entity\EntityManager; * * @PluginID("node_bulk_form") */ -class NodeBulkForm extends BulkFormBase { +class NodeBulkForm extends ActionBulkForm { /** * Constructs a new NodeBulkForm object. diff --git a/core/modules/node/lib/Drupal/node/Tests/Views/BulkFormTest.php b/core/modules/node/lib/Drupal/node/Tests/Views/BulkFormTest.php index edcf2b13e15..09f9c930909 100644 --- a/core/modules/node/lib/Drupal/node/Tests/Views/BulkFormTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/Views/BulkFormTest.php @@ -25,7 +25,7 @@ class BulkFormTest extends NodeTestBase { return array( 'name' => 'Node: Bulk form', 'description' => 'Tests a node bulk form.', - 'group' => 'Views Modules', + 'group' => 'Views module integration', ); } 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 new file mode 100644 index 00000000000..56b750d151e --- /dev/null +++ b/core/modules/node/tests/Drupal/node/Tests/Plugin/views/field/NodeBulkFormTest.php @@ -0,0 +1,69 @@ + 'Node: Bulk form', + 'description' => 'Tests the node bulk form plugin.', + 'group' => 'Views module integration', + ); + } + + /** + * Tests the constructor assignment of actions. + */ + public function testConstructor() { + $actions = array(); + + for ($i = 1; $i <= 2; $i++) { + $action = $this->getMockBuilder('Drupal\system\Plugin\Core\Entity\Action') + ->disableOriginalConstructor() + ->getMock(); + $action->expects($this->any()) + ->method('getType') + ->will($this->returnValue('node')); + $actions[$i] = $action; + } + + $action = $this->getMockBuilder('Drupal\system\Plugin\Core\Entity\Action') + ->disableOriginalConstructor() + ->getMock(); + $action->expects($this->any()) + ->method('getType') + ->will($this->returnValue('user')); + $actions[] = $action; + + $entity_manager = $this->getMockBuilder('Drupal\Core\Entity\EntityManager') + ->disableOriginalConstructor() + ->getMock(); + $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); + + $this->assertAttributeEquals(array_slice($actions, 0, -1, TRUE), 'actions', $node_bulk_form); + } + +} diff --git a/core/modules/user/lib/Drupal/user/Plugin/views/field/UserBulkForm.php b/core/modules/user/lib/Drupal/user/Plugin/views/field/UserBulkForm.php index a302a5010c5..8e9ed6e7fb0 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/views/field/UserBulkForm.php +++ b/core/modules/user/lib/Drupal/user/Plugin/views/field/UserBulkForm.php @@ -7,9 +7,9 @@ namespace Drupal\user\Plugin\views\field; +use Drupal\views\Plugin\views\field\ActionBulkForm; use Drupal\Component\Annotation\PluginID; use Drupal\Core\Entity\EntityManager; -use Drupal\system\Plugin\views\field\BulkFormBase; use Drupal\user\UserInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -18,7 +18,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; * * @PluginID("user_bulk_form") */ -class UserBulkForm extends BulkFormBase { +class UserBulkForm extends ActionBulkForm { /** * {@inheritdoc} 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 new file mode 100644 index 00000000000..1214fc62e55 --- /dev/null +++ b/core/modules/user/tests/Drupal/user/Tests/Plugin/views/field/UserBulkFormTest.php @@ -0,0 +1,70 @@ + 'User: Bulk form', + 'description' => 'Tests the user bulk form plugin.', + 'group' => 'Views module integration', + ); + } + + /** + * Tests the constructor assignment of actions. + */ + public function testConstructor() { + $actions = array(); + + for ($i = 1; $i <= 2; $i++) { + $action = $this->getMockBuilder('Drupal\system\Plugin\Core\Entity\Action') + ->disableOriginalConstructor() + ->getMock(); + $action->expects($this->any()) + ->method('getType') + ->will($this->returnValue('user')); + $actions[$i] = $action; + } + + $action = $this->getMockBuilder('Drupal\system\Plugin\Core\Entity\Action') + ->disableOriginalConstructor() + ->getMock(); + $action->expects($this->any()) + ->method('getType') + ->will($this->returnValue('node')); + $actions[] = $action; + + $entity_manager = $this->getMockBuilder('Drupal\Core\Entity\EntityManager') + ->disableOriginalConstructor() + ->getMock(); + $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)); + + $user_bulk_form = new UserBulkForm(array(), 'user_bulk_form', array(), $entity_manager); + + $this->assertAttributeEquals(array_slice($actions, 0, -1, TRUE), 'actions', $user_bulk_form); + } + +} diff --git a/core/modules/action/lib/Drupal/action/Plugin/views/field/BulkForm.php b/core/modules/views/lib/Drupal/views/Plugin/views/field/ActionBulkForm.php similarity index 96% rename from core/modules/action/lib/Drupal/action/Plugin/views/field/BulkForm.php rename to core/modules/views/lib/Drupal/views/Plugin/views/field/ActionBulkForm.php index 3d9f92e7e81..ba2356c825b 100644 --- a/core/modules/action/lib/Drupal/action/Plugin/views/field/BulkForm.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/field/ActionBulkForm.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\action\Plugin\views\field\BulkForm. + * Contains \Drupal\views\Plugin\views\field\BulkForm. */ -namespace Drupal\action\Plugin\views\field; +namespace Drupal\views\Plugin\views\field; use Drupal\Component\Annotation\PluginID; use Drupal\system\Plugin\views\field\BulkFormBase; @@ -15,7 +15,7 @@ use Drupal\system\Plugin\views\field\BulkFormBase; * * @PluginID("action_bulk_form") */ -class BulkForm extends BulkFormBase { +class ActionBulkForm extends BulkFormBase { /** * Overrides \Drupal\views\Plugin\views\field\FieldPluginBase::defineOptions().