GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — 8.x-4.x ( 94e180...901761 )
by Brant
05:18 queued 31s
created

RoboFile::configureBehat()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 27
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 16
nc 4
nop 1
dl 0
loc 27
rs 9.7333
c 0
b 0
f 0
1
<?php
2
3
use Symfony\Component\Finder\Finder;
4
use Symfony\Component\Yaml\Yaml;
5
use Drupal\Component\Utility\NestedArray;
6
7
class RoboFile extends \Robo\Tasks {
8
9
  /**
10
   * The default URL of the Drupal site.
11
   *
12
   * @var string
13
   */
14
  const BASE_URL = 'http://127.0.0.1:8080';
15
16
  /**
17
   * {@inheritdoc}
18
   */
19
  protected function taskBehat($behat = NULL) {
20
    return parent::taskBehat($behat ?: 'vendor/bin/behat')
21
      ->config('.behat.yml')
22
      ->format('pretty')
23
      ->option('colors')
24
      ->option('stop-on-failure')
25
      ->option('strict');
26
  }
27
28
  protected function taskDrupal($command, $console = NULL) {
29
    return $this->taskExec($console ?: '../vendor/bin/drupal')
30
      ->rawArg($command)
31
      ->dir('docroot');
32
  }
33
34
  protected function taskDrush($command, $drush = NULL) {
35
    return $this->taskExec($drush ?: '../vendor/bin/drush')
36
      ->rawArg($command)
37
      ->dir('docroot');
38
  }
39
40
  /**
41
   * Configures Behat.
42
   *
43
   * @param string $base_url
44
   *  (optional) The URL of the Drupal site.
45
   *
46
   * @return \Robo\Contract\TaskInterface
47
   *   The task to execute.
48
   */
49
  public function configureBehat ($base_url = NULL) {
50
    $configuration = [];
51
52
    /** @var Finder $partials */
53
    $partials = Finder::create()->in('docroot')->files()->name('behat.partial.yml');
54
55
    foreach ($partials as $partial) {
56
      $partial = str_replace(
57
        '%paths.base%',
58
        $partial->getPathInfo()->getRealPath(),
59
        $partial->getContents()
60
      );
61
      $configuration = NestedArray::mergeDeep($configuration, Yaml::parse($partial));
62
    }
63
64
    if ($configuration) {
65
      $configuration = str_replace([
66
          '%base_url%',
67
          '%drupal_root%',
68
        ],
69
        [
70
          $base_url ?: static::BASE_URL,
71
          'docroot',
72
        ],
73
        Yaml::dump($configuration)
74
      );
75
      return $this->taskWriteToFile('.behat.yml')->text($configuration);
76
    }
77
78
  }
79
80
  /**
81
   * Run Behat tests.
82
   *
83
   * To run all tests, simply run 'test:behat'. To run a specific feature, you
84
   * can pass its path, relative to the tests/features directory:
85
   *
86
   * test:behat media/image.feature
87
   *
88
   * You can omit the .feature extension. This example runs
89
   * tests/features/workflow/diff.feature:
90
   *
91
   * test:behat workflow/diff
92
   *
93
   * This also works with a directory of features. This example runs everything
94
   * in tests/features/media:
95
   *
96
   * test:behat media
97
   *
98
   * Any command-line options after the initial -- will be passed unmodified to
99
   * Behat. So you can filter tests by tags, like normal:
100
   *
101
   * test:behat -- --tags=javascript,~media
102
   *
103
   * This command will start Selenium Server in the background during the test
104
   * run, to support functional JavaScript tests.
105
   */
106
  public function testBehat(array $arguments) {
107
    $this
108
      ->taskExec('vendor/bin/selenium-server-standalone')
109
      ->rawArg('-port 4444')
110
      ->rawArg('-log selenium.log')
111
      ->background()
112
      ->run();
113
114
    $task = $this->taskBehat();
115
116
    foreach ($arguments as $argument) {
117
      if ($argument{0} == '-') {
118
        $task->rawArg($argument);
119
      }
120
      else {
121
        $feature = "tests/features/$argument";
122
123
        if (file_exists("$feature.feature")) {
124
          $feature .= '.feature';
125
        }
126
        $task->arg($feature);
127
      }
128
    }
129
    return $task;
130
  }
131
132
}
133