function FieldKernelTest::testClickSortable

Same name in other branches
  1. 8.9.x core/modules/views/tests/src/Kernel/Handler/FieldKernelTest.php \Drupal\Tests\views\Kernel\Handler\FieldKernelTest::testClickSortable()
  2. 10 core/modules/views/tests/src/Kernel/Handler/FieldKernelTest.php \Drupal\Tests\views\Kernel\Handler\FieldKernelTest::testClickSortable()
  3. 11.x core/modules/views/tests/src/Kernel/Handler/FieldKernelTest.php \Drupal\Tests\views\Kernel\Handler\FieldKernelTest::testClickSortable()

Tests whether the filters are click sortable as expected.

File

core/modules/views/tests/src/Kernel/Handler/FieldKernelTest.php, line 752

Class

FieldKernelTest
Tests the generic field handler.

Namespace

Drupal\Tests\views\Kernel\Handler

Code

public function testClickSortable() {
    // Test that clickSortable is TRUE by default.
    $item = [
        'table' => 'views_test_data',
        'field' => 'name',
    ];
    $plugin = $this->container
        ->get('plugin.manager.views.field')
        ->getHandler($item);
    $this->assertTrue($plugin->clickSortable(), 'TRUE as a default value is correct.');
    // Test that clickSortable is TRUE by when set TRUE in the data.
    $item['field'] = 'id';
    $plugin = $this->container
        ->get('plugin.manager.views.field')
        ->getHandler($item);
    $this->assertTrue($plugin->clickSortable(), 'TRUE as a views data value is correct.');
    // Test that clickSortable is FALSE by when set FALSE in the data.
    $item['field'] = 'job';
    $plugin = $this->container
        ->get('plugin.manager.views.field')
        ->getHandler($item);
    $this->assertFalse($plugin->clickSortable(), 'FALSE as a views data value is correct.');
}

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