You are here

public function SimpleGseSearchTest::testSearch in Simple Google Custom Search Engine 2.0.x

Same name and namespace in other branches
  1. 8 tests/src/Functional/SimpleGseSearchTest.php \Drupal\Tests\simple_gse_search\Functional\SimpleGseSearchTest::testSearch()

Tests searching redirects as expected.

File

tests/src/Functional/SimpleGseSearchTest.php, line 32

Class

SimpleGseSearchTest
Tests if the search form submit redirects correctly.

Namespace

Drupal\Tests\simple_gse_search\Functional

Code

public function testSearch() {
  $this
    ->drupalGet('<front>');
  $this
    ->submitForm([
    's' => 'bananas',
  ], 'go');
  $url = Url::fromRoute('simple_gse_search.search_page', [], [
    'query' => [
      's' => 'bananas',
    ],
  ])
    ->setAbsolute()
    ->toString();
  $this
    ->assertEquals($url, $this
    ->getSession()
    ->getCurrentUrl());
  $this
    ->assertSession()
    ->fieldValueEquals('s', 'bananas');
}