| 1 | <?php |
||
| 7 | class RoboFile extends \Robo\Tasks |
||
| 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') |
||
| 70 | } |