You are here

SearchBlockTest.php in Google Search Appliance 8

File

tests/src/Functional/SearchBlockTest.php
View source
<?php

namespace Drupal\Tests\google_appliance\Functional;

use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\google_appliance\Routing\SearchViewRoute;
use Drupal\Core\Url;

/**
 * Test search block.
 *
 * @group google_appliance
 */
class SearchBlockTest extends GoogleApplianceFunctionalTestBase {
  use StringTranslationTrait;

  /**
   * Test search block form.
   */
  public function testSearchBlock() {
    $this
      ->placeBlock('google_appliance_search');

    // Test redirect.
    // Go to the front page and submit the search form.
    $this
      ->drupalGet(Url::fromRoute('<front>'));
    $terms = [
      'search_keys' => 'ponies',
    ];
    $this
      ->submitForm($terms, $this
      ->t('Search'));
    $this
      ->assertEquals(Url::fromRoute(SearchViewRoute::ROUTE_NAME, [
      'search_query' => 'ponies',
    ])
      ->setAbsolute()
      ->toString(), $this
      ->getSession()
      ->getCurrentUrl());
    $assert = $this
      ->assertSession();
    $assert
      ->statusCodeEquals(200);
  }

}

Classes

Namesort descending Description
SearchBlockTest Test search block.