You are here

FilterLanguageTest.php in Zircon Profile 8

Same filename and directory in other branches
  1. 8.0 core/modules/language/src/Tests/Views/FilterLanguageTest.php

File

core/modules/language/src/Tests/Views/FilterLanguageTest.php
View source
<?php

/**
 * @file
 * Contains \Drupal\language\Tests\Views\FilterLanguageTest.
 */
namespace Drupal\language\Tests\Views;

use Drupal\views\Views;

/**
 * Tests the filter language handler.
 *
 * @group language
 * @see \Drupal\language\Plugin\views\filter\Language
 */
class FilterLanguageTest extends LanguageTestBase {

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

  /**
   * Tests the language filter.
   */
  public function testFilter() {
    $view = Views::getView('test_view');
    foreach (array(
      'en' => 'John',
      'xx-lolspeak' => 'George',
    ) as $langcode => $name) {
      $view
        ->setDisplay();
      $view->displayHandlers
        ->get('default')
        ->overrideOption('filters', array(
        'langcode' => array(
          'id' => 'langcode',
          'table' => 'views_test_data',
          'field' => 'langcode',
          'value' => array(
            $langcode,
          ),
        ),
      ));
      $this
        ->executeView($view);
      $expected = array(
        array(
          'name' => $name,
        ),
      );
      $this
        ->assertIdenticalResultset($view, $expected, array(
        'views_test_data_name' => 'name',
      ));
      $view
        ->destroy();
    }
  }

}

Classes

Namesort descending Description
FilterLanguageTest Tests the filter language handler.