views_embed_view example

$this->assertContains('test_view', $plugin_details['views'], 'The test_view View was found in the list of views using this plugin.');
    }
  }

  /** * Tests views.module: views_embed_view(). */
  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);

    
Home | Imprint | This part of the site doesn't use cookies.