forked from sebastianbergmann/phpunit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Andreas Möller <am@localheinz.com> Co-authored-by: Arne Blankerts <Arne@Blankerts.de>
- Loading branch information
1 parent
fe473cb
commit 647aa5a
Showing
10 changed files
with
331 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <sebastian@phpunit.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace PHPUnit\Event\TestSuite; | ||
|
||
use ArrayIterator; | ||
use Countable; | ||
use IteratorAggregate; | ||
use PHPUnit\Event\Test\Failure; | ||
|
||
final class FailureCollection implements Countable, IteratorAggregate | ||
{ | ||
/** | ||
* @psalm-var list<Failure> | ||
* | ||
* @var array<int, Failure> | ||
*/ | ||
private array $failures; | ||
|
||
public function __construct(Failure ...$failures) | ||
{ | ||
$this->failures = $failures; | ||
} | ||
|
||
public function count(): int | ||
{ | ||
return count($this->failures); | ||
} | ||
|
||
/** | ||
* @return ArrayIterator<int, Failure> | ||
*/ | ||
public function getIterator(): ArrayIterator | ||
{ | ||
return new ArrayIterator($this->failures); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <sebastian@phpunit.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace PHPUnit\Event\TestSuite; | ||
|
||
final class Result | ||
{ | ||
private int $count; | ||
|
||
private FailureCollection $errors; | ||
|
||
private FailureCollection $failures; | ||
|
||
private FailureCollection $notImplemented; | ||
|
||
private FailureCollection $risky; | ||
|
||
private FailureCollection $skipped; | ||
|
||
private FailureCollection $warnings; | ||
|
||
private array $passed; | ||
|
||
/** | ||
* @psalm-var list<class-string> | ||
* | ||
* @var array<int, string> | ||
*/ | ||
private array $passedClasses; | ||
|
||
/** | ||
* @psalm-param list<class-string> $passedClasses | ||
* | ||
* @param array<int, string> $passedClasses | ||
*/ | ||
public function __construct( | ||
int $count, | ||
FailureCollection $errors, | ||
FailureCollection $failures, | ||
FailureCollection $notImplemented, | ||
FailureCollection $risky, | ||
FailureCollection $skipped, | ||
FailureCollection $warnings, | ||
array $passed, | ||
array $passedClasses | ||
) { | ||
$this->count = $count; | ||
$this->errors = $errors; | ||
$this->failures = $failures; | ||
$this->notImplemented = $notImplemented; | ||
$this->risky = $risky; | ||
$this->skipped = $skipped; | ||
$this->warnings = $warnings; | ||
$this->passed = $passed; | ||
$this->passedClasses = $passedClasses; | ||
} | ||
|
||
public function count(): int | ||
{ | ||
return $this->count; | ||
} | ||
|
||
public function errors(): FailureCollection | ||
{ | ||
return $this->errors; | ||
} | ||
|
||
public function failures(): FailureCollection | ||
{ | ||
return $this->failures; | ||
} | ||
|
||
public function notImplemented(): FailureCollection | ||
{ | ||
return $this->notImplemented; | ||
} | ||
|
||
public function risky(): FailureCollection | ||
{ | ||
return $this->risky; | ||
} | ||
|
||
public function skipped(): FailureCollection | ||
{ | ||
return $this->skipped; | ||
} | ||
|
||
public function warnings(): FailureCollection | ||
{ | ||
return $this->warnings; | ||
} | ||
|
||
public function passed(): array | ||
{ | ||
return $this->passed; | ||
} | ||
|
||
/** | ||
* @psalm-return list<class-string> | ||
* | ||
* @return array<int, string> | ||
*/ | ||
public function passedClasses(): array | ||
{ | ||
return $this->passedClasses; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <sebastian@phpunit.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace PHPUnit\Event; | ||
|
||
use PHPUnit\Event\Test\Failure; | ||
use PHPUnit\Event\TestSuite\FailureCollection; | ||
use PHPUnit\Event\TestSuite\Result; | ||
use PHPUnit\Framework\TestFailure; | ||
use PHPUnit\Framework\TestResult; | ||
|
||
final class TestResultMapper | ||
{ | ||
public function map(TestResult $result): Result | ||
{ | ||
return new Result( | ||
$result->count(), | ||
self::toFailureCollection(...$result->errors()), | ||
self::toFailureCollection(...$result->failures()), | ||
self::toFailureCollection(...$result->notImplemented()), | ||
self::toFailureCollection(...$result->risky()), | ||
self::toFailureCollection(...$result->skipped()), | ||
self::toFailureCollection(...$result->warnings()), | ||
$result->passed(), | ||
$result->passedClasses() | ||
); | ||
} | ||
|
||
private static function toFailureCollection(TestFailure ...$testFailures): FailureCollection | ||
{ | ||
return new FailureCollection(...array_map(static function (TestFailure $testFailure): Failure { | ||
return new Failure( | ||
$testFailure->getTestName(), | ||
$testFailure->thrownException() | ||
); | ||
}, $testFailures)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.