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: Implement and emit TestDouble\TestStubCreated event
Fixes #51. Co-authored-by: Andreas Möller <am@localheinz.com> Co-authored-by: Arne Blankerts <Arne@Blankerts.de>
- Loading branch information
1 parent
277bfe5
commit 108e61c
Showing
10 changed files
with
157 additions
and
2 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,45 @@ | ||
<?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\TestDouble; | ||
|
||
use PHPUnit\Event\Event; | ||
use PHPUnit\Event\Telemetry; | ||
|
||
final class TestStubCreated implements Event | ||
{ | ||
private Telemetry\Info $telemetryInfo; | ||
|
||
/** | ||
* @var class-string | ||
*/ | ||
private string $className; | ||
|
||
/** | ||
* @psalm-param class-string $className | ||
*/ | ||
public function __construct(Telemetry\Info $telemetryInfo, string $className) | ||
{ | ||
$this->telemetryInfo = $telemetryInfo; | ||
$this->className = $className; | ||
} | ||
|
||
public function telemetryInfo(): Telemetry\Info | ||
{ | ||
return $this->telemetryInfo; | ||
} | ||
|
||
/** | ||
* @return class-string | ||
*/ | ||
public function className(): string | ||
{ | ||
return $this->className; | ||
} | ||
} |
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\TestDouble; | ||
|
||
use PHPUnit\Event\Subscriber; | ||
|
||
interface TestStubCreatedSubscriber extends Subscriber | ||
{ | ||
public function notify(TestStubCreated $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,32 @@ | ||
<?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\TestDouble; | ||
|
||
use PHPUnit\Event\AbstractEventTestCase; | ||
|
||
/** | ||
* @covers \PHPUnit\Event\TestDouble\TestStubCreated | ||
*/ | ||
final class TestStubCreatedTest extends AbstractEventTestCase | ||
{ | ||
public function testConstructorSetsValues(): void | ||
{ | ||
$telemetryInfo = self::createTelemetryInfo(); | ||
$className = self::class; | ||
|
||
$event = new TestStubCreated( | ||
$telemetryInfo, | ||
$className | ||
); | ||
|
||
$this->assertSame($telemetryInfo, $event->telemetryInfo()); | ||
$this->assertSame($className, $event->className()); | ||
} | ||
} |