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.

RoboFile   A
last analyzed

Complexity

Total Complexity 14

Size/Duplication

Total Lines 123
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 14
eloc 46
dl 0
loc 123
rs 10
c 0
b 0
f 0

5 Methods

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