function ExposedFormLinkDisplayTest::testExposedFormActionUsesCustomLinkDisplay

Tests that exposed form action uses the custom link display path.

File

core/modules/views/tests/src/Kernel/Plugin/ExposedFormLinkDisplayTest.php, line 76

Class

ExposedFormLinkDisplayTest
Tests exposed form actions for block displays with custom link targets.

Namespace

Drupal\Tests\views\Kernel\Plugin

Code

public function testExposedFormActionUsesCustomLinkDisplay() : void {
  $view = Views::getView('test_exposed_block_link_display');
  $view->setDisplay('block_1');
  $view->initHandlers();
  $form = $view->display_handler
    ->getPlugin('exposed_form')
    ->renderExposedForm(TRUE);
  $this->assertNotEmpty($form, 'The exposed form was built for the block display.');
  $this->assertSame('/custom-link', $form['#action']);
  $page_path = $view->displayHandlers
    ->get('page_1')
    ->getPath();
  $this->assertNotSame($page_path, $form['#action']);
  $this->assertNotSame('/' . $page_path, $form['#action']);
  $current_path = $this->container
    ->get('path.current')
    ->getPath();
  $this->assertNotSame($current_path, $form['#action']);
}

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