You are here

public function SimpleGseSearchTest::testSearch in Simple Google Custom Search Engine 8

Same name and namespace in other branches
  1. 2.0.x 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');
}