File tree Expand file tree Collapse file tree 5 files changed +12
-13
lines changed
Expand file tree Collapse file tree 5 files changed +12
-13
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,8 @@ public function registerObserver(IObserverComponent $component) : void
4545 $ observerList [] = $ componentPath ;
4646 $ this ->getEventMap ()->save ($ eventName , $ observerList );
4747
48- $ registeredComponents = $ this ->getEventMap ()->load ('components ' ) ?? [];
48+ $ registeredComponents = $ this ->getEventMap ()->load ('components ' )
49+ ?? [];
4950 $ registeredComponents [] = $ componentPath ;
5051 $ this ->getEventMap ()->save ('components ' , $ registeredComponents );
5152 }
@@ -55,6 +56,7 @@ public function dispatchEvent(IEvent $event) : void
5556 {
5657 $ presenter = $ this ->application ->getPresenter ();
5758 \assert ($ presenter instanceof \Nette \Application \UI \Control);
59+
5860 foreach ($ this ->getObserverList (\get_class ($ event )) as $ observerPath ) {
5961 \assert (\is_string ($ observerPath ));
6062
@@ -73,7 +75,8 @@ private function getObserverList(string $eventName) : array
7375
7476 private function isComponentRegistered (string $ componentPath ) : bool
7577 {
76- $ registeredComponents = $ this ->getEventMap ()->load ('components ' ) ?? [];
78+ $ registeredComponents = $ this ->getEventMap ()->load ('components ' )
79+ ?? [];
7780
7881 return \in_array ($ componentPath , $ registeredComponents , true );
7982 }
Original file line number Diff line number Diff line change 44
55namespace Infinityloop \Tests \ObserverComponent ;
66
7- use Infinityloop \ObserverComponent \EventMapper ;
8-
97final class EventMapperTest extends \Mockery \Adapter \Phpunit \MockeryTestCase
108{
119 public function testComponentRegisteredReturn () : void
@@ -155,7 +153,7 @@ public function testDispatchEvent() : void
155153
156154 $ request = new \Nette \Application \Request ('TestPresenter:edit ' );
157155
158- $ component = new TestComponent ();
156+ $ component = new \ Infinityloop \ Tests \ ObserverComponent \ TestComponent ();
159157
160158 $ presenter = \Mockery::mock (\Nette \Application \IPresenter::class);
161159 $ presenter ->expects ('getAction ' )
@@ -188,7 +186,7 @@ public function testDispatchEvent() : void
188186 ->withAnyArgs ()
189187 ->andReturn ([0 => TestComponent::class]);
190188
191- $ event = new TestEventEdit ();
189+ $ event = new \ Infinityloop \ Tests \ ObserverComponent \ TestEventEdit ();
192190
193191 $ instance = new \Infinityloop \ObserverComponent \EventMapper ($ application , $ storage );
194192 $ instance ->dispatchEvent ($ event );
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ public function testInjectEventMapperObservable() : void
3434
3535 $ instance = new \Infinityloop \ObserverComponent \EventMapper ($ application , $ storage );
3636
37- $ decoratorInstance = new class ()
37+ $ decoratorInstance = new class ()
3838 {
3939 use \Infinityloop \ObserverComponent \TObservable;
4040 };
@@ -76,9 +76,9 @@ public function testNotifyObservers() : void
7676
7777 $ instance = new \Infinityloop \ObserverComponent \EventMapper ($ application , $ storage );
7878
79- $ event = new TestEventEdit ();
79+ $ event = new \ Infinityloop \ Tests \ ObserverComponent \ TestEventEdit ();
8080
81- $ decoratorInstance = new class ()
81+ $ decoratorInstance = new class ()
8282 {
8383 use \Infinityloop \ObserverComponent \TObservable;
8484 };
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ public function testInjectEventMapperObserver() : void
3434
3535 $ instance = new \Infinityloop \ObserverComponent \EventMapper ($ application , $ storage );
3636
37- $ decoratorInstance = new class ()
37+ $ decoratorInstance = new class ()
3838 {
3939 use \Infinityloop \ObserverComponent \TObserverComponent;
4040
Original file line number Diff line number Diff line change @@ -10,9 +10,7 @@ class TestComponent implements \Infinityloop\ObserverComponent\IObserverComponen
1010
1111 public static function getObservedEvents () : array
1212 {
13- return [
14- \Infinityloop \Tests \ObserverComponent \TestEventEdit::class
15- ];
13+ return [\Infinityloop \Tests \ObserverComponent \TestEventEdit::class];
1614 }
1715
1816 public function observableUpdated (\Infinityloop \ObserverComponent \IEvent $ event ) : void
You can’t perform that action at this time.
0 commit comments