44
55use Doctrine \ORM \EntityManager ;
66use Doctrine \ORM \Tools \SchemaTool ;
7- use SimpleBus \SymfonyBridge \Tests \Functional \SmokeTest \Auto \AutoCommand ;
8- use SimpleBus \SymfonyBridge \Tests \Functional \SmokeTest \Auto \AutoEvent ;
7+ use SimpleBus \SymfonyBridge \Tests \Functional \SmokeTest \Auto \AutoCommand1 ;
8+ use SimpleBus \SymfonyBridge \Tests \Functional \SmokeTest \Auto \AutoCommand2 ;
9+ use SimpleBus \SymfonyBridge \Tests \Functional \SmokeTest \Auto \AutoEvent1 ;
10+ use SimpleBus \SymfonyBridge \Tests \Functional \SmokeTest \Auto \AutoEvent2 ;
11+ use SimpleBus \SymfonyBridge \Tests \Functional \SmokeTest \Auto \AutoEvent3 ;
912use SimpleBus \SymfonyBridge \Tests \Functional \SmokeTest \TestCommand ;
1013use SimpleBus \SymfonyBridge \Tests \Functional \SmokeTest \TestKernel ;
1114use Symfony \Bundle \FrameworkBundle \Test \KernelTestCase ;
@@ -52,13 +55,13 @@ public function it_handles_a_command_then_dispatches_events_for_all_modified_ent
5255 /**
5356 * @test
5457 */
55- public function it_can_auto_register_event_subscribers ()
58+ public function it_can_auto_register_event_subscribers_using_invoke ()
5659 {
5760 self ::bootKernel (['environment ' => 'config2 ' ]);
5861 $ container = self ::$ kernel ->getContainer ();
5962
60- $ subscriber = $ container ->get ('auto_event_subscriber ' );
61- $ event = new AutoEvent ();
63+ $ subscriber = $ container ->get ('auto_event_subscriber_using_invoke ' );
64+ $ event = new AutoEvent1 ();
6265
6366 $ this ->assertNull ($ subscriber ->handled );
6467
@@ -70,13 +73,51 @@ public function it_can_auto_register_event_subscribers()
7073 /**
7174 * @test
7275 */
73- public function it_can_auto_register_command_handlers ()
76+ public function it_can_auto_register_event_subscribers_using_public_method ()
7477 {
7578 self ::bootKernel (['environment ' => 'config2 ' ]);
7679 $ container = self ::$ kernel ->getContainer ();
7780
78- $ handler = $ container ->get ('auto_command_handler ' );
79- $ command = new AutoCommand ();
81+ $ subscriber = $ container ->get ('auto_event_subscriber_using_public_method ' );
82+ $ event2 = new AutoEvent2 ();
83+ $ event3 = new AutoEvent3 ();
84+
85+ $ this ->assertEmpty ($ subscriber ->handled );
86+
87+ $ container ->get ('event_bus ' )->handle ($ event2 );
88+ $ container ->get ('event_bus ' )->handle ($ event3 );
89+
90+ $ this ->assertSame ([$ event2 , $ event3 ], $ subscriber ->handled );
91+ }
92+
93+ /**
94+ * @test
95+ */
96+ public function it_can_auto_register_command_handlers_using_invoke ()
97+ {
98+ self ::bootKernel (['environment ' => 'config2 ' ]);
99+ $ container = self ::$ kernel ->getContainer ();
100+
101+ $ handler = $ container ->get ('auto_command_handler_using_invoke ' );
102+ $ command = new AutoCommand1 ();
103+
104+ $ this ->assertNull ($ handler ->handled );
105+
106+ $ container ->get ('command_bus ' )->handle ($ command );
107+
108+ $ this ->assertSame ($ command , $ handler ->handled );
109+ }
110+
111+ /**
112+ * @test
113+ */
114+ public function it_can_auto_register_command_handlers_using_public_method ()
115+ {
116+ self ::bootKernel (['environment ' => 'config2 ' ]);
117+ $ container = self ::$ kernel ->getContainer ();
118+
119+ $ handler = $ container ->get ('auto_command_handler_using_public_method ' );
120+ $ command = new AutoCommand2 ();
80121
81122 $ this ->assertNull ($ handler ->handled );
82123
0 commit comments