3 namespace Drupal\Tests\comment\Unit\Plugin\views\field;
5 use Drupal\Core\DependencyInjection\ContainerBuilder;
6 use Drupal\comment\Plugin\views\field\CommentBulkForm;
7 use Drupal\Tests\UnitTestCase;
10 * @coversDefaultClass \Drupal\comment\Plugin\views\field\CommentBulkForm
13 class CommentBulkFormTest extends UnitTestCase {
18 protected function tearDown() {
20 $container = new ContainerBuilder();
21 \Drupal::setContainer($container);
25 * Tests the constructor assignment of actions.
27 public function testConstructor() {
30 for ($i = 1; $i <= 2; $i++) {
31 $action = $this->getMock('\Drupal\system\ActionConfigEntityInterface');
32 $action->expects($this->any())
34 ->will($this->returnValue('comment'));
35 $actions[$i] = $action;
38 $action = $this->getMock('\Drupal\system\ActionConfigEntityInterface');
39 $action->expects($this->any())
41 ->will($this->returnValue('user'));
44 $entity_storage = $this->getMock('Drupal\Core\Entity\EntityStorageInterface');
45 $entity_storage->expects($this->any())
46 ->method('loadMultiple')
47 ->will($this->returnValue($actions));
49 $entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface');
50 $entity_manager->expects($this->once())
51 ->method('getStorage')
53 ->will($this->returnValue($entity_storage));
55 $language_manager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface');
57 $views_data = $this->getMockBuilder('Drupal\views\ViewsData')
58 ->disableOriginalConstructor()
60 $views_data->expects($this->any())
63 ->will($this->returnValue(['table' => ['entity type' => 'comment']]));
64 $container = new ContainerBuilder();
65 $container->set('views.views_data', $views_data);
66 $container->set('string_translation', $this->getStringTranslationStub());
67 \Drupal::setContainer($container);
69 $storage = $this->getMock('Drupal\views\ViewEntityInterface');
70 $storage->expects($this->any())
73 ->will($this->returnValue('comment'));
75 $executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
76 ->disableOriginalConstructor()
78 $executable->storage = $storage;
80 $display = $this->getMockBuilder('Drupal\views\Plugin\views\display\DisplayPluginBase')
81 ->disableOriginalConstructor()
84 $definition['title'] = '';
87 $comment_bulk_form = new CommentBulkForm([], 'comment_bulk_form', $definition, $entity_manager, $language_manager);
88 $comment_bulk_form->init($executable, $display, $options);
90 $this->assertAttributeEquals(array_slice($actions, 0, -1, TRUE), 'actions', $comment_bulk_form);