forked from fenetikm/codeception-module-drupal-user-registry
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRoboFile.php
132 lines (117 loc) · 3.29 KB
/
RoboFile.php
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
<?php
/**
* Define Robo commands for building and testing Drupal User Registry Codeception module.
*
* @see http://robo.li/
*/
class RoboFile extends \Robo\Tasks
{
/**
* @type string
* Location of directory containing source code.
*/
const SRC_DIR = "src";
/**
* @type string
* Location of directory containing documentation files.
*/
const DOCS_DIR = "docs";
/**
* @type string
* Location of directory within DOCS_DIR to contain files generated by PHP_CodeCoverage.
*/
const COVERAGE_DOCS_SUBDIR = "coverage";
/**
* @type string
* Location of directory containing Codeception tests.
*/
const TESTS_DIR = "tests";
/**
* @type string
* Path to Codeception.
*/
const CODECEPTION_PATH = "vendor/bin/codecept";
/**
* Run PHP_CodeSniffer standards checks.
*/
public function cleanupPhpcs()
{
$directories = [self::SRC_DIR, self::TESTS_DIR];
foreach ($directories as $directory) {
$this->taskExec("phpcs --standard=PSR2 " . $directory)
->printed(false)
->run();
}
}
/**
* Regenerate all documentation files.
*/
public function docsGenerate()
{
$this->docsClean();
$this->docsPhpdoc();
$this->docsCoverage();
}
/**
* Generate PhpDocumentor files.
*/
public function docsPhpdoc()
{
$this->taskExec("phpdoc run")->run();
}
/**
* Run unit tests + coverage and copy to docs/coverage/ directory.
*/
public function docsCoverage()
{
$this->taskDeleteDir(self::DOCS_DIR . DIRECTORY_SEPARATOR . self::COVERAGE_DOCS_SUBDIR)->run();
$this->testsCoverage();
$this->taskCopyDir([
"tests/_output/coverage" => self::DOCS_DIR . DIRECTORY_SEPARATOR . self::COVERAGE_DOCS_SUBDIR
])->run();
}
/**
* Clean entire documentation directory.
*/
public function docsClean()
{
$this->taskCleanDir(self::DOCS_DIR)->run();
}
/**
* Build Codeception's auto-generated files.
*/
public function testsBuild()
{
$this->taskExec(sprintf("%s build", self::CODECEPTION_PATH))->run();
}
/**
* Run all tests locally.
*/
public function testsRun()
{
// Still have to build the *Tester classes if we've just checked out.
$this->testsBuild();
foreach (["unit", "functional"] as $suite) {
$this->taskCodecept(self::CODECEPTION_PATH)
->option("config", "codeception.yml")
->option("env", "local")
->suite($suite)
->run();
}
}
/**
* Run CodeCoverage.
*/
public function testsCoverage()
{
// Unable to use taskCodecept() here as "Executing vendor/bin/codecept run --coverage-html unit" actually runs
// the acceptance suite too. The syntax below (with suite before options) seems to work:
//
// $this->taskCodecept(self::CODECEPTION_PATH)
// ->suite("unit")
// ->option("coverage-html")
// ->run();
// @todo Investigate and submit issue.
$this->taskExec(self::CODECEPTION_PATH . " run unit --coverage-html")->run();
}
}