-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathphpunit-bootstrap.php
More file actions
50 lines (38 loc) · 1.55 KB
/
Copy pathphpunit-bootstrap.php
File metadata and controls
50 lines (38 loc) · 1.55 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
45
46
47
48
49
50
<?php
use SIL\Tests\Mocks\MockWP_Http;
const PHP_UNIT = true;
const TESTS_DIR = __DIR__ . '/test-php';
const CONFIG_DIR = TESTS_DIR . '/config';
const TEST_RESOURCES = TESTS_DIR . '/resources';
const WEBONARY_CLOUD_DEFAULT_DICTIONARY_ID = 'unit_test';
const WEBONARY_CLOUD_API_URL = 'https://unit-test.local/v1/';
const WEBONARY_CLOUD_FILE_URL = 'https://unit-test.local/';
const MULTISITE = true;
const SUBDOMAIN_INSTALL = false;
register_shutdown_function(function(){
print 'SHUTDOWN' . PHP_EOL;
});
include_once 'wordpress-develop/tests/phpunit/includes/bootstrap.php';
// we need to set this before activating the plugin
update_option('useCloudBackend', '1');
// activate the Webonary plugin
activate_plugin('sil-dictionary-webonary/sil-dictionary.php');
activate_plugin('links-dropdown-widget/plugin.php');
activate_plugin('webonary-create-site2/webonary-create-site2.php');
activate_plugin('contact-form-7-to-database-extension/contact-form-7-db.php');
do_action('init');
// this is so we can mock requests to the cloud
add_filter('pre_http_request', [MockWP_Http::class, 'HandleHttpRequest'], 10, 3);
// remove the test cache directory, if it exists
$cache_dir = rtrim(sys_get_temp_dir(), '/\\') . '/webonary-cache-php-unit';
if (is_dir($cache_dir))
SIL\Webonary\Helpers\Cache::ClearDirectory($cache_dir, true);
// add a couple test sites
$data = get_site(1)->to_array();
// webonary.org site, no path
$data['domain'] = 'webonary.org';
$data['path'] = '/';
wp_insert_site($data);
// webonary.org site, with path
$data['path'] = '/unit-test';
wp_insert_site($data);