-
-
Notifications
You must be signed in to change notification settings - Fork 85
Expand file tree
/
Copy path_bootstrap.php
More file actions
44 lines (38 loc) · 1.68 KB
/
Copy path_bootstrap.php
File metadata and controls
44 lines (38 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
// This is global bootstrap for autoloading.
use Codeception\Event\SuiteEvent;
use Codeception\Events;
use Codeception\Util\Autoload;
use lucatume\WPBrowser\Events\Dispatcher;
use lucatume\WPBrowser\Utils\Db;
use lucatume\WPBrowser\Utils\Env;
function createTestDatabasesIfNotExist(): void
{
$env = Env::envFile('tests/.env');
$host = $env['WORDPRESS_DB_HOST'];
$user = $env['WORDPRESS_DB_USER'];
$pass = $env['WORDPRESS_DB_PASSWORD'];
try {
$db = Db::db('mysql:host=' . $host, $user, $pass);
$db('CREATE DATABASE IF NOT EXISTS ' . $env['WORDPRESS_SUBDIR_DB_NAME']);
$db('CREATE DATABASE IF NOT EXISTS ' . $env['WORDPRESS_SUBDOMAIN_DB_NAME']);
$db('CREATE DATABASE IF NOT EXISTS ' . $env['WORDPRESS_EMPTY_DB_NAME']);
} catch (Exception $e) {
codecept_debug('Could not connect to the database: ' . $e->getMessage());
}
}
createTestDatabasesIfNotExist();
// Make sure traits can be autoloaded from tests/_support/Traits
Autoload::addNamespace('\lucatume\WPBrowser\Tests\Traits', codecept_root_dir('tests/_support/Traits'));
// If the `uopz` extension is installed, then ensure `exit` and `die` to work normally.
if (function_exists('uopz_allow_exit')) {
uopz_allow_exit(true);
}
// Register the fork-child reporting hook ahead of Codeception's ErrorHandler shutdown handler.
require_once __DIR__ . '/_support/Fork.php';
lucatume\WPBrowser\Tests\Traits\Fork::registerChildShutdownHandler();
// This is here to test the EventDispatcherBridge extension.
Dispatcher::addListener(Events::MODULE_INIT, function (SuiteEvent $suiteEvent) {
$suiteName = $suiteEvent->getSuite()?->getName();
codecept_debug('Suite name: ' . $suiteName);
});