Tests: Move tests infrastructure, set up travis

Consolidates the composer files so we can run install once in travis.
This commit is contained in:
Kelly Dwan 2019-11-15 10:40:18 -05:00
parent 5c2041442a
commit 68d5c53c95
No known key found for this signature in database
GPG key ID: 8BA5575F3D11575D
10 changed files with 2618 additions and 2488 deletions

View file

@ -1,29 +1,29 @@
<?php
/**
* PHPUnit bootstrap file
*/
namespace WordPressDotOrg\FiveForTheFuture\Tests;
$_tests_dir = getenv( 'WP_TESTS_DIR' );
if ( 'cli' !== php_sapi_name() ) {
return;
if ( ! $_tests_dir ) {
$_tests_dir = rtrim( sys_get_temp_dir(), '/\\' ) . '/wordpress-tests-lib';
}
define( 'WP_PLUGIN_DIR', dirname( dirname( __DIR__ ) ) );
$core_tests_directory = getenv( 'WP_TESTS_DIR' );
if ( ! $core_tests_directory ) {
echo "\nPlease set the WP_TESTS_DIR environment variable to the folder where WordPress' PHPUnit tests live --";
echo "\ne.g., export WP_TESTS_DIR=/srv/www/wordpress-develop/tests/phpunit\n";
return;
if ( ! file_exists( $_tests_dir . '/includes/functions.php' ) ) {
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
exit( 1 );
}
require_once $core_tests_directory . '/includes/functions.php';
require_once dirname( dirname( $core_tests_directory ) ) . '/build/wp-admin/includes/plugin.php';
// Give access to tests_add_filter() function.
require_once $_tests_dir . '/includes/functions.php';
tests_add_filter( 'muplugins_loaded', function() {
require_once dirname( __DIR__ ) . '/index.php';
} );
/**
* Manually load the plugin being tested.
*/
function _manually_load_plugin() {
require dirname( dirname( __FILE__ ) ) . '/index.php';
}
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
require_once $core_tests_directory . '/includes/bootstrap.php';
// Start up the WP testing environment.
require $_tests_dir . '/includes/bootstrap.php';