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.
Enhancement: Emit Test\PreConditionFinished event
Fixes #42.
- Loading branch information
1 parent
0471448
commit f17ce58
Showing
10 changed files
with
233 additions
and
19 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
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,68 @@ | ||
<?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\Test; | ||
|
||
use PHPUnit\Event\Event; | ||
use PHPUnit\Event\Telemetry; | ||
use SebastianBergmann\CodeUnit; | ||
|
||
final class PreConditionFinished implements Event | ||
{ | ||
/** | ||
* @var Telemetry\Info | ||
*/ | ||
private $telemetryInfo; | ||
|
||
/** | ||
* @psalm-var class-string | ||
* | ||
* @var string | ||
*/ | ||
private $testClassName; | ||
|
||
/** | ||
* @var array<CodeUnit\ClassMethodUnit> | ||
*/ | ||
private $calledMethods; | ||
|
||
/** | ||
* @psalm-param class-string $testClassName | ||
*/ | ||
public function __construct( | ||
Telemetry\Info $telemetryInfo, | ||
string $testClassName, | ||
CodeUnit\ClassMethodUnit ...$calledMethods | ||
) { | ||
$this->telemetryInfo = $telemetryInfo; | ||
$this->testClassName = $testClassName; | ||
$this->calledMethods = $calledMethods; | ||
} | ||
|
||
public function telemetryInfo(): Telemetry\Info | ||
{ | ||
return $this->telemetryInfo; | ||
} | ||
|
||
/** | ||
* @psalm-return class-string | ||
*/ | ||
public function testClassName(): string | ||
{ | ||
return $this->testClassName; | ||
} | ||
|
||
/** | ||
* @return array<CodeUnit\ClassMethodUnit> | ||
*/ | ||
public function calledMethods(): array | ||
{ | ||
return $this->calledMethods; | ||
} | ||
} |
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,17 @@ | ||
<?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\Test; | ||
|
||
use PHPUnit\Event\Subscriber; | ||
|
||
interface PreConditionFinishedSubscriber extends Subscriber | ||
{ | ||
public function notify(PreConditionFinished $event): void; | ||
} |
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
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,41 @@ | ||
<?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\Test; | ||
|
||
use PHPUnit\Event\AbstractEventTestCase; | ||
use SebastianBergmann\CodeUnit; | ||
|
||
/** | ||
* @covers \PHPUnit\Event\Test\PreConditionFinished | ||
*/ | ||
final class PreConditionFinishedTest extends AbstractEventTestCase | ||
{ | ||
public function testConstructorSetsValues(): void | ||
{ | ||
$telemetryInfo = self::createTelemetryInfo(); | ||
$testClassName = self::class; | ||
$calledMethods = array_map(static function (string $methodName): CodeUnit\ClassMethodUnit { | ||
return CodeUnit\ClassMethodUnit::forClassMethod( | ||
self::class, | ||
$methodName | ||
); | ||
}, get_class_methods($this)); | ||
|
||
$event = new PreConditionFinished( | ||
$telemetryInfo, | ||
$testClassName, | ||
...$calledMethods | ||
); | ||
|
||
self::assertSame($telemetryInfo, $event->telemetryInfo()); | ||
self::assertSame($testClassName, $event->testClassName()); | ||
self::assertSame($calledMethods, $event->calledMethods()); | ||
} | ||
} |