You are here

public function ModuleTest::testViewsEmbedView in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/views/tests/src/Kernel/ModuleTest.php \Drupal\Tests\views\Kernel\ModuleTest::testViewsEmbedView()
  2. 9 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);
}