public function ModuleTest::testViewsEmbedView in Drupal 9
Same name and namespace in other branches
- 8 core/modules/views/tests/src/Kernel/ModuleTest.php \Drupal\Tests\views\Kernel\ModuleTest::testViewsEmbedView()
Tests views.module: views_embed_view().
File
- core/
modules/ views/ tests/ src/ Kernel/ ModuleTest.php, line 248
Class
- ModuleTest
- Tests basic functions from the Views module.
Namespace
Drupal\Tests\views\KernelCode
public function testViewsEmbedView() {
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = \Drupal::service('renderer');
$result = views_embed_view('test_argument');
$renderer
->renderPlain($result);
$this
->assertCount(5, $result['view_build']['#view']->result);
$result = views_embed_view('test_argument', 'default', 1);
$renderer
->renderPlain($result);
$this
->assertCount(1, $result['view_build']['#view']->result);
$result = views_embed_view('test_argument', 'default', '1,2');
$renderer
->renderPlain($result);
$this
->assertCount(2, $result['view_build']['#view']->result);
$result = views_embed_view('test_argument', 'default', '1,2', 'John');
$renderer
->renderPlain($result);
$this
->assertCount(1, $result['view_build']['#view']->result);
$result = views_embed_view('test_argument', 'default', '1,2', 'John,George');
$renderer
->renderPlain($result);
$this
->assertCount(2, $result['view_build']['#view']->result);
}