33namespace ApiClients \Tests \Foundation ;
44
55use ApiClients \Foundation \Client ;
6- use ApiClients \Foundation \Events \CommandLocatorEvent ;
76use ApiClients \Foundation \Factory ;
7+ use ApiClients \Foundation \Hydrator \Hydrator ;
8+ use ApiClients \Foundation \Transport \Client as TransportClient ;
89use ApiClients \Foundation \Options ;
910use ApiClients \Tools \TestUtilities \TestCase ;
10- use League \Event \CallbackListener ;
11- use League \Event \EmitterInterface ;
11+ use InvalidArgumentException ;
1212use League \Tactician \Exception \MissingHandlerException ;
1313use React \EventLoop \Factory as LoopFactory ;
14+ use React \EventLoop \LoopInterface ;
1415use Throwable ;
1516use function Clue \React \Block \await ;
1617
@@ -31,27 +32,46 @@ public function testCreate()
3132 $ this ->assertInstanceOf (Client::class, $ client );
3233
3334 $ container = $ client ->getContainer ();
34-
35- $ called = false ;
36- $ container ->get (EmitterInterface::class)->addListener (
37- CommandLocatorEvent::NAME ,
38- CallbackListener::fromCallable (
39- function (CommandLocatorEvent $ event ) use (&$ called ) {
40- $ called = true ;
41- }
42- )
43- );
44-
45- $ this ->assertFalse ($ called );
35+ $ this ->assertInstanceOf (LoopInterface::class, $ container ->get (LoopInterface::class));
36+ $ this ->assertSame ($ loop , $ container ->get (LoopInterface::class));
37+ $ this ->assertInstanceOf (Hydrator::class, $ container ->get (Hydrator::class));
38+ $ this ->assertInstanceOf (TransportClient::class, $ container ->get (TransportClient::class));
4639
4740 try {
4841 await ($ client ->handle (new class () {}), $ loop );
4942 } catch (Throwable $ exception ) {
5043
5144 }
5245
53- $ this ->assertTrue ($ called );
5446 $ this ->assertTrue (isset ($ exception ));
5547 $ this ->assertInstanceOf (MissingHandlerException::class, $ exception );
5648 }
49+
50+ /**
51+ * @expectedException InvalidArgumentException
52+ * @expectedExceptionMessage Missing Hydrator options
53+ */
54+ public function testCreateMissingHydratorOptions ()
55+ {
56+ Factory::create (
57+ LoopFactory::create (),
58+ [
59+ Options::TRANSPORT_OPTIONS => [],
60+ ]
61+ )->getContainer ()->get (Hydrator::class);
62+ }
63+
64+ /**
65+ * @expectedException InvalidArgumentException
66+ * @expectedExceptionMessage Missing Transport options
67+ */
68+ public function testCreateMissingTransportOptions ()
69+ {
70+ Factory::create (
71+ LoopFactory::create (),
72+ [
73+ Options::HYDRATOR_OPTIONS => [],
74+ ]
75+ )->getContainer ()->get (TransportClient::class);
76+ }
5777}
0 commit comments