1 | <?php |
||
12 | class FeatureContext implements Context, SnippetAcceptingContext |
||
13 | { |
||
14 | /** |
||
15 | * @var string Name of directory where test files are keept |
||
16 | */ |
||
17 | private $sourceDir; |
||
18 | |||
19 | /** |
||
20 | * @var string[] Arguments used when invoking readme-tester |
||
21 | */ |
||
22 | private $args = []; |
||
23 | |||
24 | /** |
||
25 | * @var integer The number of processed files |
||
26 | */ |
||
27 | private $fileCount = 0; |
||
28 | |||
29 | /** |
||
30 | * @var integer The number of assertions |
||
31 | */ |
||
32 | private $assertionCount = 0; |
||
33 | |||
34 | /** |
||
35 | * @var integer The number of failed assertions |
||
36 | */ |
||
37 | private $failureCount = 0; |
||
38 | |||
39 | /** |
||
40 | * @var integer Return value of the last readme-tester execution |
||
41 | */ |
||
42 | private $returnValue = 0; |
||
43 | |||
44 | public function __construct() |
||
45 | { |
||
46 | $this->sourceDir = sys_get_temp_dir() . '/readmetester-behat-' . rand() . '/'; |
||
47 | mkdir($this->sourceDir); |
||
48 | } |
||
49 | |||
50 | public function __destruct() |
||
51 | { |
||
52 | exec("rm -rf {$this->sourceDir}"); |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * @Given a markdown file: |
||
57 | */ |
||
58 | public function aMarkdownFile(PyStringNode $string) |
||
59 | { |
||
60 | file_put_contents($this->sourceDir . rand() . '.md', (string)$string); |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * @Given a source file :filename: |
||
65 | */ |
||
66 | public function aSourceFile($filename, PyStringNode $string) |
||
67 | { |
||
68 | file_put_contents($this->sourceDir . $filename, (string)$string); |
||
69 | } |
||
70 | |||
71 | |||
72 | /** |
||
73 | * @Given the command line argument :argument |
||
74 | */ |
||
75 | public function theCommandLineArgument($argument) |
||
76 | { |
||
77 | $this->args[] = $argument; |
||
78 | } |
||
79 | |||
80 | |||
81 | /** |
||
82 | * @When I run readme tester |
||
83 | */ |
||
84 | public function iRunReadmeTester() |
||
85 | { |
||
86 | $command = realpath('bin/readme-tester') . " test {$this->sourceDir} " . implode(' ', $this->args); |
||
87 | |||
88 | $cwd = getcwd(); |
||
89 | chdir($this->sourceDir); |
||
90 | $lastLine = exec($command, $output, $this->returnValue); |
||
91 | chdir($cwd); |
||
92 | |||
93 | $success = preg_match('/^(\d+) files? tested, (\d+) assertions?, (\d+) failures?.$/', $lastLine, $matches); |
||
94 | |||
95 | if (!$success) { |
||
96 | throw new \Exception("Last line of output did not contain test report: ($lastLine)"); |
||
97 | } |
||
98 | |||
99 | $this->fileCount = (int)$matches[1]; |
||
100 | $this->assertionCount = (int)$matches[2]; |
||
101 | $this->failureCount = (int)$matches[3]; |
||
102 | } |
||
103 | |||
104 | /** |
||
105 | * @Then :number tests are executed |
||
106 | */ |
||
107 | public function testsAreExecuted(int $number) |
||
111 | } |
||
112 | } |
||
113 | |||
114 | /** |
||
115 | * @Then :number failures are found |
||
116 | */ |
||
117 | public function failuresAreFound($number) |
||
118 | { |
||
119 | if ($this->failureCount != $number) { |
||
120 | throw new \Exception("{$this->failureCount} failures found, expected $number"); |
||
121 | } |
||
122 | } |
||
123 | |||
124 | /** |
||
125 | * @Then the exit code is :code |
||
126 | */ |
||
127 | public function theExitCodeIs(int $code) |
||
131 | } |
||
132 | } |
||
133 | } |
||
134 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths