You are here

public function CacheabilityTest::testFramework in Search API 8

Tests the cacheability settings of Search API.

File

tests/src/Functional/CacheabilityTest.php, line 49

Class

CacheabilityTest
Tests the cacheability metadata of Search API.

Namespace

Drupal\Tests\search_api\Functional

Code

public function testFramework() {
  $this
    ->drupalLogin($this->adminUser);

  // Verify that the search results are marked as uncacheable.
  $this
    ->drupalGet('search-api-test');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->responseHeaderEquals('x-drupal-dynamic-cache', 'UNCACHEABLE');
  $this
    ->assertStringContainsString('no-cache', $this
    ->drupalGetHeader('cache-control'));

  // Verify that the search results are displayed.
  $this
    ->assertSession()
    ->pageTextContains('foo test');
  $this
    ->assertSession()
    ->pageTextContains('foo baz');
}