bootstrap.php 980 Bytes
Newer Older
Erick Hitter's avatar
Erick Hitter committed
1 2 3 4 5 6 7
<?php
/**
 * PHPUnit bootstrap file
 *
 * @package Camo_Image_Proxy
 */

Erick Hitter's avatar
Cleanup  
Erick Hitter committed
8
$camo_tests_dir = getenv( 'WP_TESTS_DIR' );
Erick Hitter's avatar
Erick Hitter committed
9

Erick Hitter's avatar
Cleanup  
Erick Hitter committed
10 11
if ( ! $camo_tests_dir ) {
	$camo_tests_dir = rtrim( sys_get_temp_dir(), '/\\' ) . '/wordpress-tests-lib';
Erick Hitter's avatar
Erick Hitter committed
12 13
}

Erick Hitter's avatar
Cleanup  
Erick Hitter committed
14
if ( ! file_exists( $camo_tests_dir . '/includes/functions.php' ) ) {
Erick Hitter's avatar
PHPCS 2  
Erick Hitter committed
15
	// @codingStandardsIgnoreStart
Erick Hitter's avatar
Cleanup  
Erick Hitter committed
16
	echo "Could not find $camo_tests_dir/includes/functions.php, have you run bin/install-wp-tests.sh ?" . PHP_EOL; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
Erick Hitter's avatar
PHPCS 2  
Erick Hitter committed
17
	// @codingStandardsIgnoreEnd
Erick Hitter's avatar
Erick Hitter committed
18 19 20 21
	exit( 1 );
}

// Give access to tests_add_filter() function.
Erick Hitter's avatar
Cleanup  
Erick Hitter committed
22
require_once $camo_tests_dir . '/includes/functions.php';
Erick Hitter's avatar
Erick Hitter committed
23 24 25 26

/**
 * Manually load the plugin being tested.
 */
Erick Hitter's avatar
Cleanup  
Erick Hitter committed
27
function camo_manually_load_plugin() {
Erick Hitter's avatar
Erick Hitter committed
28 29
	require dirname( dirname( __FILE__ ) ) . '/camo-image-proxy.php';
}
Erick Hitter's avatar
Cleanup  
Erick Hitter committed
30
tests_add_filter( 'muplugins_loaded', 'camo_manually_load_plugin' );
Erick Hitter's avatar
Erick Hitter committed
31 32

// Start up the WP testing environment.
Erick Hitter's avatar
Cleanup  
Erick Hitter committed
33
require $camo_tests_dir . '/includes/bootstrap.php';