Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
15.38% |
2 / 13 |
|
66.67% |
2 / 3 |
CRAP | |
0.00% |
0 / 1 |
| StoreTestCoverageCommand | |
15.38% |
2 / 13 |
|
66.67% |
2 / 3 |
20.15 | |
0.00% |
0 / 1 |
| getName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getHelpText | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| run | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
12 | |||
| 1 | <?php |
| 2 | namespace Apie\FtpServer\SiteCommands; |
| 3 | |
| 4 | use Apie\Core\Context\ApieContext; |
| 5 | use React\Socket\ConnectionInterface; |
| 6 | use SebastianBergmann\CodeCoverage\CodeCoverage; |
| 7 | use SebastianBergmann\CodeCoverage\Report\PHP as PhpReport; |
| 8 | |
| 9 | class StoreTestCoverageCommand implements SiteCommandInterface |
| 10 | { |
| 11 | public function getName(): string |
| 12 | { |
| 13 | return 'TEST'; |
| 14 | } |
| 15 | |
| 16 | public function getHelpText(): string |
| 17 | { |
| 18 | return 'Stores the test coverage data sent by the client (tests only).'; |
| 19 | } |
| 20 | |
| 21 | public function run(ApieContext $apieContext, string $arg = ''): ApieContext |
| 22 | { |
| 23 | $conn = $apieContext->getContext(ConnectionInterface::class); |
| 24 | if (!$arg) { |
| 25 | $conn->write("501 No file path provided for coverage data\r\n"); |
| 26 | return $apieContext; |
| 27 | } |
| 28 | $coverage = $apieContext->getContext(CodeCoverage::class, false); |
| 29 | if ($coverage instanceof CodeCoverage) { |
| 30 | $coverage->stop(); |
| 31 | (new PhpReport)->process($coverage, $arg); |
| 32 | $conn->write("200 Test coverage data stored successfully\r\n"); |
| 33 | } else { |
| 34 | $conn->write("200 No test coverage data to store\r\n"); |
| 35 | //$conn->write("550 No code coverage context available\r\n"); |
| 36 | } |
| 37 | return $apieContext; |
| 38 | } |
| 39 | } |