Skip to content

Commit

Permalink
Fix: Rename TestSuite\RunStarted to TestSuite\Started
Browse files Browse the repository at this point in the history
Related to #25.
  • Loading branch information
localheinz committed Oct 30, 2020
1 parent c502f10 commit 6cbbb2e
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 51 deletions.
10 changes: 5 additions & 5 deletions .psalm/baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -447,11 +447,6 @@
<code>RunFinishedSubscriber</code>
</UnusedClass>
</file>
<file src="src/Event/TestSuite/RunStartedSubscriber.php">
<UnusedClass occurrences="1">
<code>RunStartedSubscriber</code>
</UnusedClass>
</file>
<file src="src/Event/TestSuite/Sorted.php">
<PossiblyUnusedMethod occurrences="3">
<code>executionOrder</code>
Expand All @@ -464,6 +459,11 @@
<code>SortedSubscriber</code>
</UnusedClass>
</file>
<file src="src/Event/TestSuite/StartedSubscriber.php">
<UnusedClass occurrences="1">
<code>StartedSubscriber</code>
</UnusedClass>
</file>
<file src="src/Framework/Assert.php">
<ArgumentTypeCoercion occurrences="2">
<code>$actualElement-&gt;childNodes-&gt;item($i)</code>
Expand Down
10 changes: 5 additions & 5 deletions src/Event/DispatchingEmitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,6 @@ public function testSuiteRunFinished(): void
$this->dispatcher->dispatch(new TestSuite\RunFinished($this->telemetryInfo()));
}

public function testSuiteRunStarted(): void
{
$this->dispatcher->dispatch(new TestSuite\RunStarted($this->telemetryInfo()));
}

public function testSuiteSorted(int $executionOrder, int $executionOrderDefects, bool $resolveDependencies): void
{
$this->dispatcher->dispatch(new TestSuite\Sorted(
Expand All @@ -324,6 +319,11 @@ public function testSuiteSorted(int $executionOrder, int $executionOrderDefects,
));
}

public function testSuiteStarted(): void
{
$this->dispatcher->dispatch(new TestSuite\Started($this->telemetryInfo()));
}

private function telemetryInfo(): Telemetry\Info
{
$current = $this->system->snapshot();
Expand Down
4 changes: 2 additions & 2 deletions src/Event/Emitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function testSuiteLoaded(TestSuite $testSuite): void;

public function testSuiteRunFinished(): void;

public function testSuiteRunStarted(): void;

public function testSuiteSorted(int $executionOrder, int $executionOrderDefects, bool $resolveDependencies): void;

public function testSuiteStarted(): void;
}
4 changes: 2 additions & 2 deletions src/Event/Registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ private static function registerDefaultTypes(TypeMap $typeMap): void
Test\SkippedIncomplete::class,
Test\SkippedWithMessage::class,
TestDouble\MockCreated::class,
TestDouble\MockObjectCreatedForTrait::class,
TestDouble\MockObjectCreatedForAbstractClass::class,
TestDouble\MockObjectCreatedForTrait::class,
TestDouble\PartialMockObjectCreated::class,
TestDouble\TestProxyCreated::class,
TestSuite\AfterClassFinished::class,
TestSuite\Loaded::class,
TestSuite\RunFinished::class,
TestSuite\RunStarted::class,
TestSuite\Sorted::class,
TestSuite\Started::class,
];

foreach ($defaultEvents as $eventClass) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use PHPUnit\Event\Event;
use PHPUnit\Event\Telemetry;

final class RunStarted implements Event
final class Started implements Event
{
/**
* @var Telemetry\Info
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

use PHPUnit\Event\Subscriber;

interface RunStartedSubscriber extends Subscriber
interface StartedSubscriber extends Subscriber
{
public function notify(RunStarted $event): void;
public function notify(Started $event): void;
}
2 changes: 1 addition & 1 deletion src/TextUI/TestRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ public function run(TestSuite $suite, array $arguments = [], array $warnings = [
$this->write(PHP_EOL);
}

Event\Registry::emitter()->testSuiteRunStarted();
Event\Registry::emitter()->testSuiteStarted();

$suite->run($result);

Expand Down
4 changes: 2 additions & 2 deletions tests/_files/NullEmitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ public function testSuiteRunFinished(): void
{
}

public function testSuiteRunStarted(): void
public function testSuiteSorted(int $executionOrder, int $executionOrderDefects, bool $resolveDependencies): void
{
}

public function testSuiteSorted(int $executionOrder, int $executionOrderDefects, bool $resolveDependencies): void
public function testSuiteStarted(): void
{
}
}
56 changes: 28 additions & 28 deletions tests/unit/Event/DispatchingEmitterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1299,34 +1299,6 @@ public function notify(TestSuite\RunFinished $event): void
self::assertInstanceOf(TestSuite\RunFinished::class, $subscriber->lastRecordedEvent());
}

public function testTestSuiteRunStartedDispatchesTestSuiteRunStartedEvent(): void
{
$subscriber = new class extends RecordingSubscriber implements TestSuite\RunStartedSubscriber {
public function notify(TestSuite\RunStarted $event): void
{
$this->record($event);
}
};

$dispatcher = self::createDispatcherWithRegisteredSubscriber(
TestSuite\RunStartedSubscriber::class,
TestSuite\RunStarted::class,
$subscriber
);

$telemetrySystem = self::createTelemetrySystem();

$emitter = new DispatchingEmitter(
$dispatcher,
$telemetrySystem
);

$emitter->testSuiteRunStarted();

self::assertSame(1, $subscriber->recordedEventCount());
self::assertInstanceOf(TestSuite\RunStarted::class, $subscriber->lastRecordedEvent());
}

public function testTestSuiteSortedDispatchesTestSuiteSortedEvent(): void
{
$executionOrder = 9001;
Expand Down Expand Up @@ -1370,6 +1342,34 @@ public function notify(TestSuite\Sorted $event): void
self::assertSame($resolveDependencies, $event->resolveDependencies());
}

public function testTestSuiteStartedDispatchesTestSuiteStartedEvent(): void
{
$subscriber = new class extends RecordingSubscriber implements TestSuite\StartedSubscriber {
public function notify(TestSuite\Started $event): void
{
$this->record($event);
}
};

$dispatcher = self::createDispatcherWithRegisteredSubscriber(
TestSuite\StartedSubscriber::class,
TestSuite\Started::class,
$subscriber
);

$telemetrySystem = self::createTelemetrySystem();

$emitter = new DispatchingEmitter(
$dispatcher,
$telemetrySystem
);

$emitter->testSuiteStarted();

self::assertSame(1, $subscriber->recordedEventCount());
self::assertInstanceOf(TestSuite\Started::class, $subscriber->lastRecordedEvent());
}

private static function createDispatcherWithRegisteredSubscriber(string $subscriberInterface, string $eventClass, Subscriber $subscriber): Dispatcher
{
$typeMap = new TypeMap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
use PHPUnit\Event\AbstractEventTestCase;

/**
* @covers \PHPUnit\Event\TestSuite\RunStarted
* @covers \PHPUnit\Event\TestSuite\Started
*/
final class RunStartedTest extends AbstractEventTestCase
final class StartedTest extends AbstractEventTestCase
{
public function testConstructorSetsValues(): void
{
$telemetryInfo = self::createTelemetryInfo();

$event = new RunStarted($telemetryInfo);
$event = new Started($telemetryInfo);

self::assertSame($telemetryInfo, $event->telemetryInfo());
}
Expand Down

0 comments on commit 6cbbb2e

Please sign in to comment.