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

RoboFile::setTestConfig()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 22
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 9.2
c 0
b 0
f 0
cc 2
eloc 15
nc 2
nop 0
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
}