public function ViewsBulkOperationsActionProcessorTest::testViewsbulkOperationsActionProcessor in Views Bulk Operations (VBO) 4.0.x
Same name and namespace in other branches
- 8.3 tests/src/Kernel/ViewsBulkOperationsActionProcessorTest.php \Drupal\Tests\views_bulk_operations\Kernel\ViewsBulkOperationsActionProcessorTest::testViewsbulkOperationsActionProcessor()
- 8.2 tests/src/Kernel/ViewsBulkOperationsActionProcessorTest.php \Drupal\Tests\views_bulk_operations\Kernel\ViewsBulkOperationsActionProcessorTest::testViewsbulkOperationsActionProcessor()
Tests general functionality of ViewsBulkOperationsActionProcessor.
@covers ::getPageList @covers ::populateQueue @covers ::process
File
- tests/
src/ Kernel/ ViewsBulkOperationsActionProcessorTest.php, line 68
Class
- ViewsBulkOperationsActionProcessorTest
- @coversDefaultClass \Drupal\views_bulk_operations\Service\ViewsBulkOperationsActionProcessor @group views_bulk_operations
Namespace
Drupal\Tests\views_bulk_operations\KernelCode
public function testViewsbulkOperationsActionProcessor() {
$vbo_data = [
'view_id' => 'views_bulk_operations_test',
'action_id' => 'views_bulk_operations_simple_test_action',
'configuration' => [
'preconfig' => 'test',
],
];
// Test executing all view results first.
$results = $this
->executeAction($vbo_data);
// The default batch size is 10 and there are 20 result rows total
// (10 nodes, each having a translation), check messages:
$this
->assertEquals('Processed 10 of 20 entities.', $results['messages'][0]);
$this
->assertEquals('Processed 20 of 20 entities.', $results['messages'][1]);
$this
->assertEquals(20, $results['operations']['Test']);
// For a more advanced test, check if randomly selected entities
// have been unpublished.
$vbo_data = [
'view_id' => 'views_bulk_operations_test',
'action_id' => 'views_bulk_operations_advanced_test_action',
'preconfiguration' => [
'test_preconfig' => 'test',
'test_config' => 'unpublish',
],
];
// Get list of rows to process from different view pages.
$selection = [
0,
3,
6,
8,
15,
16,
18,
];
$vbo_data['list'] = $this
->getResultsList($vbo_data, $selection);
// Execute the action.
$results = $this
->executeAction($vbo_data);
$this
->assertNodeStatuses($vbo_data['list']);
}