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

Commit

Permalink
Merge remote-tracking branch 'origin/php7'
Browse files Browse the repository at this point in the history
  • Loading branch information
holyshared committed Dec 4, 2015
2 parents ad8d51c + 4bfe215 commit c1e9800
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 82 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ language: php
php:
- 5.6
- 5.5
- '7'
before_install:
- composer self-update
- composer install
Expand All @@ -10,4 +11,5 @@ script:
after_script:
- composer coveralls
- vendor/bin/phpmetrics src

notifications:
email: false
3 changes: 0 additions & 3 deletions peridot.coverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
use Peridot\Reporter\Dot\DotReporterPlugin;
use holyshared\peridot\temporary\TemporaryPlugin;

use \RecursiveDirectoryIterator;
use \FilesystemIterator;
use \RecursiveIteratorIterator;


class SuiteLoader implements SuiteLoaderInterface
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/result/FixtureCoverageResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace cloak\spec\result;

use cloak\result\CoverageResult;
use cloak\result\LineResultCollection;
use cloak\result\collection\LineResultCollection;

class FixtureCoverageResult
{
Expand Down
2 changes: 1 addition & 1 deletion spec/reporter/CompositeReporter.spec.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion spec/reporter/MarkdownReporter.spec.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 => [
Expand Down
5 changes: 2 additions & 3 deletions spec/reporter/ProcessingTimeReporter.spec.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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([]);
Expand Down
135 changes: 63 additions & 72 deletions spec/result/CoverageResult.spec.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
});

Expand Down

0 comments on commit c1e9800

Please sign in to comment.