Newer
Older
catch
committed
<?php
Dries Buytaert
committed
namespace Drupal\Tests\user\Unit\Plugin\views\field;
catch
committed
use Drupal\Core\DependencyInjection\ContainerBuilder;
catch
committed
use Drupal\Tests\UnitTestCase;
use Drupal\user\Plugin\views\field\UserBulkForm;
/**
* @coversDefaultClass \Drupal\user\Plugin\views\field\UserBulkForm
* @group user
catch
committed
*/
class UserBulkFormTest extends UnitTestCase {
/**
* {@inheritdoc}
*/
protected function tearDown() {
parent::tearDown();
$container = new ContainerBuilder();
\Drupal::setContainer($container);
}
catch
committed
/**
* Tests the constructor assignment of actions.
*/
public function testConstructor() {
$actions = [];
catch
committed
for ($i = 1; $i <= 2; $i++) {
$action = $this->getMock('\Drupal\system\ActionConfigEntityInterface');
catch
committed
$action->expects($this->any())
->method('getType')
->will($this->returnValue('user'));
$actions[$i] = $action;
}
$action = $this->getMock('\Drupal\system\ActionConfigEntityInterface');
catch
committed
$action->expects($this->any())
->method('getType')
->will($this->returnValue('node'));
$actions[] = $action;
catch
committed
$entity_storage = $this->getMock('Drupal\Core\Entity\EntityStorageInterface');
$entity_storage->expects($this->any())
catch
committed
->method('loadMultiple')
->will($this->returnValue($actions));
Alex Pott
committed
$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');
$messenger = $this->getMock('Drupal\Core\Messenger\MessengerInterface');
$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);
Angie Byron
committed
$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 = [];
catch
committed
$user_bulk_form = new UserBulkForm([], 'user_bulk_form', $definition, $entity_manager, $language_manager, $messenger);
$user_bulk_form->init($executable, $display, $options);