TestDatabase
class TestDatabase (View source)
Provides helper methods for interacting with the fixture database.
Properties
| protected int | $lockId | A random number used to ensure that test fixtures are unique to each test method. |
|
| protected string | $databasePrefix | The test database prefix. |
Methods
Returns the database connection to the site running Simpletest.
TestDatabase constructor.
Gets the relative path to the test site directory.
Gets the test database prefix.
Generates a unique lock ID for the test method.
Releases a lock.
Releases all test locks.
Gets the lock file path.
Store an assertion from outside the testing context.
Get information about the last test that ran given a test ID.
Reads the error log and reports any errors as assertion failures.
Defines the database schema for run-tests.sh and simpletest module.
Inserts the parsed PHPUnit results into {simpletest}.
Details
static Connection
getConnection()
Returns the database connection to the site running Simpletest.
__construct(string|null $db_prefix = NULL, bool $create_lock = FALSE)
TestDatabase constructor.
string
getTestSitePath()
Gets the relative path to the test site directory.
string
getDatabasePrefix()
Gets the test database prefix.
protected int
getTestLock(bool $create_lock = FALSE)
Generates a unique lock ID for the test method.
bool
releaseLock()
Releases a lock.
static
releaseAllTestLocks()
Releases all test locks.
This should only be called once all the test fixtures have been cleaned up.
protected string
getLockFile(int $lock_id)
Gets the lock file path.
static int
insertAssert(string $test_id, string $test_class, bool|string $status, string $message = '', string $group = 'Other', array $caller = [])
| internal |
Store an assertion from outside the testing context.
This is useful for inserting assertions that can only be recorded after the test case has been destroyed, such as PHP fatal errors. The caller information is not automatically gathered since the caller is most likely inserting the assertion on behalf of other code. In all other respects the method behaves just like \Drupal\simpletest\TestBase::assert() in terms of storing the assertion.
static array
lastTestGet(int $test_id)
| internal |
Get information about the last test that ran given a test ID.
bool
logRead(int $test_id, string $test_class)
| internal |
Reads the error log and reports any errors as assertion failures.
The errors in the log should only be fatal errors since any other errors will have been recorded by the error handler.
static array
testingSchema()
| internal |
Defines the database schema for run-tests.sh and simpletest module.
static
processPhpUnitResults(array[] $phpunit_results)
| internal |
Inserts the parsed PHPUnit results into {simpletest}.