You are here

AreaViewTest.php in Zircon Profile 8.0

Same filename and directory in other branches
  1. 8 core/modules/views/src/Tests/Handler/AreaViewTest.php

File

core/modules/views/src/Tests/Handler/AreaViewTest.php
View source
<?php

/**
 * @file
 * Contains \Drupal\views\Tests\Handler\AreaViewTest.
 */
namespace Drupal\views\Tests\Handler;

use Drupal\views\Tests\ViewKernelTestBase;
use Drupal\views\Views;

/**
 * Tests the view area handler.
 *
 * @group views
 * @see \Drupal\views\Plugin\views\area\View
 */
class AreaViewTest extends ViewKernelTestBase {

  /**
   * Modules to enable.
   *
   * @var array
   */
  public static $modules = array(
    'user',
  );

  /**
   * Views used by this test.
   *
   * @var array
   */
  public static $testViews = array(
    'test_simple_argument',
    'test_area_view',
  );

  /**
   * Tests the view area handler.
   */
  public function testViewArea() {

    /** @var \Drupal\Core\Render\RendererInterface $renderer */
    $renderer = $this->container
      ->get('renderer');
    $view = Views::getView('test_area_view');

    // Tests \Drupal\views\Plugin\views\area\View::calculateDependencies().
    $this
      ->assertIdentical([
      'config' => [
        'views.view.test_simple_argument',
      ],
    ], $view
      ->getDependencies());
    $this
      ->executeView($view);
    $output = $view
      ->render();
    $output = $renderer
      ->renderRoot($output);
    $this
      ->assertTrue(strpos($output, 'js-view-dom-id-' . $view->dom_id) !== FALSE, 'The test view is correctly embedded.');
    $view
      ->destroy();
    $view
      ->setArguments(array(
      27,
    ));
    $this
      ->executeView($view);
    $output = $view
      ->render();
    $output = $renderer
      ->renderRoot($output);
    $this
      ->assertTrue(strpos($output, 'John') === FALSE, 'The test view is correctly embedded with inherited arguments.');
    $this
      ->assertTrue(strpos($output, 'George') !== FALSE, 'The test view is correctly embedded with inherited arguments.');
    $view
      ->destroy();
  }

}

Classes

Namesort descending Description
AreaViewTest Tests the view area handler.