DrushCommandsTest.php in Views Bulk Operations (VBO) 4.0.x
File
tests/src/Functional/DrushCommandsTest.php
View source
<?php
namespace Drupal\Tests\views_bulk_operations\Functional;
use Drupal\Tests\BrowserTestBase;
use Drush\TestTraits\DrushTestTrait;
class DrushCommandsTest extends BrowserTestBase {
use DrushTestTrait;
const TEST_NODE_COUNT = 15;
protected $defaultTheme = 'stark';
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 < self::TEST_NODE_COUNT; $i++) {
$time -= $i;
$this->testNodes[] = $this
->drupalCreateNode([
'type' => 'page',
'title' => 'Title ' . $i,
'sticky' => $i % 2 ? TRUE : FALSE,
'created' => $time,
'changed' => $time,
]);
}
}
public function testDrushCommand() {
$this
->drush('vbo-exec', [
'views_bulk_operations_test',
'views_bulk_operations_simple_test_action',
]);
for ($i = 0; $i < self::TEST_NODE_COUNT; $i++) {
$this
->assertStringContainsString("Test action (preconfig: , label: Title {$i})", $this
->getErrorOutput());
}
$this
->drush('vbo-exec', [
'views_bulk_operations_test',
'views_bulk_operations_simple_test_action',
], [
'exposed' => 'sticky=1',
]);
for ($i = 0; $i < self::TEST_NODE_COUNT; $i++) {
$test_string = "Test action (preconfig: , label: Title {$i})";
if ($i % 2) {
$this
->assertStringContainsString($test_string, $this
->getErrorOutput());
}
else {
$this
->assertStringNotContainsString($test_string, $this
->getErrorOutput());
}
}
}
}