Skip to content

Commit

Permalink
Remove deprecated methods from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
overclokk committed Sep 25, 2023
1 parent 63cc864 commit 51fb48a
Show file tree
Hide file tree
Showing 9 changed files with 220 additions and 232 deletions.
2 changes: 1 addition & 1 deletion src/GlobalDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
* @psalm-api
*/
class GlobalDispatcher implements EventDispatcherInterface, ListenerRegisterInterface
class GlobalDispatcher implements GlobalDispatcherInterface, ListenerRegisterInterface
{
use LegacyEventDispatcherMethodsDeprecatedTrait;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
namespace ItalyStrap\Tests\Integration;

use ItalyStrap\Event\EventDispatcher;
use ItalyStrap\Event\GlobalOrderedListenerProvider;
use ItalyStrap\Tests\ClassWithDispatchDependency;
use ItalyStrap\Tests\IntegrationTestCase;

class EventDispatcherTest extends IntegrationTestCase
class GlobalDispatcherTest extends IntegrationTestCase
{
private function makeDispatcher(): EventDispatcher
{
Expand All @@ -18,8 +19,9 @@ private function makeDispatcher(): EventDispatcher
public function testItShouldOutputTextOnEventName()
{
$sut = $this->makeDispatcher();
$listenerRegister = new GlobalOrderedListenerProvider();

$sut->addListener('event_name', function () {
$listenerRegister->addListener('event_name', function () {
echo 'Value printed';
});

Expand All @@ -30,10 +32,11 @@ public function testItShouldOutputTextOnEventName()
public function testClassWithDispatchDependency()
{
$sut = $this->makeDispatcher();
$listenerRegister = new GlobalOrderedListenerProvider();

$some_class = new ClassWithDispatchDependency($sut);

$sut->addListener(
$listenerRegister->addListener(
ClassWithDispatchDependency::EVENT_NAME,
fn(string $value) => 'New value'
);
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/SubscriberRegisterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace ItalyStrap\Tests\Integration;

use ItalyStrap\Event\EventDispatcher;
use ItalyStrap\Event\GlobalOrderedListenerProvider;
use ItalyStrap\Event\SubscriberRegister;
use ItalyStrap\Tests\IntegrationTestCase;
use ItalyStrap\Tests\SubscriberMock;
Expand All @@ -17,7 +18,7 @@ class SubscriberRegisterTest extends IntegrationTestCase
private function makeInstance(): SubscriberRegister
{
return new SubscriberRegister(
new EventDispatcher()
new GlobalOrderedListenerProvider()
);
}

Expand Down
13 changes: 7 additions & 6 deletions tests/integration/SubscribersConfigExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
use ItalyStrap\Config\ConfigFactory;
use ItalyStrap\Empress\AurynResolver;
use ItalyStrap\Empress\Injector;
use ItalyStrap\Event\EventDispatcher;
use ItalyStrap\Event\EventDispatcherInterface;
use ItalyStrap\Event\GlobalDispatcher;
use ItalyStrap\Event\GlobalDispatcherInterface;
use ItalyStrap\Event\GlobalOrderedListenerProvider;
use ItalyStrap\Event\ListenerRegisterInterface;
use ItalyStrap\Event\SubscriberRegister;
use ItalyStrap\Event\SubscribersConfigExtension;
Expand All @@ -23,9 +24,9 @@ public function testItShouldConfigureSubscribersExtension()
$injector = new Injector();
$injector->share($injector);

$injector->alias(EventDispatcherInterface::class, EventDispatcher::class);
$injector->alias(ListenerRegisterInterface::class, EventDispatcher::class);
$injector->share(EventDispatcherInterface::class);
$injector->alias(GlobalDispatcherInterface::class, GlobalDispatcher::class);
$injector->alias(ListenerRegisterInterface::class, GlobalOrderedListenerProvider::class);
$injector->share(GlobalDispatcherInterface::class);
$injector->share(SubscriberRegister::class);
$injector->defineParam('provider_args', [
'event' => function () {
Expand All @@ -52,6 +53,6 @@ public function testItShouldConfigureSubscribersExtension()
$empress->resolve();

$this->expectOutputString('Some text');
( $injector->make(EventDispatcher::class) )->trigger('event');
( $injector->make(GlobalDispatcher::class) )->trigger('event');
}
}
5 changes: 0 additions & 5 deletions tests/src/SubscriberRegisterTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ trait SubscriberRegisterTestTrait
{
public function subscriberProvider(): iterable
{
// yield 'event_name => From class string FQCN' => [
// [
// 'event_name' => ListenerCallable::class,
// ]
// ];

$obj = new class {
public function __invoke(): bool
Expand Down
216 changes: 0 additions & 216 deletions tests/unit/EventDispatcherTest.php

This file was deleted.

Loading

0 comments on commit 51fb48a

Please sign in to comment.