Completed
Pull Request — master (#18)
by Daryl
01:53
created

RoboFile   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A tests() 0 13 1
A phpunit() 0 6 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
	function tests()
11
	{
12
13
		$this->taskExec('mysql -e "CREATE DATABASE IF NOT EXISTS test_db"')->run();
14
		$this->taskExec('mysql -e "GRANT ALL ON test_db.* to \'root\'@\'%\'"')->run();
15
		$this->taskSvnStack()
16
			->checkout('https://develop.svn.wordpress.org/tags/4.8.3 wp-tests')
17
			->run();
18
19
		$this->setTestConfig();
20
		$this->phpunit();
21
22
	}
23
24
	function phpunit()
25
	{
26
		$this->taskPhpUnit('vendor/bin/phpunit')
27
		     ->configFile('tests/phpunit.xml.dist')
28
		     ->run();
29
	}
30
31
	private function setTestConfig()
32
	{
33
34
		if (file_exists('wp-tests/wp-tests-config-sample.php')) {
35
			copy('wp-tests/wp-tests-config-sample.php', 'wp-tests/wp-tests-config.php');
36
		}
37
38
		$this->taskReplaceInFile( 'wp-tests/wp-tests-config.php')
39
			->from('youremptytestdbnamehere')
40
			->to('test_db')
41
			->run();
42
43
		$this->taskReplaceInFile( 'wp-tests/wp-tests-config.php')
44
			->from('yourusernamehere')
45
			->to('root')
46
			->run();
47
48
		$this->taskReplaceInFile( 'wp-tests/wp-tests-config.php')
49
			->from('yourpasswordhere')
50
			->to('')
51
			->run();
52
	}
53
54
}