function FilterCombineTest::testFilterCombineNotStarts

Same name and namespace in other branches
  1. 10 core/modules/views/tests/src/Kernel/Handler/FilterCombineTest.php \Drupal\Tests\views\Kernel\Handler\FilterCombineTest::testFilterCombineNotStarts()
  2. 11.x core/modules/views/tests/src/Kernel/Handler/FilterCombineTest.php \Drupal\Tests\views\Kernel\Handler\FilterCombineTest::testFilterCombineNotStarts()

Tests the Combine field filter using the 'not_starts' operator.

File

core/modules/views/tests/src/Kernel/Handler/FilterCombineTest.php, line 436

Class

FilterCombineTest
Tests the combine filter handler.

Namespace

Drupal\Tests\views\Kernel\Handler

Code

public function testFilterCombineNotStarts() {
    $view = Views::getView('test_view');
    $view->setDisplay();
    $fields = $view->displayHandlers
        ->get('default')
        ->getOption('fields');
    $view->displayHandlers
        ->get('default')
        ->overrideOption('fields', $fields + [
        'job' => [
            'id' => 'job',
            'table' => 'views_test_data',
            'field' => 'job',
            'relationship' => 'none',
        ],
    ]);
    // Change the filtering.
    $view->displayHandlers
        ->get('default')
        ->overrideOption('filters', [
        'age' => [
            'id' => 'combine',
            'table' => 'views',
            'field' => 'combine',
            'relationship' => 'none',
            'operator' => 'not_starts',
            'fields' => [
                'job',
            ],
            'value' => 'sIn',
        ],
    ]);
    $this->executeView($view);
    $resultset = [
        [
            'name' => 'Ringo',
            'job' => 'Drummer',
        ],
        [
            'name' => 'Paul',
            'job' => 'Songwriter',
        ],
        [
            'name' => 'Meredith',
            'job' => 'Speaker',
        ],
    ];
    $this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}

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