X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fuser%2Ftests%2Fsrc%2FUnit%2FPlugin%2Fviews%2Ffield%2FUserBulkFormTest.php;fp=web%2Fcore%2Fmodules%2Fuser%2Ftests%2Fsrc%2FUnit%2FPlugin%2Fviews%2Ffield%2FUserBulkFormTest.php;h=11a970a0bf3939fcb3eefcf71bd0904f3c116f3b;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/core/modules/user/tests/src/Unit/Plugin/views/field/UserBulkFormTest.php b/web/core/modules/user/tests/src/Unit/Plugin/views/field/UserBulkFormTest.php new file mode 100644 index 000000000..11a970a0b --- /dev/null +++ b/web/core/modules/user/tests/src/Unit/Plugin/views/field/UserBulkFormTest.php @@ -0,0 +1,93 @@ +getMock('\Drupal\system\ActionConfigEntityInterface'); + $action->expects($this->any()) + ->method('getType') + ->will($this->returnValue('user')); + $actions[$i] = $action; + } + + $action = $this->getMock('\Drupal\system\ActionConfigEntityInterface'); + $action->expects($this->any()) + ->method('getType') + ->will($this->returnValue('node')); + $actions[] = $action; + + $entity_storage = $this->getMock('Drupal\Core\Entity\EntityStorageInterface'); + $entity_storage->expects($this->any()) + ->method('loadMultiple') + ->will($this->returnValue($actions)); + + $entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface'); + $entity_manager->expects($this->once()) + ->method('getStorage') + ->with('action') + ->will($this->returnValue($entity_storage)); + + $language_manager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface'); + + $views_data = $this->getMockBuilder('Drupal\views\ViewsData') + ->disableOriginalConstructor() + ->getMock(); + $views_data->expects($this->any()) + ->method('get') + ->with('users') + ->will($this->returnValue(['table' => ['entity type' => 'user']])); + $container = new ContainerBuilder(); + $container->set('views.views_data', $views_data); + $container->set('string_translation', $this->getStringTranslationStub()); + \Drupal::setContainer($container); + + $storage = $this->getMock('Drupal\views\ViewEntityInterface'); + $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 = []; + + $user_bulk_form = new UserBulkForm([], 'user_bulk_form', $definition, $entity_manager, $language_manager); + $user_bulk_form->init($executable, $display, $options); + + $this->assertAttributeEquals(array_slice($actions, 0, -1, TRUE), 'actions', $user_bulk_form); + } + +}