Completed
Push — master ( 6c0735...dd8543 )
by Dennis
06:47
created

bootstrap.php ➔ msls_test_data()   A

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');
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
6
if ( ! $_tests_dir ) $_tests_dir = '/tmp/wordpress-tests-lib';
0 ignored issues
show
Coding Style Best Practice introduced by
It is generally a best practice to always use braces with control structures.

Adding braces to control structures avoids accidental mistakes as your code changes:

// Without braces (not recommended)
if (true)
    doSomething();

// Recommended
if (true) {
    doSomething();
}
Loading history...
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...
Coding Style introduced by
The function name setUp is in camel caps, but expected set_up instead as per the coding standard.
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...
Coding Style introduced by
The function name tearDown is in camel caps, but expected tear_down instead as per the coding standard.
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