-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a958ff3
commit ef80a8d
Showing
10 changed files
with
379 additions
and
0 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,56 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace PHPUnit\Runner\DeprecationCollector; | ||
|
||
use PHPUnit\Event\EventFacadeIsSealedException; | ||
use PHPUnit\Event\Facade; | ||
use PHPUnit\Event\Test\DeprecationTriggered; | ||
use PHPUnit\Event\UnknownSubscriberTypeException; | ||
|
||
/** | ||
* @internal This class is not covered by the backward compatibility promise for PHPUnit | ||
*/ | ||
final class Collector | ||
{ | ||
/** | ||
* @psalm-var list<non-empty-string> | ||
*/ | ||
private array $deprecations = []; | ||
|
||
/** | ||
* @throws EventFacadeIsSealedException | ||
* @throws UnknownSubscriberTypeException | ||
*/ | ||
public function __construct(Facade $facade) | ||
{ | ||
$facade->registerSubscribers( | ||
new TestPreparedSubscriber($this), | ||
new TestTriggeredDeprecationSubscriber($this), | ||
); | ||
} | ||
|
||
/** | ||
* @psalm-return list<non-empty-string> | ||
*/ | ||
public function deprecations(): array | ||
{ | ||
return $this->deprecations; | ||
} | ||
|
||
public function testPrepared(): void | ||
{ | ||
$this->deprecations = []; | ||
} | ||
|
||
public function testTriggeredDeprecation(DeprecationTriggered $event): void | ||
{ | ||
$this->deprecations[] = $event->message(); | ||
} | ||
} |
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,55 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace PHPUnit\Runner\DeprecationCollector; | ||
|
||
use PHPUnit\Event\EventFacadeIsSealedException; | ||
use PHPUnit\Event\Facade as EventFacade; | ||
use PHPUnit\Event\UnknownSubscriberTypeException; | ||
|
||
/** | ||
* @internal This class is not covered by the backward compatibility promise for PHPUnit | ||
*/ | ||
final class Facade | ||
{ | ||
private static ?Collector $collector = null; | ||
|
||
/** | ||
* @throws EventFacadeIsSealedException | ||
* @throws UnknownSubscriberTypeException | ||
*/ | ||
public static function init(): void | ||
{ | ||
self::collector(); | ||
} | ||
|
||
/** | ||
* @psalm-return list<non-empty-string> | ||
* | ||
* @throws EventFacadeIsSealedException | ||
* @throws UnknownSubscriberTypeException | ||
*/ | ||
public static function deprecations(): array | ||
{ | ||
return self::collector()->deprecations(); | ||
} | ||
|
||
/** | ||
* @throws EventFacadeIsSealedException | ||
* @throws UnknownSubscriberTypeException | ||
*/ | ||
private static function collector(): Collector | ||
{ | ||
if (self::$collector === null) { | ||
self::$collector = new Collector(EventFacade::instance()); | ||
} | ||
|
||
return self::$collector; | ||
} | ||
} |
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,28 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace PHPUnit\Runner\DeprecationCollector; | ||
|
||
/** | ||
* @internal This class is not covered by the backward compatibility promise for PHPUnit | ||
*/ | ||
abstract class Subscriber | ||
{ | ||
private readonly Collector $collector; | ||
|
||
public function __construct(Collector $collector) | ||
{ | ||
$this->collector = $collector; | ||
} | ||
|
||
protected function collector(): Collector | ||
{ | ||
return $this->collector; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/Runner/DeprecationCollector/Subscriber/TestPreparedSubscriber.php
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,24 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace PHPUnit\Runner\DeprecationCollector; | ||
|
||
use PHPUnit\Event\Test\Prepared; | ||
use PHPUnit\Event\Test\PreparedSubscriber; | ||
|
||
/** | ||
* @internal This class is not covered by the backward compatibility promise for PHPUnit | ||
*/ | ||
final class TestPreparedSubscriber extends Subscriber implements PreparedSubscriber | ||
{ | ||
public function notify(Prepared $event): void | ||
{ | ||
$this->collector()->testPrepared(); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/Runner/DeprecationCollector/Subscriber/TestTriggeredDeprecationSubscriber.php
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,24 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace PHPUnit\Runner\DeprecationCollector; | ||
|
||
use PHPUnit\Event\Test\DeprecationTriggered; | ||
use PHPUnit\Event\Test\DeprecationTriggeredSubscriber; | ||
|
||
/** | ||
* @internal This class is not covered by the backward compatibility promise for PHPUnit | ||
*/ | ||
final class TestTriggeredDeprecationSubscriber extends Subscriber implements DeprecationTriggeredSubscriber | ||
{ | ||
public function notify(DeprecationTriggered $event): void | ||
{ | ||
$this->collector()->testTriggeredDeprecation($event); | ||
} | ||
} |
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.