class DrupalFlushAllCachesInInstallerTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/FunctionalTests/Installer/DrupalFlushAllCachesInInstallerTest.php \Drupal\FunctionalTests\Installer\DrupalFlushAllCachesInInstallerTest
- 10 core/tests/Drupal/FunctionalTests/Installer/DrupalFlushAllCachesInInstallerTest.php \Drupal\FunctionalTests\Installer\DrupalFlushAllCachesInInstallerTest
Tests drupal_flush_all_caches() during an install.
@group Installer
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\FunctionalTests\Installer\DrupalFlushAllCachesInInstallerTest implements \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of DrupalFlushAllCachesInInstallerTest
File
-
core/
tests/ Drupal/ FunctionalTests/ Installer/ DrupalFlushAllCachesInInstallerTest.php, line 13
Namespace
Drupal\FunctionalTests\InstallerView source
class DrupalFlushAllCachesInInstallerTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected $profile = 'cache_flush_test';
/**
* {@inheritdoc}
*/
protected function prepareEnvironment() {
parent::prepareEnvironment();
$info = [
'type' => 'profile',
'core_version_requirement' => '*',
'name' => 'Cache flush test',
'install' => [
'language',
],
];
// File API functions are not available yet.
$path = $this->siteDirectory . '/profiles/cache_flush_test';
mkdir($path, 0777, TRUE);
file_put_contents("{$path}/cache_flush_test.info.yml", Yaml::encode($info));
$php_code = <<<EOF
<?php
function cache_flush_test_install() {
// Note it is bad practice to call this method during hook_install() as it
// results in an additional expensive container rebuild.
drupal_flush_all_caches();
// Ensure services are available after calling drupal_flush_all_caches().
\\Drupal::state()->set('cache_flush_test', \\Drupal::hasService('language_negotiator'));
}
EOF;
file_put_contents("{$path}/cache_flush_test.install", $php_code);
}
/**
* Confirms that the installation succeeded.
*/
public function testInstalled() {
$this->assertTrue(\Drupal::state()->get('cache_flush_test'));
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.