Completed
Pull Request — master (#22)
by Daryl
07:43
created

RoboFile   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A hello() 0 5 1
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 hello($opts = ['who' => 'unknown'])
12
	{
13
		print_r($opts);
14
		$this->say("Hello, " . $opts['who']);
15
	}
16
17
	function scripts() {
18
19
		$this->taskMinify('assets/maps.js')
20
			->to('dist/scripts/maps.min.js')
21
			->run();
22
23
	}
24
25
	function tests()
26
	{
27
28
		$this->taskExec('mysql -e "CREATE DATABASE IF NOT EXISTS test_db"')->run();
29
		$this->taskExec('mysql -e "GRANT ALL ON test_db.* to \'root\'@\'%\'"')->run();
30
		$this->taskSvnStack()
31
			->checkout('https://develop.svn.wordpress.org/tags/4.8.3 wp-tests')
32
			->run();
33
34
		$this->setTestConfig();
35
		$this->phpunit();
36
37
	}
38
39
	function phpunit()
40
	{
41
		$this->taskPhpUnit('vendor/bin/phpunit')
42
			->configFile('tests/phpunit.xml.dist')
43
			->envVars(array('WP_TESTS_DIR' => 'wp-tests'))
44
			->run();
45
	}
46
47
	private function setTestConfig()
48
	{
49
50
		if (file_exists('wp-tests/wp-tests-config-sample.php')) {
51
			copy('wp-tests/wp-tests-config-sample.php', 'wp-tests/wp-tests-config.php');
52
		}
53
54
		$this->taskReplaceInFile( 'wp-tests/wp-tests-config.php')
55
			->from('youremptytestdbnamehere')
56
			->to('test_db')
57
			->run();
58
59
		$this->taskReplaceInFile( 'wp-tests/wp-tests-config.php')
60
			->from('yourusernamehere')
61
			->to('root')
62
			->run();
63
64
		$this->taskReplaceInFile( 'wp-tests/wp-tests-config.php')
65
			->from('yourpasswordhere')
66
			->to('')
67
			->run();
68
	}
69
70
}