acquia /
df
| 1 | <?php |
||
| 2 | |||
| 3 | class RoboFile extends \Robo\Tasks { |
||
| 4 | |||
| 5 | /** |
||
| 6 | * {@inheritdoc} |
||
| 7 | */ |
||
| 8 | protected function taskBehat($behat = NULL) { |
||
| 9 | return parent::taskBehat($behat ?: 'vendor/bin/behat') |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 10 | ->config('docroot/sites/default/files/behat.yml') |
||
| 11 | ->format('pretty') |
||
| 12 | ->option('colors') |
||
| 13 | ->option('stop-on-failure') |
||
| 14 | ->option('strict'); |
||
| 15 | } |
||
| 16 | |||
| 17 | protected function taskDrupal($command, $console = NULL) { |
||
| 18 | return $this->taskExec($console ?: '../vendor/bin/drupal') |
||
| 19 | ->rawArg($command) |
||
| 20 | ->dir('docroot'); |
||
| 21 | } |
||
| 22 | |||
| 23 | protected function taskDrush($command, $drush = NULL) { |
||
| 24 | return $this->taskExec($drush ?: '../vendor/bin/drush') |
||
| 25 | ->rawArg($command) |
||
| 26 | ->dir('docroot'); |
||
| 27 | } |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Run Behat tests. |
||
| 31 | * |
||
| 32 | * To run all tests, simply run 'test:behat'. To run a specific feature, you |
||
| 33 | * can pass its path, relative to the tests/features directory: |
||
| 34 | * |
||
| 35 | * test:behat media/image.feature |
||
| 36 | * |
||
| 37 | * You can omit the .feature extension. This example runs |
||
| 38 | * tests/features/workflow/diff.feature: |
||
| 39 | * |
||
| 40 | * test:behat workflow/diff |
||
| 41 | * |
||
| 42 | * This also works with a directory of features. This example runs everything |
||
| 43 | * in tests/features/media: |
||
| 44 | * |
||
| 45 | * test:behat media |
||
| 46 | * |
||
| 47 | * Any command-line options after the initial -- will be passed unmodified to |
||
| 48 | * Behat. So you can filter tests by tags, like normal: |
||
| 49 | * |
||
| 50 | * test:behat -- --tags=javascript,~media |
||
| 51 | * |
||
| 52 | * This command will start Selenium Server in the background during the test |
||
| 53 | * run, to support functional JavaScript tests. |
||
| 54 | */ |
||
| 55 | public function testBehat(array $arguments) { |
||
| 56 | $this |
||
| 57 | ->taskExec('vendor/bin/selenium-server-standalone') |
||
| 58 | ->rawArg('-port 4444') |
||
| 59 | ->rawArg('-log selenium.log') |
||
| 60 | ->background() |
||
| 61 | ->run(); |
||
| 62 | |||
| 63 | $task = $this->taskBehat(); |
||
| 64 | |||
| 65 | foreach ($arguments as $argument) { |
||
| 66 | if ($argument{0} == '-') { |
||
| 67 | $task->rawArg($argument); |
||
| 68 | } |
||
| 69 | else { |
||
| 70 | $feature = "tests/features/$argument"; |
||
| 71 | |||
| 72 | if (file_exists("$feature.feature")) { |
||
| 73 | $feature .= '.feature'; |
||
| 74 | } |
||
| 75 | $task->arg($feature); |
||
| 76 | } |
||
| 77 | } |
||
| 78 | return $task; |
||
| 79 | } |
||
| 80 | |||
| 81 | } |
||
| 82 |