Completed
Branch master (82e11d)
by Daryl
01:51 queued 37s
created

RoboFile   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 6
dl 0
loc 58
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A scripts() 0 7 1
A tests() 0 13 1
A phpunit() 0 7 1
A setTestConfig() 0 22 2
1
<?php
2
/**
3
 * This is project's console commands configuration for Robo task runner.
4
 *
5
 * @see http://robo.li/
6
 */
7
class RoboFile extends \Robo\Tasks
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
8
{
9
	// define public methods as commands
10
11
	function scripts() {
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...
12
13
		$this->taskMinify('assets/maps.js')
14
		     ->to('dist/scripts/maps.min.js')
15
		     ->run();
16
17
	}
18
19
	function tests()
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...
20
	{
21
22
		$this->taskExec('mysql -e "CREATE DATABASE IF NOT EXISTS test_db"')->run();
23
		$this->taskExec('mysql -e "GRANT ALL ON test_db.* to \'root\'@\'%\'"')->run();
24
		$this->taskSvnStack()
25
		     ->checkout('https://develop.svn.wordpress.org/tags/4.8.3 wp-tests')
26
		     ->run();
27
28
		$this->setTestConfig();
29
		$this->phpunit();
30
31
	}
32
33
	function phpunit()
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
	{
35
		$this->taskPhpUnit('vendor/bin/phpunit')
36
		     ->configFile('tests/phpunit.xml.dist')
37
		     ->envVars(array('WP_TESTS_DIR' => 'wp-tests'))
38
		     ->run();
39
	}
40
41
	private function setTestConfig()
42
	{
43
44
		if (file_exists('wp-tests/wp-tests-config-sample.php')) {
45
			copy('wp-tests/wp-tests-config-sample.php', 'wp-tests/wp-tests-config.php');
46
		}
47
48
		$this->taskReplaceInFile( 'wp-tests/wp-tests-config.php')
49
		     ->from('youremptytestdbnamehere')
50
		     ->to('test_db')
51
		     ->run();
52
53
		$this->taskReplaceInFile( 'wp-tests/wp-tests-config.php')
54
		     ->from('yourusernamehere')
55
		     ->to('root')
56
		     ->run();
57
58
		$this->taskReplaceInFile( 'wp-tests/wp-tests-config.php')
59
		     ->from('yourpasswordhere')
60
		     ->to('')
61
		     ->run();
62
	}
63
64
}