class UserBulkFormTest in Drupal 10
Same name and namespace in other branches
- 8 core/modules/user/tests/src/Unit/Plugin/views/field/UserBulkFormTest.php \Drupal\Tests\user\Unit\Plugin\views\field\UserBulkFormTest
- 9 core/modules/user/tests/src/Unit/Plugin/views/field/UserBulkFormTest.php \Drupal\Tests\user\Unit\Plugin\views\field\UserBulkFormTest
@coversDefaultClass \Drupal\user\Plugin\views\field\UserBulkForm @group user
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, PhpUnitWarnings
- class \Drupal\Tests\user\Unit\Plugin\views\field\UserBulkFormTest
Expanded class hierarchy of UserBulkFormTest
File
- core/
modules/ user/ tests/ src/ Unit/ Plugin/ views/ field/ UserBulkFormTest.php, line 15
Namespace
Drupal\Tests\user\Unit\Plugin\views\fieldView source
class UserBulkFormTest extends UnitTestCase {
/**
* {@inheritdoc}
*/
protected function tearDown() : void {
parent::tearDown();
$container = new ContainerBuilder();
\Drupal::setContainer($container);
}
/**
* Tests the constructor assignment of actions.
*/
public function testConstructor() {
$actions = [];
for ($i = 1; $i <= 2; $i++) {
$action = $this
->createMock('\\Drupal\\system\\ActionConfigEntityInterface');
$action
->expects($this
->any())
->method('getType')
->will($this
->returnValue('user'));
$actions[$i] = $action;
}
$action = $this
->createMock('\\Drupal\\system\\ActionConfigEntityInterface');
$action
->expects($this
->any())
->method('getType')
->will($this
->returnValue('node'));
$actions[] = $action;
$entity_storage = $this
->createMock('Drupal\\Core\\Entity\\EntityStorageInterface');
$entity_storage
->expects($this
->any())
->method('loadMultiple')
->will($this
->returnValue($actions));
$entity_type_manager = $this
->createMock(EntityTypeManagerInterface::class);
$entity_type_manager
->expects($this
->once())
->method('getStorage')
->with('action')
->will($this
->returnValue($entity_storage));
$entity_repository = $this
->createMock(EntityRepositoryInterface::class);
$language_manager = $this
->createMock('Drupal\\Core\\Language\\LanguageManagerInterface');
$messenger = $this
->createMock('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);
$container
->set('string_translation', $this
->getStringTranslationStub());
\Drupal::setContainer($container);
$storage = $this
->createMock('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_type_manager, $language_manager, $messenger, $entity_repository);
$user_bulk_form
->init($executable, $display, $options);
$reflected_actions = (new \ReflectionObject($user_bulk_form))
->getProperty('actions');
$reflected_actions
->setAccessible(TRUE);
$this
->assertEquals(array_slice($actions, 0, -1, TRUE), $reflected_actions
->getValue($user_bulk_form));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PhpUnitWarnings:: |
private static | property | Deprecation warnings from PHPUnit to raise with @trigger_error(). | |
PhpUnitWarnings:: |
public | function | Converts PHPUnit deprecation warnings to E_USER_DEPRECATED. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. | |
UnitTestCase:: |
protected | function | 206 | |
UnitTestCase:: |
public static | function | ||
UserBulkFormTest:: |
protected | function | ||
UserBulkFormTest:: |
public | function | Tests the constructor assignment of actions. |