ViewsBulkOperationsDataServiceTest.php in Views Bulk Operations (VBO) 4.0.x
File
tests/src/Kernel/ViewsBulkOperationsDataServiceTest.php
View source
<?php
namespace Drupal\Tests\views_bulk_operations\Kernel;
use Drupal\views\Views;
class ViewsBulkOperationsDataServiceTest extends ViewsBulkOperationsKernelTestBase {
public function setUp() {
parent::setUp();
$this
->createTestNodes([
'page' => [
'languages' => [
'pl',
'es',
'it',
'fr',
'de',
],
'count' => 20,
],
]);
}
public function testViewsbulkOperationsViewDataEntityGetter() {
$view = Views::getView('views_bulk_operations_test');
$view
->setDisplay('page_1');
$view
->setItemsPerPage(0);
$view
->setCurrentPage(0);
$view
->execute();
$test_data = $this->testNodesData;
foreach ($view->result as $row) {
$entity = $this->vboDataService
->getEntityDefault($row, 'none', $view);
$expected_label = $test_data[$entity
->id()][$entity
->language()
->getId()];
$this
->assertEquals($expected_label, $entity
->label(), 'Title matches');
if ($expected_label === $entity
->label()) {
unset($test_data[$entity
->id()][$entity
->language()
->getId()]);
if (empty($test_data[$entity
->id()])) {
unset($test_data[$entity
->id()]);
}
}
}
$this
->assertEmpty($test_data, 'All created entities and their translations were returned.');
}
}