public function ModuleTest::testViewsPreview in Drupal 8
Same name and namespace in other branches
- 9 core/modules/views/tests/src/Kernel/ModuleTest.php \Drupal\Tests\views\Kernel\ModuleTest::testViewsPreview()
Tests the \Drupal\views\ViewsExecutable::preview() method.
File
- core/
modules/ views/ tests/ src/ Kernel/ ModuleTest.php, line 276
Class
- ModuleTest
- Tests basic functions from the Views module.
Namespace
Drupal\Tests\views\KernelCode
public function testViewsPreview() {
$view = Views::getView('test_argument');
$result = $view
->preview('default');
$this
->assertCount(5, $result['#view']->result);
$view = Views::getView('test_argument');
$result = $view
->preview('default', [
'0' => 1,
]);
$this
->assertCount(1, $result['#view']->result);
$view = Views::getView('test_argument');
$result = $view
->preview('default', [
'3' => 1,
]);
$this
->assertCount(1, $result['#view']->result);
$view = Views::getView('test_argument');
$result = $view
->preview('default', [
'0' => '1,2',
]);
$this
->assertCount(2, $result['#view']->result);
$view = Views::getView('test_argument');
$result = $view
->preview('default', [
'3' => '1,2',
]);
$this
->assertCount(2, $result['#view']->result);
$view = Views::getView('test_argument');
$result = $view
->preview('default', [
'0' => '1,2',
'1' => 'John',
]);
$this
->assertCount(1, $result['#view']->result);
$view = Views::getView('test_argument');
$result = $view
->preview('default', [
'3' => '1,2',
'4' => 'John',
]);
$this
->assertCount(1, $result['#view']->result);
$view = Views::getView('test_argument');
$result = $view
->preview('default', [
'0' => '1,2',
'1' => 'John,George',
]);
$this
->assertCount(2, $result['#view']->result);
$view = Views::getView('test_argument');
$result = $view
->preview('default', [
'3' => '1,2',
'4' => 'John,George',
]);
$this
->assertCount(2, $result['#view']->result);
}