function ArgumentLanguageTest::testArgument

Same name in other branches
  1. 9 core/modules/language/tests/src/Kernel/Views/ArgumentLanguageTest.php \Drupal\Tests\language\Kernel\Views\ArgumentLanguageTest::testArgument()
  2. 8.9.x core/modules/language/tests/src/Kernel/Views/ArgumentLanguageTest.php \Drupal\Tests\language\Kernel\Views\ArgumentLanguageTest::testArgument()
  3. 11.x core/modules/language/tests/src/Kernel/Views/ArgumentLanguageTest.php \Drupal\Tests\language\Kernel\Views\ArgumentLanguageTest::testArgument()

Tests the language argument.

File

core/modules/language/tests/src/Kernel/Views/ArgumentLanguageTest.php, line 27

Class

ArgumentLanguageTest
Tests the argument language handler.

Namespace

Drupal\Tests\language\Kernel\Views

Code

public function testArgument() : void {
    $view = Views::getView('test_view');
    foreach ([
        'en' => 'John',
        'xx-lolspeak' => 'George',
    ] as $langcode => $name) {
        $view->setDisplay();
        $view->displayHandlers
            ->get('default')
            ->overrideOption('arguments', [
            'langcode' => [
                'id' => 'langcode',
                'table' => 'views_test_data',
                'field' => 'langcode',
            ],
        ]);
        $this->executeView($view, [
            $langcode,
        ]);
        $expected = [
            [
                'name' => $name,
            ],
        ];
        $this->assertIdenticalResultset($view, $expected, [
            'views_test_data_name' => 'name',
        ]);
        $view->destroy();
    }
}

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