protected function ViewsBulkOperationsActionProcessorTest::assertNodeStatuses in Views Bulk Operations (VBO) 8.3
Same name and namespace in other branches
- 4.0.x tests/src/Kernel/ViewsBulkOperationsActionProcessorTest.php \Drupal\Tests\views_bulk_operations\Kernel\ViewsBulkOperationsActionProcessorTest::assertNodeStatuses()
Helper function to assert if node statuses have expected values.
Parameters
array $list: VBO processing list.
bool $exclude: Exclude mode enabled?
2 calls to ViewsBulkOperationsActionProcessorTest::assertNodeStatuses()
- ViewsBulkOperationsActionProcessorTest::testViewsbulkOperationsActionProcessor in tests/
src/ Kernel/ ViewsBulkOperationsActionProcessorTest.php - Tests general functionality of ViewsBulkOperationsActionProcessor.
- ViewsBulkOperationsActionProcessorTest::testViewsbulkOperationsActionProcessorExclude in tests/
src/ Kernel/ ViewsBulkOperationsActionProcessorTest.php - Tests exclude mode of ViewsBulkOperationsActionProcessor.
File
- tests/
src/ Kernel/ ViewsBulkOperationsActionProcessorTest.php, line 32
Class
- ViewsBulkOperationsActionProcessorTest
- @coversDefaultClass \Drupal\views_bulk_operations\Service\ViewsBulkOperationsActionProcessor @group views_bulk_operations
Namespace
Drupal\Tests\views_bulk_operations\KernelCode
protected function assertNodeStatuses(array $list, $exclude = FALSE) {
$nodeStorage = $this->container
->get('entity_type.manager')
->getStorage('node');
$statuses = [];
foreach ($this->testNodesData as $id => $lang_data) {
$node = $nodeStorage
->load($id);
$statuses[$id] = $node
->isPublished();
// Reset node status.
$node
->setPublished();
$node
->save();
}
foreach ($statuses as $id => $status) {
$asserted = FALSE;
foreach ($list as $item) {
if ($item[3] == $id) {
$this
->assertEquals((bool) $exclude, $status);
$asserted = TRUE;
break;
}
}
if (!$asserted) {
$this
->assertEquals(!(bool) $exclude, $status);
}
}
}