This repository was archived by the owner on Aug 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRoboFile.php
More file actions
135 lines (122 loc) · 3.5 KB
/
RoboFile.php
File metadata and controls
135 lines (122 loc) · 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
class RoboFile extends \Robo\Tasks {
/**
* {@inheritdoc}
*/
protected function taskBehat($behat = NULL) {
return parent::taskBehat($behat ?: 'bin/behat')
->config('tests/behat.yml')
->option('strict');
}
protected function taskDrupal($command, $console = NULL) {
return $this->taskExec($console ?: '../bin/drupal')
->rawArg($command)
->dir('docroot');
}
protected function taskDrush($command, $drush = NULL) {
return $this->taskExec($drush ?: '../bin/drush')
->rawArg($command)
->dir('docroot');
}
/**
* Updates from a previous version of Lightning.
*
* @param string $version
* The version from which to update.
*
* @see ::restore()
*
* @return \Robo\Contract\TaskInterface|NULL
* The task(s) to run, or NULL if the specified version is invalid.
*/
public function update($version) {
$tasks = $this->restore($version);
if ($tasks) {
$tasks
->addTask(
$this->taskDrush('updatedb')->option('yes')
)
->addTask(
$this->taskDrupal('update:intercept')->option('no-interaction')->arg($version)
);
}
return $tasks;
}
/**
* Restores a database dump of a previous version of Lightning.
*
* @param string $version
* The semantic version from which to restore, e.g. 2.1.7. A dump of this
* version must exist in the tests/fixtures directory, named like
* $version.sql.bz2.
*
* @return \Robo\Contract\TaskInterface|NULL
* The task(s) to run, or NULL if the fixture does not exist.
*/
public function restore($version) {
$fixture = "tests/fixtures/$version.sql";
if (file_exists("$fixture.bz2")) {
return $this->collectionBuilder()
->addTask(
$this->taskExec('bunzip2')->arg("$fixture.bz2")->option('keep')->option('force')
)
->addTask(
$this->taskDrupal('database:restore')->option('file', "../$fixture")
)
->completion(
$this->taskFilesystemStack()->remove($fixture)
);
}
else {
$this->say("$version fixture does not exist.");
}
}
/**
* Run Behat tests.
*
* To run all tests, simply run 'test:behat'. To run a specific feature, you
* can pass its path, relative to the tests/features directory:
*
* test:behat media/image.feature
*
* You can omit the .feature extension. This example runs
* tests/features/workflow/diff.feature:
*
* test:behat workflow/diff
*
* This also works with a directory of features. This example runs everything
* in tests/features/media:
*
* test:behat media
*
* Any command-line options after the initial -- will be passed unmodified to
* Behat. So you can filter tests by tags, like normal:
*
* test:behat -- --tags=javascript,~media
*
* This command will start Selenium Server in the background during the test
* run, to support functional JavaScript tests.
*/
public function testBehat(array $arguments) {
$this
->taskExec('bin/selenium-server-standalone')
->rawArg('-port 4444')
->rawArg('-log selenium.log')
->background()
->run();
$task = $this->taskBehat();
foreach ($arguments as $argument) {
if ($argument{0} == '-') {
$task->rawArg($argument);
}
else {
$feature = "tests/features/$argument";
if (file_exists("$feature.feature")) {
$feature .= '.feature';
}
$task->arg($feature);
}
}
return $task;
}
}