From 04206366c76f1a3224d894758b86ee9541f04350 Mon Sep 17 00:00:00 2001 From: holyshared Date: Fri, 4 Dec 2015 10:03:31 +0900 Subject: [PATCH 1/7] php7 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2288e28..6865d42 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,3 @@ script: after_script: - composer coveralls - vendor/bin/phpmetrics src - From 27ae67eeec7ed87ea1af4352281a3f958d3eee59 Mon Sep 17 00:00:00 2001 From: holyshared Date: Fri, 4 Dec 2015 10:03:48 +0900 Subject: [PATCH 2/7] notifications off --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 6865d42..9c78dff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,3 +11,5 @@ script: after_script: - composer coveralls - vendor/bin/phpmetrics src +notifications: + email: false From 497cc9bf3b8c1a2e7bd303111532e1d011393f2c Mon Sep 17 00:00:00 2001 From: holyshared Date: Fri, 4 Dec 2015 10:12:19 +0900 Subject: [PATCH 3/7] fix warning message --- peridot.coverage.php | 3 --- 1 file changed, 3 deletions(-) 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 From 0ac44a1f0678d56be7c904f8bca820b54ea8553e Mon Sep 17 00:00:00 2001 From: holyshared Date: Fri, 4 Dec 2015 10:36:22 +0900 Subject: [PATCH 4/7] fix coverage result spec --- spec/result/CoverageResult.spec.php | 135 +++++++++++++--------------- 1 file changed, 63 insertions(+), 72 deletions(-) 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(); + }); }); }); From 5a8827aafe56b5c552f343c56e8fcef2ed7a03f1 Mon Sep 17 00:00:00 2001 From: holyshared Date: Fri, 4 Dec 2015 10:53:44 +0900 Subject: [PATCH 5/7] fix type hint --- spec/fixtures/result/FixtureCoverageResult.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 { From bd8c9aa4e60eaa3e825ad8fb3c281bd17ab7213d Mon Sep 17 00:00:00 2001 From: holyshared Date: Fri, 4 Dec 2015 11:05:51 +0900 Subject: [PATCH 6/7] DateTime to DateTimeImmutable --- spec/reporter/MarkdownReporter.spec.php | 2 +- spec/reporter/ProcessingTimeReporter.spec.php | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) 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([]); From 4bfe2151edee08d5cf2a254f699a4be4d6dd4f81 Mon Sep 17 00:00:00 2001 From: holyshared Date: Fri, 4 Dec 2015 11:13:19 +0900 Subject: [PATCH 7/7] fix composite reporter spec --- spec/reporter/CompositeReporter.spec.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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);