1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* WP tests bootstrap. |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
$_tests_dir = getenv( 'WP_TESTS_DIR' ); |
7
|
|
|
if ( ! $_tests_dir ) { |
8
|
|
|
$tmp_dir = getenv( 'TMPDIR' ); |
9
|
|
|
if ( ! empty( $tmp_dir ) ) { |
10
|
|
|
$_tests_dir = rtrim( $tmp_dir, '/' ) . '/wordpress-tests-lib'; |
11
|
|
|
if ( ! is_dir( $_tests_dir ) ) { |
12
|
|
|
$_tests_dir = null; |
13
|
|
|
} |
14
|
|
|
} |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
if ( ! $_tests_dir ) { |
18
|
|
|
$_tests_dir = '/tmp/wordpress-tests-lib'; |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
require_once $_tests_dir . '/includes/functions.php'; |
22
|
|
|
|
23
|
|
|
function _manually_load_plugin() { |
24
|
|
|
define( 'AUTOPTIMIZE_INIT_EARLIER', true ); |
25
|
|
|
|
26
|
|
|
// For overriding cache dirs and whatnot. Kinda works if you keep a few things in mind. |
27
|
|
|
if ( getenv('CUSTOM_CONSTANTS' ) ) { |
28
|
|
|
define( 'AUTOPTIMIZE_CACHE_CHILD_DIR', '/c/ao/' ); |
29
|
|
|
$pathname = WP_CONTENT_DIR . AUTOPTIMIZE_CACHE_CHILD_DIR; |
30
|
|
View Code Duplication |
if ( is_multisite() && apply_filters( 'autoptimize_separate_blog_caches', true ) ) { |
|
|
|
|
31
|
|
|
$blog_id = get_current_blog_id(); |
32
|
|
|
$pathname .= $blog_id . '/'; |
33
|
|
|
} |
34
|
|
|
define( 'AUTOPTIMIZE_CACHE_DIR', $pathname ); |
35
|
|
|
|
36
|
|
|
$custom_site_url = 'http://localhost/wordpress'; |
37
|
|
|
define( 'AUTOPTIMIZE_WP_SITE_URL', $custom_site_url ); |
38
|
|
|
add_filter( 'site_url', function( $url, $path, $scheme, $blog_id ) use ( $custom_site_url ) { |
39
|
|
|
return $custom_site_url; |
40
|
|
|
}, 10, 4 ); |
41
|
|
|
add_filter( 'content_url', function( $url, $path ) use ( $custom_site_url ) { |
42
|
|
|
return $custom_site_url . '/wp-content'; |
43
|
|
|
}, 10, 2 ); |
44
|
|
|
define( 'AO_TEST_SUBFOLDER_INSTALL', true ); |
45
|
|
|
|
46
|
|
|
define( 'CUSTOM_CONSTANTS_USED', true ); |
47
|
|
|
} else { |
48
|
|
|
define( 'CUSTOM_CONSTANTS_USED', false ); |
49
|
|
|
define( 'AO_TEST_SUBFOLDER_INSTALL', false ); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/* |
53
|
|
|
$active_plugins = array('autoptimize/autoptimize.php'); |
54
|
|
|
update_option( 'active_plugins', $active_plugins ); |
55
|
|
|
*/ |
56
|
|
|
|
57
|
|
|
update_option( 'autoptimize_js', 1 ); |
58
|
|
|
update_option( 'autoptimize_css', 1 ); |
59
|
|
|
update_option( 'autoptimize_html', 0 ); |
60
|
|
|
update_option( 'autoptimize_cdn_url', 'http://cdn.example.org' ); |
61
|
|
|
update_option( 'autoptimize_cache_nogzip', 1 ); |
62
|
|
|
|
63
|
|
|
add_filter( 'autoptimize_css_include_inline', function( $include_inline ) { |
64
|
|
|
return true; |
65
|
|
|
}); |
66
|
|
|
|
67
|
|
|
require dirname( dirname( __FILE__ ) ) . '/autoptimize.php'; |
68
|
|
|
} |
69
|
|
|
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' ); |
70
|
|
|
|
71
|
|
|
require $_tests_dir . '/includes/bootstrap.php'; |
72
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.