File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php declare (strict_types=1 );
2
+
3
+ namespace ApiClients \Tests \Supervisord \CommandBus \Handler ;
4
+
5
+ use ApiClients \Client \Supervisord \CommandBus \Command \StateCommand ;
6
+ use ApiClients \Client \Supervisord \CommandBus \Handler \StateHandler ;
7
+ use ApiClients \Client \Supervisord \Resource \StateInterface ;
8
+ use ApiClients \Foundation \Hydrator \Hydrator ;
9
+ use ApiClients \Tools \Services \XmlRpc \XmlRpcService ;
10
+ use ApiClients \Tools \TestUtilities \TestCase ;
11
+ use function React \Promise \resolve ;
12
+
13
+ final class StateHandlerTest extends TestCase
14
+ {
15
+ public function testCommand ()
16
+ {
17
+ $ state = [
18
+ 'statecode ' => 1 ,
19
+ 'statecname ' => 'GOOD ' ,
20
+ ];
21
+
22
+ $ resource = $ this ->prophesize (StateInterface::class)->reveal ();
23
+
24
+ $ service = $ this ->prophesize (XmlRpcService::class);
25
+ $ service ->call ('supervisor.getState ' )->shouldBeCalled ()->willReturn (resolve ($ state ));
26
+
27
+ $ hydrator = $ this ->prophesize (Hydrator::class);
28
+ $ hydrator ->hydrate (StateInterface::HYDRATE_CLASS , $ state )->shouldBeCalled ()->willReturn ($ resource );
29
+
30
+ $ handler = new StateHandler ($ service ->reveal (), $ hydrator ->reveal ());
31
+ $ result = $ this ->await ($ handler ->handle (new StateCommand ()));
32
+
33
+ self ::assertSame ($ resource , $ result );
34
+ }
35
+ }
You can’t perform that action at this time.
0 commit comments