From 393a9650c63df4f0e2f06342a43a2a9d1bc02616 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Kone=C4=8Dn=C3=BD?= Date: Mon, 16 Dec 2024 19:17:32 +0100 Subject: [PATCH] BC break: renamed TestsStartedEvent to TestsStarted and TestsFinishedEvent to TestsFinished --- CHANGELOG.md | 1 + README.md | 4 ++-- .../{TestsStartedEvent.php => TestsFinished.php} | 2 +- .../{TestsFinishedEvent.php => TestsStarted.php} | 2 +- src/ExtensionsEventSubscriber.php | 8 ++++---- src/Tester.php | 16 ++++++++-------- 6 files changed, 17 insertions(+), 16 deletions(-) rename src/Events/{TestsStartedEvent.php => TestsFinished.php} (86%) rename src/Events/{TestsFinishedEvent.php => TestsStarted.php} (86%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 45c743d0..1745c11e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ Version 7.0.0-dev - improved error message for assertions assertSame and assertNotSame when any passed value is boolean - deprecated method TAssertions::showStringOrArray in favor of new showValue (the latter accepts value of any type) - allowing skipping tests based on OS family with default skip checker +- BC break: renamed TestsStartedEvent to TestsStarted and TestsFinishedEvent to TestsFinished Version 6.1.0 - added CodeCoverageExtension, Reader, IAnnotationsReaderEngine, PhpAttributesEngine, TAssertions::getCounter(), TestsStartedEvent, TestsFinishedEvent to public api diff --git a/README.md b/README.md index faf69491..941f619f 100644 --- a/README.md +++ b/README.md @@ -230,9 +230,9 @@ It is possible to change the name for output for formats Cobertura and text, jus Automated tests runner's functionality can be extended by extensions. They can add callbacks for certain events. Extensions have to implement the *MyTester\ITesterExtension* interface. For now, custom extensions cannot be registered when using the script *vendor/bin/mytester*, -Method getEventsPreRun returns callbacks that are called before all tests are run (when we know which test cases should be run), it receives MyTester\Events\TestsStartedEvent as its first parameter. +Method getEventsPreRun returns callbacks that are called before all tests are run (when we know which test cases should be run), it receives MyTester\Events\TestsStarted as its first parameter. -Method getEventsAfterRun returns callbacks that are called after all tests were run, it receives MyTester\Events\TestsFinishedEvent as its first parameter. +Method getEventsAfterRun returns callbacks that are called after all tests were run, it receives MyTester\Events\TestsFinished as its first parameter. Method getEventsBeforeTestCase returns callbacks that are called before a test case is run, it receives MyTester\Events\TestCaseStarted as its first parameter. diff --git a/src/Events/TestsStartedEvent.php b/src/Events/TestsFinished.php similarity index 86% rename from src/Events/TestsStartedEvent.php rename to src/Events/TestsFinished.php index 9f05c372..ec1e6663 100644 --- a/src/Events/TestsStartedEvent.php +++ b/src/Events/TestsFinished.php @@ -8,7 +8,7 @@ /** * @author Jakub Konečný */ -final readonly class TestsStartedEvent +final readonly class TestsFinished { /** * @param TestCase[] $testCases diff --git a/src/Events/TestsFinishedEvent.php b/src/Events/TestsStarted.php similarity index 86% rename from src/Events/TestsFinishedEvent.php rename to src/Events/TestsStarted.php index 89883e85..135f7c35 100644 --- a/src/Events/TestsFinishedEvent.php +++ b/src/Events/TestsStarted.php @@ -8,7 +8,7 @@ /** * @author Jakub Konečný */ -final readonly class TestsFinishedEvent +final readonly class TestsStarted { /** * @param TestCase[] $testCases diff --git a/src/ExtensionsEventSubscriber.php b/src/ExtensionsEventSubscriber.php index 5cc9dc74..c87f146e 100644 --- a/src/ExtensionsEventSubscriber.php +++ b/src/ExtensionsEventSubscriber.php @@ -23,10 +23,10 @@ public function __construct(private array $extensions = []) public static function getSubscribedEvents(): iterable { return [ - Events\TestsStartedEvent::class => [ + Events\TestsStarted::class => [ ["onTestsStarted", ], ], - Events\TestsFinishedEvent::class => [ + Events\TestsFinished::class => [ ["onTestsFinished", ], ], Events\TestCaseStarted::class => [ @@ -38,7 +38,7 @@ public static function getSubscribedEvents(): iterable ]; } - public function onTestsStarted(Events\TestsStartedEvent $event): void + public function onTestsStarted(Events\TestsStarted $event): void { foreach ($this->extensions as $extension) { $callbacks = $extension->getEventsPreRun(); @@ -48,7 +48,7 @@ public function onTestsStarted(Events\TestsStartedEvent $event): void } } - public function onTestsFinished(Events\TestsFinishedEvent $event): void + public function onTestsFinished(Events\TestsFinished $event): void { foreach ($this->extensions as $extension) { $callbacks = $extension->getEventsAfterRun(); diff --git a/src/Tester.php b/src/Tester.php index d3fca122..77f48949 100644 --- a/src/Tester.php +++ b/src/Tester.php @@ -40,23 +40,23 @@ private function createEventDispatcher(): EventDispatcherInterface $listenerProvider->addSubscriber(new ExtensionsEventSubscriber($this->extensions)); $listenerProvider->addListener( - Events\TestsStartedEvent::class, - function (Events\TestsStartedEvent $event) { + Events\TestsStarted::class, + function (Events\TestsStarted $event) { $this->resultsFormatter->reportTestsStarted($event->testCases); }, 100 ); $listenerProvider->addListener( - Events\TestsFinishedEvent::class, - function (Events\TestsFinishedEvent $event) { + Events\TestsFinished::class, + function (Events\TestsFinished $event) { $this->resultsFormatter->reportTestsFinished($event->testCases); }, 100 ); $listenerProvider->addListener( - Events\TestsFinishedEvent::class, - function (Events\TestsFinishedEvent $event) { + Events\TestsFinished::class, + function (Events\TestsFinished $event) { $this->resultsFormatter->outputResults((string) getcwd()); }, 99 @@ -95,7 +95,7 @@ public function execute(): never $testCases[] = $this->testSuiteFactory->create($suite); } - $this->eventDispatcher->dispatch(new Events\TestsStartedEvent($testCases)); + $this->eventDispatcher->dispatch(new Events\TestsStarted($testCases)); foreach ($testCases as $testCase) { $this->eventDispatcher->dispatch(new Events\TestCaseStarted($testCase)); @@ -105,7 +105,7 @@ public function execute(): never $this->eventDispatcher->dispatch(new Events\TestCaseFinished($testCase)); } - $this->eventDispatcher->dispatch(new Events\TestsFinishedEvent($testCases)); + $this->eventDispatcher->dispatch(new Events\TestsFinished($testCases)); exit((int) $failed); }