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 68441f68265dffa830d4fd795874c401c5eadbe5..4ae0bef5918d8d3ee442a7af9c28353a9e11f51d 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 @@ * * @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 edcf2b13e15a3a27f0572423f7580c98a8218bc9..09f9c93090908a70394a7d535ff2ded1549e62c5 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 @@ public static function getInfo() { 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 0000000000000000000000000000000000000000..56b750d151ebade7c376664d397f46f59927e5a3 --- /dev/null +++ b/core/modules/node/tests/Drupal/node/Tests/Plugin/views/field/NodeBulkFormTest.php @@ -0,0 +1,69 @@ +<?php + +/** + * @file + * Contains \Drupal\node\Tests\Plugin\views\field\NodeBulkFormTest. + */ + +namespace Drupal\node\Tests\Plugin\views\field; + +use Drupal\node\Plugin\views\field\NodeBulkForm; +use Drupal\Tests\UnitTestCase; + +/** + * Tests the node bulk form plugin. + * + * @see \Drupal\node\Plugin\views\field\NodeBulkForm + */ +class NodeBulkFormTest extends UnitTestCase { + + public static function getInfo() { + return array( + 'name' => '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 a302a5010c56db51ea03b8b1c59af3b7daf8b278..8e9ed6e7fb000585dc0705bf54c28b290ba91902 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 @@ * * @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 0000000000000000000000000000000000000000..1214fc62e55dc9de7e49eca6921b3e731321bd37 --- /dev/null +++ b/core/modules/user/tests/Drupal/user/Tests/Plugin/views/field/UserBulkFormTest.php @@ -0,0 +1,70 @@ +<?php + +/** + * @file + * Contains \Drupal\user\Tests\Plugin\views\field\UserBulkFormTest. + */ + +namespace Drupal\user\Tests\Plugin\views\field; + +use Drupal\Tests\UnitTestCase; +use Drupal\user\Plugin\views\field\UserBulkForm; + +/** + * Tests the user bulk form plugin. + * + * @see \Drupal\user\Plugin\views\field\UserBulkForm + */ +class UserBulkFormTest extends UnitTestCase { + + public static function getInfo() { + return array( + 'name' => '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 3d9f92e7e81f68a3d489cfe07966004e2a517d62..ba2356c825bdb9c1bd3cdc2c20e7e9433b0a4c15 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 @@ * * @PluginID("action_bulk_form") */ -class BulkForm extends BulkFormBase { +class ActionBulkForm extends BulkFormBase { /** * Overrides \Drupal\views\Plugin\views\field\FieldPluginBase::defineOptions().