ArgumentNullTest.php in Drupal 9
File
core/modules/views/tests/src/Kernel/Handler/ArgumentNullTest.php
View source
<?php
namespace Drupal\Tests\views\Kernel\Handler;
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
use Drupal\views\Views;
class ArgumentNullTest extends ViewsKernelTestBase {
public static $testViews = [
'test_view',
];
public function viewsData() {
$data = parent::viewsData();
$data['views_test_data']['id']['argument']['id'] = 'null';
return $data;
}
public function testAreaText() {
$view = Views::getView('test_view');
$view
->setDisplay();
$view->displayHandlers
->get('default')
->overrideOption('arguments', [
'null' => [
'id' => 'null',
'table' => 'views',
'field' => 'null',
],
]);
$this
->executeView($view);
unset($view->argument['null']->argument_validated);
$this
->assertTrue($view->argument['null']
->validateArgument(26));
unset($view->argument['null']->argument_validated);
$view->argument['null']->options['must_not_be'] = TRUE;
$this
->assertFalse($view->argument['null']
->validateArgument(26), 'must_not_be returns FALSE, if there is an argument');
unset($view->argument['null']->argument_validated);
$this
->assertTrue($view->argument['null']
->validateArgument(NULL), 'must_not_be returns TRUE, if there is no argument');
$view
->destroy();
$view
->setDisplay();
$view->displayHandlers
->get('default')
->overrideOption('arguments', [
'id' => [
'id' => 'id',
'table' => 'views_test_data',
'field' => 'id',
],
]);
$this
->executeView($view, [
26,
]);
$this
->assertCount(5, $view->result);
}
}