Skip to content
This repository was archived by the owner on Aug 17, 2023. It is now read-only.

Commit c1e9800

Browse files
committed
Merge remote-tracking branch 'origin/php7'
2 parents ad8d51c + 4bfe215 commit c1e9800

File tree

7 files changed

+71
-82
lines changed

7 files changed

+71
-82
lines changed

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ language: php
22
php:
33
- 5.6
44
- 5.5
5+
- '7'
56
before_install:
67
- composer self-update
78
- composer install
@@ -10,4 +11,5 @@ script:
1011
after_script:
1112
- composer coveralls
1213
- vendor/bin/phpmetrics src
13-
14+
notifications:
15+
email: false

peridot.coverage.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
use Peridot\Reporter\Dot\DotReporterPlugin;
1212
use holyshared\peridot\temporary\TemporaryPlugin;
1313

14-
use \RecursiveDirectoryIterator;
15-
use \FilesystemIterator;
16-
use \RecursiveIteratorIterator;
1714

1815

1916
class SuiteLoader implements SuiteLoaderInterface

spec/fixtures/result/FixtureCoverageResult.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace cloak\spec\result;
1313

1414
use cloak\result\CoverageResult;
15-
use cloak\result\LineResultCollection;
15+
use cloak\result\collection\LineResultCollection;
1616

1717
class FixtureCoverageResult
1818
{

spec/reporter/CompositeReporter.spec.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393

9494
describe('onAnalyzeStop', function() {
9595
beforeEach(function() {
96-
$this->result = new AnalyzedCoverageResult(new Sequence());
96+
$this->result = new AnalyzedCoverageResult([]);
9797
$this->stopEvent = new AnalyzeStopEvent($this->result);
9898

9999
$reporter1 = $this->prophet->prophesize(Reporter::class);

spec/reporter/MarkdownReporter.spec.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
$this->source2 = $fixturePath . '/Example2.php';
2929
$this->markdownReport = $fixturePath . '/report.md';
3030

31-
$this->startDateTime = DateTime::createFromFormat('Y-m-d H:i:s', '2014-07-10 00:00:00');
31+
$this->startDateTime = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', '2014-07-10 00:00:00');
3232

3333
$coverageResults = [
3434
$this->source1 => [

spec/reporter/ProcessingTimeReporter.spec.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@
1717
use Zend\Console\Console;
1818
use Zend\Console\ColorInterface as Color;
1919

20-
2120
describe(ProcessingTimeReporter::class, function() {
2221

2322
describe('onStart', function() {
2423
beforeEach(function() {
2524
$this->reporter = new ProcessingTimeReporter();
2625

27-
$this->dateTime = DateTime::createFromFormat('Y-m-d H:i:s', '2014-07-01 12:00:00');
26+
$this->dateTime = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', '2014-07-01 12:00:00');
2827
$this->startEvent = new AnalyzeStartEvent($this->dateTime);
2928

3029
$console = Console::getInstance();
@@ -43,7 +42,7 @@
4342
beforeEach(function() {
4443
$this->reporter = new ProcessingTimeReporter();
4544

46-
$this->dateTime = DateTime::createFromFormat('Y-m-d H:i:s', '2014-07-01 12:00:00');
45+
$this->dateTime = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', '2014-07-01 12:00:00');
4746
$this->startEvent = new AnalyzeStartEvent();
4847

4948
$analyzeResult = AnalyzedResult::fromArray([]);

spec/result/CoverageResult.spec.php

Lines changed: 63 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -12,112 +12,103 @@
1212
use cloak\value\Coverage;
1313
use cloak\spec\result\FixtureCoverageResult;
1414
use cloak\result\CoverageResult;
15-
use cloak\result\LineCountResult;
16-
use cloak\result\CodeCoverageResult;
17-
use Prophecy\Prophet;
18-
15+
use cloak\analyzer\result\LineResult;
16+
use cloak\result\collection\LineResultCollection;
1917

2018
describe(CoverageResult::class, function() {
2119
describe('#getLineCount', function() {
2220
beforeEach(function() {
23-
$this->prophet = new Prophet();
24-
25-
$lineResult = $this->prophet->prophesize(LineCountResult::class);
26-
$lineResult->getLineCount()->willReturn(10);
27-
28-
$this->result = new FixtureCoverageResult( $lineResult->reveal() );
21+
$this->lines = new LineResultCollection([
22+
new LineResult(5, LineResult::EXECUTED),
23+
new LineResult(6, LineResult::EXECUTED)
24+
]);
25+
$this->result = new FixtureCoverageResult( $this->lines );
2926
});
30-
it('delegate to LineResultCollectionInterface#getLineCount', function() {
31-
expect($this->result->getLineCount())->toBe(10);
27+
it('returns the line count', function() {
28+
expect($this->result->getLineCount())->toBe(2);
3229
});
3330
});
34-
3531
describe('#getDeadLineCount', function() {
3632
beforeEach(function() {
37-
$this->prophet = new Prophet();
38-
39-
$lineResult = $this->prophet->prophesize(LineCountResult::class);
40-
$lineResult->getDeadLineCount()->willReturn(10);
41-
42-
$this->result = new FixtureCoverageResult( $lineResult->reveal() );
33+
$this->lines = new LineResultCollection([
34+
new LineResult(5, LineResult::DEAD),
35+
new LineResult(6, LineResult::EXECUTED)
36+
]);
37+
$this->result = new FixtureCoverageResult( $this->lines );
4338
});
44-
it('delegate to LineResultCollectionInterface#getDeadLineCount', function() {
45-
expect($this->result->getDeadLineCount())->toBe(10);
39+
it('returns the deat line count', function() {
40+
expect($this->result->getDeadLineCount())->toBe(1);
4641
});
4742
});
48-
4943
describe('#getUnusedLineCount', function() {
5044
beforeEach(function() {
51-
$this->prophet = new Prophet();
52-
53-
$lineResult = $this->prophet->prophesize(LineCountResult::class);
54-
$lineResult->getUnusedLineCount()->willReturn(10);
55-
56-
$this->result = new FixtureCoverageResult( $lineResult->reveal() );
45+
$this->lines = new LineResultCollection([
46+
new LineResult(5, LineResult::DEAD),
47+
new LineResult(6, LineResult::UNUSED)
48+
]);
49+
$this->result = new FixtureCoverageResult( $this->lines );
5750
});
58-
it('delegate to LineResultCollectionInterface#getUnusedLineCount', function() {
59-
expect($this->result->getUnusedLineCount())->toBe(10);
51+
it('returns the unused line count', function() {
52+
expect($this->result->getUnusedLineCount())->toBe(1);
6053
});
6154
});
62-
6355
describe('#getExecutedLineCount', function() {
6456
beforeEach(function() {
65-
$this->prophet = new Prophet();
66-
67-
$lineResult = $this->prophet->prophesize(LineCountResult::class);
68-
$lineResult->getExecutedLineCount()->willReturn(10);
69-
70-
$this->result = new FixtureCoverageResult( $lineResult->reveal() );
57+
$this->lines = new LineResultCollection([
58+
new LineResult(5, LineResult::DEAD),
59+
new LineResult(6, LineResult::EXECUTED)
60+
]);
61+
$this->result = new FixtureCoverageResult( $this->lines );
7162
});
72-
it('delegate to LineResultCollectionInterface#getExecutedLineCount', function() {
73-
expect($this->result->getExecutedLineCount())->toBe(10);
63+
it('returns the executed line count', function() {
64+
expect($this->result->getExecutedLineCount())->toBe(1);
7465
});
7566
});
7667

7768
describe('#getCodeCoverage', function() {
7869
beforeEach(function() {
79-
$this->prophet = new Prophet();
80-
81-
$lineResult = $this->prophet->prophesize(CodeCoverageResult::class);
82-
$lineResult->getCodeCoverage()->willReturn(100);
83-
84-
$this->result = new FixtureCoverageResult( $lineResult->reveal() );
70+
$this->lines = new LineResultCollection([
71+
new LineResult(5, LineResult::DEAD),
72+
new LineResult(6, LineResult::EXECUTED)
73+
]);
74+
$this->result = new FixtureCoverageResult( $this->lines );
8575
});
86-
it('delegate to LineResultCollectionInterface#getCodeCoverage', function() {
87-
expect($this->result->getCodeCoverage())->toBe(100);
76+
it('returns the code coverage value', function() {
77+
expect($this->result->getCodeCoverage()->value())->toBe(100.0);
8878
});
8979
});
9080

9181
describe('#isCoverageLessThan', function() {
92-
beforeEach(function() {
93-
$this->prophet = new Prophet();
94-
$this->coverage = new Coverage(51);
95-
96-
$lineResult = $this->prophet->prophesize(CodeCoverageResult::class);
97-
$lineResult->isCoverageLessThan($this->coverage)->willReturn(true);
98-
99-
$this->result = new FixtureCoverageResult( $lineResult->reveal() );
100-
});
101-
it('delegate to LineResultCollectionInterface#isCoverageLessThan', function() {
102-
$result = $this->result->isCoverageLessThan($this->coverage);
103-
expect($result)->toBeTrue();
82+
context('when coverage < 51', function () {
83+
beforeEach(function() {
84+
$this->coverage = new Coverage(51);
85+
$this->lines = new LineResultCollection([
86+
new LineResult(5, LineResult::UNUSED),
87+
new LineResult(6, LineResult::EXECUTED)
88+
]);
89+
$this->result = new FixtureCoverageResult( $this->lines );
90+
});
91+
it('returns true', function() {
92+
$result = $this->result->isCoverageLessThan($this->coverage);
93+
expect($result)->toBeTrue();
94+
});
10495
});
10596
});
10697

10798
describe('#isCoverageGreaterEqual', function() {
108-
beforeEach(function() {
109-
$this->prophet = new Prophet();
110-
$this->coverage = new Coverage(51);
111-
112-
$lineResult = $this->prophet->prophesize(CodeCoverageResult::class);
113-
$lineResult->isCoverageGreaterEqual($this->coverage)
114-
->willReturn(false);
115-
116-
$this->result = new FixtureCoverageResult( $lineResult->reveal() );
117-
});
118-
it('delegate to LineResultCollectionInterface#isCoverageGreaterEqual', function() {
119-
$result = $this->result->isCoverageGreaterEqual($this->coverage);
120-
expect($result)->toBeFalse();
99+
context('when coverage < 51', function () {
100+
beforeEach(function() {
101+
$this->coverage = new Coverage(51);
102+
$this->lines = new LineResultCollection([
103+
new LineResult(5, LineResult::UNUSED),
104+
new LineResult(6, LineResult::EXECUTED)
105+
]);
106+
$this->result = new FixtureCoverageResult( $this->lines );
107+
});
108+
it('returns false', function() {
109+
$result = $this->result->isCoverageGreaterEqual($this->coverage);
110+
expect($result)->toBeFalse();
111+
});
121112
});
122113
});
123114

0 commit comments

Comments
 (0)