public function CacheabilityTest::testExecuteTasksAction in Search API 8
Tests the cache metadata of the "Execute pending tasks" action.
File
- tests/
src/ Functional/ CacheabilityTest.php, line 66
Class
- CacheabilityTest
- Tests the cacheability metadata of Search API.
Namespace
Drupal\Tests\search_api\FunctionalCode
public function testExecuteTasksAction() {
// Enable the "Local actions" block so we can verify which local actions are
// displayed.
$success = \Drupal::getContainer()
->get('module_installer')
->install([
'block',
], TRUE);
$this
->assertTrue($success, new FormattableMarkup('Enabled modules: %modules', [
'%modules' => 'block',
]));
Block::create([
'id' => 'stark_local_actions',
'theme' => 'stark',
'weight' => -20,
'plugin' => 'local_actions_block',
'region' => 'content',
])
->save();
$assert_session = $this
->assertSession();
$admin_path = 'admin/config/search/search-api';
$this
->drupalLogin($this->adminUser);
// At first, the action should not be present.
$this
->drupalGet($admin_path);
$assert_session
->statusCodeEquals(200);
$assert_session
->pageTextNotContains('Execute pending tasks');
$this
->drupalGet($admin_path);
$assert_session
->statusCodeEquals(200);
$assert_session
->pageTextNotContains('Execute pending tasks');
// Create one task.
$task = Task::create([]);
$task
->save();
// Now the action should be shown.
$this
->drupalGet($admin_path);
$assert_session
->statusCodeEquals(200);
$assert_session
->pageTextContains('Execute pending tasks');
$this
->drupalGet($admin_path);
$assert_session
->statusCodeEquals(200);
$assert_session
->pageTextContains('Execute pending tasks');
// Delete the task again.
$task
->delete();
// Now the action should be hidden again.
$this
->drupalGet($admin_path);
$assert_session
->statusCodeEquals(200);
$assert_session
->pageTextNotContains('Execute pending tasks');
$this
->drupalGet($admin_path);
$assert_session
->statusCodeEquals(200);
$assert_session
->pageTextNotContains('Execute pending tasks');
}