$json = Istanbul::export(['collector' => $collector, 'base_path' => DS . 'home' . DS . 'crysalead' . DS . 'kahlan']);
$ds = DS;
$expected = <<<EOD
{"\\/home\\/crysalead\\/kahlan\\/spec\\/Fixture\\/Reporter\\/Coverage\\/NoEmptyLine.php":{"path":"\\/home\\/crysalead\\/kahlan\\/spec\\/Fixture\\/Reporter\\/Coverage\\/NoEmptyLine.php","s":{"1":1,"2":0,"3":1,"4":0},"f":{"1":1},"b":[],"statementMap":{"1":{"start":{"line":8,"column":0},"end":{"line":8,"column":31}},"2":{"start":{"line":10,"column":0},"end":{"line":10,"column":34}},"3":{"start":{"line":12,"column":0},"end":{"line":12,"column":30}},"4":{"start":{"line":13,"column":0},"end":{"line":13,"column":30}}},"fnMap":{"1":{"name":"shallNotPass","line":6,"loc":{"start":{"line":6,"column":0},"end":{"line":14,"column":false}}}},"branchMap":[]}}
EOD;
expect($json)->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();
$json = Istanbul::export(['collector' => $collector, 'base_path' => DS . 'home' . DS . 'crysalead' . DS . 'kahlan']);
$ds = DS;
$expected = <<<EOD
{"\\/home\\/crysalead\\/kahlan\\/spec\\/Fixture\\/Reporter\\/Coverage\\/ExtraEmptyLine.php":{"path":"\\/home\\/crysalead\\/kahlan\\/spec\\/Fixture\\/Reporter\\/Coverage\\/ExtraEmptyLine.php","s":{"1":1,"2":0,"3":1,"4":0},"f":{"1":1},"b":[],"statementMap":{"1":{"start":{"line":8,"column":0},"end":{"line":8,"column":31}},"2":{"start":{"line":10,"column":0},"end":{"line":10,"column":34}},"3":{"start":{"line":12,"column":0},"end":{"line":12,"column":30}},"4":{"start":{"line":13,"column":0},"end":{"line":13,"column":30}}},"fnMap":{"1":{"name":"shallNotPass","line":6,"loc":{"start":{"line":6,"column":0},"end":{"line":14,"column":false}}}},"branchMap":[]}}
EOD;
expect($json)->toBe($expected);
});
});
describe("::write()", function () {
beforeEach(function () {
$this->output = tempnam("/tmp", "KAHLAN");
});
afterEach(function () {
unlink($this->output);
});
it("writes the coverage to a file", function () {