You are here

public function IntegrationTest::testViewsCacheDisable in Facets 8

Same name in this branch
  1. 8 tests/src/Functional/IntegrationTest.php \Drupal\Tests\facets\Functional\IntegrationTest::testViewsCacheDisable()
  2. 8 modules/facets_summary/tests/src/Functional/IntegrationTest.php \Drupal\Tests\facets_summary\Functional\IntegrationTest::testViewsCacheDisable()

Check that the disabling of the cache works.

File

tests/src/Functional/IntegrationTest.php, line 835

Class

IntegrationTest
Tests the overall functionality of the Facets admin UI.

Namespace

Drupal\Tests\facets\Functional

Code

public function testViewsCacheDisable() {

  // Load the view, verify cache settings.
  $view = Views::getView('search_api_test_view');
  $view
    ->setDisplay('page_1');
  $current_cache = $view->display_handler
    ->getOption('cache');
  $this
    ->assertEquals('none', $current_cache['type']);
  $view->display_handler
    ->setOption('cache', [
    'type' => 'tag',
  ]);
  $view
    ->save();
  $current_cache = $view->display_handler
    ->getOption('cache');
  $this
    ->assertEquals('tag', $current_cache['type']);

  // Create a facet and check for the cache disabled message.
  $id = "western_screech_owl";
  $name = "Western screech owl";
  $this
    ->createFacet($name, $id);
  $this
    ->drupalPostForm('admin/config/search/facets/' . $id . '/settings', [], 'Save');
  $this
    ->assertSession()
    ->pageTextContains('Caching of view Search API Test Fulltext search view has been disabled.');

  // Check the view's cache settings again to see if they've been updated.
  $view = Views::getView('search_api_test_view');
  $view
    ->setDisplay('page_1');
  $current_cache = $view->display_handler
    ->getOption('cache');
  $this
    ->assertEquals('none', $current_cache['type']);
}