PluginProbe
Document Library Lite / trunk
Document Library Lite vtrunk
1.2.1 1.3.0 trunk 1.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5-1 1.0.6 1.0.7 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0
document-library-lite / tests / bootstrap.php

bootstrap.php in Document Library Lite trunk, at tests/bootstrap.php

66 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 use Yoast\WPTestUtils\WPIntegration;
4
5 // Autoload everything for unit tests.
6 $ds = DIRECTORY_SEPARATOR;
7 require_once dirname(__FILE__, 2) . $ds . 'vendor' . $ds . 'autoload.php';
8
9 /**
10 * Include core bootstrap for an integration test suite
11 *
12 * This will only work if you run the tests from the command line.
13 * Running the tests from IDE such as PhpStorm will require you to
14 * add additional argument to the test run command if you want to run
15 * integration tests.
16 */
17 if (isset($GLOBALS['argv']) && in_array('--group=integration', $GLOBALS['argv'], true)) {
18 if (!file_exists(dirname(__FILE__, 2) . '/wp/tests/phpunit/wp-tests-config.php')) {
19 // We need to set up core config details and test details
20 copy(
21 dirname(__FILE__, 2) . '/wp/wp-tests-config-sample.php',
22 dirname(__FILE__, 2) . '/wp/tests/phpunit/wp-tests-config.php'
23 );
24
25 // Change certain constants from the test's config file.
26 $testConfigPath = dirname(__FILE__, 2) . '/wp/tests/phpunit/wp-tests-config.php';
27 $testConfigContents = file_get_contents($testConfigPath);
28
29 $testConfigContents = str_replace(
30 "dirname( __FILE__ ) . '/src/'",
31 "dirname(__FILE__, 3) . '/src/'",
32 $testConfigContents
33 );
34 $testConfigContents = str_replace("youremptytestdbnamehere", $_SERVER['DB_NAME'], $testConfigContents);
35 $testConfigContents = str_replace("yourusernamehere", $_SERVER['DB_USER'], $testConfigContents);
36 $testConfigContents = str_replace("yourpasswordhere", $_SERVER['DB_PASSWORD'], $testConfigContents);
37 $testConfigContents = str_replace("localhost", $_SERVER['DB_HOST'], $testConfigContents);
38
39 file_put_contents($testConfigPath, $testConfigContents);
40 }
41
42 // Give access to tests_add_filter() function.
43 require_once dirname(__FILE__, 2) . '/wp/tests/phpunit/includes/functions.php';
44
45 /**
46 * Manually load the plugin being tested.
47 */
48 function _manually_load_plugin()
49 {
50 // @@_manually_load_plugin@@
51 require dirname(__DIR__) . '/document-library-lite.php';
52 }
53
54 tests_add_filter('muplugins_loaded', '_manually_load_plugin');
55
56 // @@tests_add_filter@@
57
58 require_once dirname(__DIR__) . '/vendor/yoast/wp-test-utils/src/WPIntegration/bootstrap-functions.php';
59
60 /*
61 * Bootstrap WordPress. This will also load the Composer autoload file, the PHPUnit Polyfills
62 * and the custom autoloader for the TestCase and the mock object classes.
63 */
64 WPIntegration\bootstrap_it();
65 }
66