bootstrap.php ➔ msls_test_data()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
1
<?php
2
3
define( 'WP_TESTS_MULTISITE', true );
4
5
$_tests_dir = getenv('WP_TESTS_DIR');
6
if ( ! $_tests_dir ) $_tests_dir = '/tmp/wordpress-tests-lib';
7
8
require_once $_tests_dir . '/includes/functions.php';
9
require_once __DIR__ . '/../vendor/autoload.php';
10
11
function msls_test_data( $path = null ) {
12
	$data_root = __DIR__ . '/_data/';
13
14
	if ( null !== $path ) {
15
		return $data_root . ltrim( $path, '/\\' );
16
	}
17
18
	return $data_root;
19
}
20
21
function _manually_load_plugin() {
22
	require dirname( __FILE__ ) . '/../MultisiteLanguageSwitcher.php';
23
}
24
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
25
26
require $_tests_dir . '/includes/bootstrap.php';
27
28
class Msls_UnitTestCase extends \WP_UnitTestCase {
29
30
	/**
31
	 * SetUp initial settings
32
	 */
33
	function setUp() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
34
		parent::setUp();
35
		add_filter( 'get_available_languages', array( $this, 'filter_available_languages' ) );
36
		wp_cache_flush();
37
	}
38
39
	/**
40
	 * Break down for next test
41
	 */
42
	function tearDown() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
43
		parent::tearDown();
44
	}
45
46
	/**
47
	 * Filters the list of available languages to allow setting the WPLANG option in blogs.
48
	 *
49
	 * @param array $available_languages
50
	 *
51
	 * @return array
52
	 */
53
	public function filter_available_languages( array $available_languages = array() ) {
54
		$available_languages[] = 'de_DE';
55
56
		return $available_languages;
57
	}
58
59
}
60