Skip to content

Commit

Permalink
BC break: renamed TestsStartedEvent to TestsStarted and TestsFinished…
Browse files Browse the repository at this point in the history
…Event to TestsFinished
  • Loading branch information
konecnyjakub committed Dec 16, 2024
1 parent eb7fea0 commit 393a965
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* @author Jakub Konečný
*/
final readonly class TestsStartedEvent
final readonly class TestsFinished
{
/**
* @param TestCase[] $testCases
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* @author Jakub Konečný
*/
final readonly class TestsFinishedEvent
final readonly class TestsStarted
{
/**
* @param TestCase[] $testCases
Expand Down
8 changes: 4 additions & 4 deletions src/ExtensionsEventSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 => [
Expand All @@ -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();
Expand All @@ -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();
Expand Down
16 changes: 8 additions & 8 deletions src/Tester.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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));
Expand All @@ -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);
}
Expand Down

0 comments on commit 393a965

Please sign in to comment.