function ModuleTest::testViewsEmbedView

Same name in other branches
  1. 8.9.x core/modules/views/tests/src/Kernel/ModuleTest.php \Drupal\Tests\views\Kernel\ModuleTest::testViewsEmbedView()
  2. 10 core/modules/views/tests/src/Kernel/ModuleTest.php \Drupal\Tests\views\Kernel\ModuleTest::testViewsEmbedView()
  3. 11.x 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 249

Class

ModuleTest
Tests basic functions from the Views module.

Namespace

Drupal\Tests\views\Kernel

Code

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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.