ViewsBulkOperationsFunctionalTestBase.php in Views Bulk Operations (VBO) 4.0.x
File
tests/src/Functional/ViewsBulkOperationsFunctionalTestBase.php
View source
<?php
namespace Drupal\Tests\views_bulk_operations\Functional;
use Drupal\Tests\BrowserTestBase;
use Drupal\Core\StringTranslation\TranslatableMarkup;
abstract class ViewsBulkOperationsFunctionalTestBase extends BrowserTestBase {
const TEST_NODE_COUNT = 15;
protected $defaultTheme = 'stable';
public static $modules = [
'node',
'views',
'views_bulk_operations',
'views_bulk_operations_test',
];
protected function setUp() {
parent::setUp();
$this
->drupalCreateContentType([
'type' => 'page',
]);
$this->testNodes = [];
$time = $this->container
->get('datetime.time')
->getRequestTime();
for ($i = 0; $i < static::TEST_NODE_COUNT; $i++) {
$time -= $i;
$this->testNodes[] = $this
->drupalCreateNode([
'type' => 'page',
'title' => 'Title ' . $i,
'sticky' => FALSE,
'created' => $time,
'changed' => $time,
]);
}
}
protected function executeAction($path, TranslatableMarkup $button_text, array $selection = [], array $data = []) {
foreach ($selection as $index) {
$data["views_bulk_operations_bulk_form[{$index}]"] = TRUE;
}
$this
->drupalPostForm($path, $data, $button_text);
}
}