diff --git a/.travis.yml b/.travis.yml index 2288e28..9c78dff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ language: php php: - 5.6 - 5.5 + - '7' before_install: - composer self-update - composer install @@ -10,4 +11,5 @@ script: after_script: - composer coveralls - vendor/bin/phpmetrics src - +notifications: + email: false diff --git a/peridot.coverage.php b/peridot.coverage.php index 77570b3..04ad47a 100644 --- a/peridot.coverage.php +++ b/peridot.coverage.php @@ -11,9 +11,6 @@ use Peridot\Reporter\Dot\DotReporterPlugin; use holyshared\peridot\temporary\TemporaryPlugin; -use \RecursiveDirectoryIterator; -use \FilesystemIterator; -use \RecursiveIteratorIterator; class SuiteLoader implements SuiteLoaderInterface diff --git a/spec/fixtures/result/FixtureCoverageResult.php b/spec/fixtures/result/FixtureCoverageResult.php index b356fc0..b02b19b 100644 --- a/spec/fixtures/result/FixtureCoverageResult.php +++ b/spec/fixtures/result/FixtureCoverageResult.php @@ -12,7 +12,7 @@ namespace cloak\spec\result; use cloak\result\CoverageResult; -use cloak\result\LineResultCollection; +use cloak\result\collection\LineResultCollection; class FixtureCoverageResult { diff --git a/spec/reporter/CompositeReporter.spec.php b/spec/reporter/CompositeReporter.spec.php index c989cc2..5318ab6 100644 --- a/spec/reporter/CompositeReporter.spec.php +++ b/spec/reporter/CompositeReporter.spec.php @@ -93,7 +93,7 @@ describe('onAnalyzeStop', function() { beforeEach(function() { - $this->result = new AnalyzedCoverageResult(new Sequence()); + $this->result = new AnalyzedCoverageResult([]); $this->stopEvent = new AnalyzeStopEvent($this->result); $reporter1 = $this->prophet->prophesize(Reporter::class); diff --git a/spec/reporter/MarkdownReporter.spec.php b/spec/reporter/MarkdownReporter.spec.php index bea7552..a9066ba 100644 --- a/spec/reporter/MarkdownReporter.spec.php +++ b/spec/reporter/MarkdownReporter.spec.php @@ -28,7 +28,7 @@ $this->source2 = $fixturePath . '/Example2.php'; $this->markdownReport = $fixturePath . '/report.md'; - $this->startDateTime = DateTime::createFromFormat('Y-m-d H:i:s', '2014-07-10 00:00:00'); + $this->startDateTime = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', '2014-07-10 00:00:00'); $coverageResults = [ $this->source1 => [ diff --git a/spec/reporter/ProcessingTimeReporter.spec.php b/spec/reporter/ProcessingTimeReporter.spec.php index 47f2fc7..8359c06 100644 --- a/spec/reporter/ProcessingTimeReporter.spec.php +++ b/spec/reporter/ProcessingTimeReporter.spec.php @@ -17,14 +17,13 @@ use Zend\Console\Console; use Zend\Console\ColorInterface as Color; - describe(ProcessingTimeReporter::class, function() { describe('onStart', function() { beforeEach(function() { $this->reporter = new ProcessingTimeReporter(); - $this->dateTime = DateTime::createFromFormat('Y-m-d H:i:s', '2014-07-01 12:00:00'); + $this->dateTime = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', '2014-07-01 12:00:00'); $this->startEvent = new AnalyzeStartEvent($this->dateTime); $console = Console::getInstance(); @@ -43,7 +42,7 @@ beforeEach(function() { $this->reporter = new ProcessingTimeReporter(); - $this->dateTime = DateTime::createFromFormat('Y-m-d H:i:s', '2014-07-01 12:00:00'); + $this->dateTime = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', '2014-07-01 12:00:00'); $this->startEvent = new AnalyzeStartEvent(); $analyzeResult = AnalyzedResult::fromArray([]); diff --git a/spec/result/CoverageResult.spec.php b/spec/result/CoverageResult.spec.php index ba14219..576199d 100644 --- a/spec/result/CoverageResult.spec.php +++ b/spec/result/CoverageResult.spec.php @@ -12,112 +12,103 @@ use cloak\value\Coverage; use cloak\spec\result\FixtureCoverageResult; use cloak\result\CoverageResult; -use cloak\result\LineCountResult; -use cloak\result\CodeCoverageResult; -use Prophecy\Prophet; - +use cloak\analyzer\result\LineResult; +use cloak\result\collection\LineResultCollection; describe(CoverageResult::class, function() { describe('#getLineCount', function() { beforeEach(function() { - $this->prophet = new Prophet(); - - $lineResult = $this->prophet->prophesize(LineCountResult::class); - $lineResult->getLineCount()->willReturn(10); - - $this->result = new FixtureCoverageResult( $lineResult->reveal() ); + $this->lines = new LineResultCollection([ + new LineResult(5, LineResult::EXECUTED), + new LineResult(6, LineResult::EXECUTED) + ]); + $this->result = new FixtureCoverageResult( $this->lines ); }); - it('delegate to LineResultCollectionInterface#getLineCount', function() { - expect($this->result->getLineCount())->toBe(10); + it('returns the line count', function() { + expect($this->result->getLineCount())->toBe(2); }); }); - describe('#getDeadLineCount', function() { beforeEach(function() { - $this->prophet = new Prophet(); - - $lineResult = $this->prophet->prophesize(LineCountResult::class); - $lineResult->getDeadLineCount()->willReturn(10); - - $this->result = new FixtureCoverageResult( $lineResult->reveal() ); + $this->lines = new LineResultCollection([ + new LineResult(5, LineResult::DEAD), + new LineResult(6, LineResult::EXECUTED) + ]); + $this->result = new FixtureCoverageResult( $this->lines ); }); - it('delegate to LineResultCollectionInterface#getDeadLineCount', function() { - expect($this->result->getDeadLineCount())->toBe(10); + it('returns the deat line count', function() { + expect($this->result->getDeadLineCount())->toBe(1); }); }); - describe('#getUnusedLineCount', function() { beforeEach(function() { - $this->prophet = new Prophet(); - - $lineResult = $this->prophet->prophesize(LineCountResult::class); - $lineResult->getUnusedLineCount()->willReturn(10); - - $this->result = new FixtureCoverageResult( $lineResult->reveal() ); + $this->lines = new LineResultCollection([ + new LineResult(5, LineResult::DEAD), + new LineResult(6, LineResult::UNUSED) + ]); + $this->result = new FixtureCoverageResult( $this->lines ); }); - it('delegate to LineResultCollectionInterface#getUnusedLineCount', function() { - expect($this->result->getUnusedLineCount())->toBe(10); + it('returns the unused line count', function() { + expect($this->result->getUnusedLineCount())->toBe(1); }); }); - describe('#getExecutedLineCount', function() { beforeEach(function() { - $this->prophet = new Prophet(); - - $lineResult = $this->prophet->prophesize(LineCountResult::class); - $lineResult->getExecutedLineCount()->willReturn(10); - - $this->result = new FixtureCoverageResult( $lineResult->reveal() ); + $this->lines = new LineResultCollection([ + new LineResult(5, LineResult::DEAD), + new LineResult(6, LineResult::EXECUTED) + ]); + $this->result = new FixtureCoverageResult( $this->lines ); }); - it('delegate to LineResultCollectionInterface#getExecutedLineCount', function() { - expect($this->result->getExecutedLineCount())->toBe(10); + it('returns the executed line count', function() { + expect($this->result->getExecutedLineCount())->toBe(1); }); }); describe('#getCodeCoverage', function() { beforeEach(function() { - $this->prophet = new Prophet(); - - $lineResult = $this->prophet->prophesize(CodeCoverageResult::class); - $lineResult->getCodeCoverage()->willReturn(100); - - $this->result = new FixtureCoverageResult( $lineResult->reveal() ); + $this->lines = new LineResultCollection([ + new LineResult(5, LineResult::DEAD), + new LineResult(6, LineResult::EXECUTED) + ]); + $this->result = new FixtureCoverageResult( $this->lines ); }); - it('delegate to LineResultCollectionInterface#getCodeCoverage', function() { - expect($this->result->getCodeCoverage())->toBe(100); + it('returns the code coverage value', function() { + expect($this->result->getCodeCoverage()->value())->toBe(100.0); }); }); describe('#isCoverageLessThan', function() { - beforeEach(function() { - $this->prophet = new Prophet(); - $this->coverage = new Coverage(51); - - $lineResult = $this->prophet->prophesize(CodeCoverageResult::class); - $lineResult->isCoverageLessThan($this->coverage)->willReturn(true); - - $this->result = new FixtureCoverageResult( $lineResult->reveal() ); - }); - it('delegate to LineResultCollectionInterface#isCoverageLessThan', function() { - $result = $this->result->isCoverageLessThan($this->coverage); - expect($result)->toBeTrue(); + context('when coverage < 51', function () { + beforeEach(function() { + $this->coverage = new Coverage(51); + $this->lines = new LineResultCollection([ + new LineResult(5, LineResult::UNUSED), + new LineResult(6, LineResult::EXECUTED) + ]); + $this->result = new FixtureCoverageResult( $this->lines ); + }); + it('returns true', function() { + $result = $this->result->isCoverageLessThan($this->coverage); + expect($result)->toBeTrue(); + }); }); }); describe('#isCoverageGreaterEqual', function() { - beforeEach(function() { - $this->prophet = new Prophet(); - $this->coverage = new Coverage(51); - - $lineResult = $this->prophet->prophesize(CodeCoverageResult::class); - $lineResult->isCoverageGreaterEqual($this->coverage) - ->willReturn(false); - - $this->result = new FixtureCoverageResult( $lineResult->reveal() ); - }); - it('delegate to LineResultCollectionInterface#isCoverageGreaterEqual', function() { - $result = $this->result->isCoverageGreaterEqual($this->coverage); - expect($result)->toBeFalse(); + context('when coverage < 51', function () { + beforeEach(function() { + $this->coverage = new Coverage(51); + $this->lines = new LineResultCollection([ + new LineResult(5, LineResult::UNUSED), + new LineResult(6, LineResult::EXECUTED) + ]); + $this->result = new FixtureCoverageResult( $this->lines ); + }); + it('returns false', function() { + $result = $this->result->isCoverageGreaterEqual($this->coverage); + expect($result)->toBeFalse(); + }); }); });