Kahlan\Reporter\Coverage\Exporter\Lcov::export PHP Method

export() public static method

Exports a coverage to a Istanbul compatible JSON format.
public static export ( array $options ) : string
$options array The option array where the possible values are: -`'collector'` _object_ : The collector instance.
return string
    public static function export($options)
    {
        $defaults = ['collector' => null, 'base_path' => getcwd()];
        $options += $defaults;
        $collector = $options['collector'];
        $export = '';
        $base = $options['base_path'] ? rtrim($options['base_path'], DS) . DS : '';
        foreach ($collector->export() as $file => $coverage) {
            $path = $base . $file;
            $export .= static::_export($path, $collector->parse($file), $coverage);
        }
        return $export;
    }

Usage Example

Esempio n. 1
0
DA:13,0
LF:4
LH:2
end_of_record
EOD;
            expect($txt)->toBe($expected);
        });
        it("exports the coverage of a file with an extra line at the end", function () {
            $path = 'spec' . DS . 'Fixture' . DS . 'Reporter' . DS . 'Coverage' . DS . 'ExtraEmptyLine.php';
            $collector = new Collector(['driver' => $this->driver, 'path' => $path]);
            $code = new ExtraEmptyLine();
            $collector->start();
            $code->shallNotPass();
            $collector->stop();
            $time = time();
            $txt = Lcov::export(['collector' => $collector, 'base_path' => DS . 'home' . DS . 'crysalead' . DS . 'kahlan']);
            $ds = DS;
            $expected = <<<EOD
TN:
SF:/home/crysalead/kahlan/spec/Fixture/Reporter/Coverage/ExtraEmptyLine.php
1,shallNotPass
FNDA:1,shallNotPass
FNF:1
FNH:1
DA:8,1
DA:10,0
DA:12,1
DA:13,0
LF:4
LH:2
end_of_record