Skip to content

Commit 5530b05

Browse files
committed
Start WP core tests
1 parent ebdd767 commit 5530b05

File tree

2 files changed

+39
-15
lines changed

2 files changed

+39
-15
lines changed

phpunit.xml.dist

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,7 @@
99
>
1010
<testsuites>
1111
<testsuite name="fileSystem">
12-
<directory prefix="test-" suffix=".php">./tests/filesystem</directory>
12+
<directory prefix="test-" suffix=".php">./tests/</directory>
1313
</testsuite>
14-
<testsuite name="imageModel">
15-
<directory prefix="test-" suffix=".php">./tests/Model/image</directory>
16-
</testsuite>
17-
<testsuite name="Controllers">
18-
<directory prefix="test-" suffix=".php">./tests/Controller</directory>
19-
</testsuite>
20-
<testsuite name="queue">
21-
<directory prefix="test-" suffix=".php">./tests/queue</directory>
22-
</testsuite>
23-
<testsuite name="model">
24-
<directory prefix="test-" suffix=".php">./tests/Model</directory>
25-
</testsuite>
26-
27-
2814
</testsuites>
2915
</phpunit>

tests/bootstrap.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
/**
3+
* PHPUnit bootstrap file.
4+
*
5+
* @package Shortpixel_Image_Optimiser
6+
*/
7+
8+
$_tests_dir = getenv( 'WP_TESTS_DIR' );
9+
10+
if ( ! $_tests_dir ) {
11+
$_tests_dir = rtrim( sys_get_temp_dir(), '/\\' ) . '/wordpress-tests-lib';
12+
}
13+
14+
// Forward custom PHPUnit Polyfills configuration to PHPUnit bootstrap file.
15+
$_phpunit_polyfills_path = getenv( 'WP_TESTS_PHPUNIT_POLYFILLS_PATH' );
16+
if ( false !== $_phpunit_polyfills_path ) {
17+
define( 'WP_TESTS_PHPUNIT_POLYFILLS_PATH', $_phpunit_polyfills_path );
18+
}
19+
20+
if ( ! file_exists( "{$_tests_dir}/includes/functions.php" ) ) {
21+
echo "Could not find {$_tests_dir}/includes/functions.php, have you run bin/install-wp-tests.sh ?" . PHP_EOL; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
22+
exit( 1 );
23+
}
24+
25+
// Give access to tests_add_filter() function.
26+
require_once "{$_tests_dir}/includes/functions.php";
27+
28+
/**
29+
* Manually load the plugin being tested.
30+
*/
31+
function _manually_load_plugin() {
32+
require dirname( dirname( __FILE__ ) ) . '/wp-shortpixel.php';
33+
}
34+
35+
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
36+
37+
// Start up the WP testing environment.
38+
require "{$_tests_dir}/includes/bootstrap.php";

0 commit comments

Comments
 (0)