19
19
20
20
final class FactoryTest extends TestCase
21
21
{
22
- public function testCreate ()
22
+ public function testcreateContainer ()
23
23
{
24
24
$ loop = LoopFactory::create ();
25
25
26
26
$ stdClass = new \stdClass ();
27
27
$ stdClass ->foo = 'bar ' ;
28
28
29
- $ client = Factory::create (
29
+ $ container = Factory::createContainer (
30
30
$ loop ,
31
31
[
32
32
Options::HYDRATOR_OPTIONS => [],
@@ -42,16 +42,37 @@ public function testCreate()
42
42
]
43
43
);
44
44
45
- $ this ->assertInstanceOf (Client::class, $ client );
46
-
47
- $ container = $ client ->getContainer ();
48
45
$ this ->assertInstanceOf (LoopInterface::class, $ container ->get (LoopInterface::class));
49
46
$ this ->assertSame ($ loop , $ container ->get (LoopInterface::class));
50
47
$ this ->assertInstanceOf (Hydrator::class, $ container ->get (Hydrator::class));
51
48
$ this ->assertInstanceOf (TransportClient::class, $ container ->get (ClientInterface::class));
52
49
$ this ->assertInstanceOf (\stdClass::class, $ container ->get (\stdClass::class));
53
50
$ this ->assertSame ($ stdClass , $ container ->get (\stdClass::class));
54
51
$ this ->assertSame ('bar ' , $ container ->get (\stdClass::class)->foo );
52
+ }
53
+
54
+ public function testCreate ()
55
+ {
56
+ $ loop = LoopFactory::create ();
57
+
58
+ $ stdClass = new \stdClass ();
59
+ $ stdClass ->foo = 'bar ' ;
60
+
61
+ $ client = Factory::create (
62
+ $ loop ,
63
+ [
64
+ Options::HYDRATOR_OPTIONS => [],
65
+ Options::TRANSPORT_OPTIONS => [
66
+ TransportOptions::USER_AGENT => 'User Agent ' ,
67
+ ],
68
+ Options::TRANSPORT_OPTIONS => [
69
+ TransportOptions::USER_AGENT => '' ,
70
+ ],
71
+ Options::CONTAINER_DEFINITIONS => [
72
+ \stdClass::class => $ stdClass ,
73
+ ],
74
+ ]
75
+ );
55
76
56
77
try {
57
78
await ($ client ->handle (new class () {}), $ loop );
@@ -69,12 +90,12 @@ public function testCreate()
69
90
*/
70
91
public function testCreateMissingHydratorOptions ()
71
92
{
72
- Factory::create (
93
+ Factory::createContainer (
73
94
LoopFactory::create (),
74
95
[
75
96
Options::TRANSPORT_OPTIONS => [],
76
97
]
77
- )->getContainer ()-> get (Hydrator::class);
98
+ )->get (Hydrator::class);
78
99
}
79
100
80
101
/**
@@ -83,11 +104,11 @@ public function testCreateMissingHydratorOptions()
83
104
*/
84
105
public function testCreateMissingTransportOptions ()
85
106
{
86
- Factory::create (
107
+ Factory::createContainer (
87
108
LoopFactory::create (),
88
109
[
89
110
Options::HYDRATOR_OPTIONS => [],
90
111
]
91
- )->getContainer ()-> get (ClientInterface::class);
112
+ )->get (ClientInterface::class);
92
113
}
93
114
}
0 commit comments