CacheabilityTest.php in Search API Saved Searches 8
File
tests/src/Functional/CacheabilityTest.php
View source
<?php
namespace Drupal\Tests\search_api_saved_searches\Functional;
use Drupal\search_api_saved_searches\Entity\SavedSearchAccessControlHandler;
use Drupal\Tests\BrowserTestBase;
class CacheabilityTest extends BrowserTestBase {
public static $modules = [
'block',
'rest',
'search_api_saved_searches',
'search_api_test_views',
];
protected $defaultTheme = 'stark';
protected $adminUser;
public function setUp() {
parent::setUp();
$permissions = [
SavedSearchAccessControlHandler::ADMIN_PERMISSION,
];
$this->adminUser = $this
->drupalCreateUser($permissions);
$this
->drupalLogin($this->adminUser);
}
public function testBlockCaching() {
$block_label = 'Save search test block label';
$this
->drupalPlaceBlock('search_api_saved_searches', [
'label' => $block_label,
'type' => 'default',
]);
$this
->drupalGet('search-api-test');
$assert_session = $this
->assertSession();
$assert_session
->pageTextContains($block_label);
$this
->drupalGet('user/1');
$assert_session
->pageTextNotContains($block_label);
$this
->drupalGet('search-api-test');
$assert_session
->pageTextContains($block_label);
}
}