protected function SimpleTestTest::setUp in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/simpletest/src/Tests/SimpleTestTest.php \Drupal\simpletest\Tests\SimpleTestTest::setUp()
Sets up a Drupal site for running functional and integration tests.
Installs Drupal with the installation profile specified in \Drupal\simpletest\WebTestBase::$profile into the prefixed database.
Afterwards, installs any additional modules specified in the static \Drupal\simpletest\WebTestBase::$modules property of each class in the class hierarchy.
After installation all caches are flushed and several configuration values are reset to the values of the parent site executing the test, since the default values may be incompatible with the environment in which tests are being executed.
Overrides WebTestBase::setUp
File
- core/
modules/ simpletest/ src/ Tests/ SimpleTestTest.php, line 70 - Contains \Drupal\simpletest\Tests\SimpleTestTest.
Class
- SimpleTestTest
- Tests SimpleTest's web interface: check that the intended tests were run and ensure that test reports display the intended results. Also test SimpleTest's internal browser and APIs implicitly.
Namespace
Drupal\simpletest\TestsCode
protected function setUp() {
if (!$this
->isInChildSite()) {
$php = <<<'EOD'
<?php
# Make sure that the $test_class variable is defined when this file is included.
if ($test_class) {
}
# Define a function to be able to check that this file was loaded with
# function_exists().
if (!function_exists('simpletest_test_stub_settings_function')) {
function simpletest_test_stub_settings_function() {}
}
EOD;
file_put_contents($this->siteDirectory . '/' . 'settings.testing.php', $php);
// @see \Drupal\system\Tests\DrupalKernel\DrupalKernelSiteTest
$class = __CLASS__;
$yaml = <<<EOD
services:
# Add a new service.
site.service.yml:
class: {<span class="php-variable">$class</span>}
# Swap out a core service.
cache.backend.database:
class: Drupal\\Core\\Cache\\MemoryBackendFactory
EOD;
file_put_contents($this->siteDirectory . '/testing.services.yml', $yaml);
$original_container = $this->originalContainer;
parent::setUp();
$this
->assertNotIdentical(\Drupal::getContainer(), $original_container, 'WebTestBase test creates a new container.');
// Create and log in an admin user.
$this
->drupalLogin($this
->drupalCreateUser(array(
'administer unit tests',
)));
}
else {
// This causes three of the five fails that are asserted in
// confirmStubResults().
self::$modules = array(
'non_existent_module',
);
parent::setUp();
}
}