TestSetupTrait
trait TestSetupTrait (View source)
Provides a trait for shared test setup functionality.
Properties
| static protected string[] | $configSchemaCheckerExclusions | An array of config object names that are excluded from schema checking. |
|
| protected ContainerInterface | $container | The dependency injection container used in the test. |
|
| protected string | $siteDirectory | The site directory of this test run. |
|
| protected string | $publicFilesDirectory | The public file directory for the test environment. |
|
| protected string | $originalSite | The site directory of the original parent site. |
|
| protected string | $privateFilesDirectory | The private file directory for the test environment. |
|
| protected bool | $strictConfigSchema | Set to TRUE to strict check all configuration saved. |
|
| protected DrupalKernel | $kernel | The DrupalKernel instance used in the test. |
|
| protected string | $tempFilesDirectory | The temporary file directory for the test environment. |
|
| protected string | $testId | The test run ID. |
Methods
Returns the database connection to the site running Simpletest.
Generates a database prefix for running tests.
Changes the database connection to the prefixed one.
Gets the config schema exclusions for this test.
Details
static Connection
getDatabaseConnection()
Returns the database connection to the site running Simpletest.
protected
prepareDatabasePrefix()
Generates a database prefix for running tests.
The database prefix is used by prepareEnvironment() to setup a public files directory for the test to be run, which also contains the PHP error log, which is written to in case of a fatal error. Since that directory is based on the database prefix, all tests (even unit tests) need to have one, in order to access and read the error log.
The generated database table prefix is used for the Drupal installation being performed for the test. It is also used as user agent HTTP header it is also used in the user agent HTTP header value by BrowserTestBase, which is sent to the Drupal installation of the test. During early Drupal all bootstrap, the user agent HTTP header is parsed, and if it matches, database queries use the database table prefix that has been generated here.
protected
changeDatabasePrefix()
Changes the database connection to the prefixed one.
protected string[]
getConfigSchemaExclusions()
Gets the config schema exclusions for this test.