@@ -56,17 +56,20 @@ public static function getDate(): \DateTime
56
56
public function testProviderEntry ()
57
57
{
58
58
$ testClass = new class () extends AbstractEntryProvider {
59
- public function getFoo ()
59
+ public function getNow ()
60
60
{
61
- return ' foo ' ;
61
+ return new \ DateTime () ;
62
62
}
63
63
};
64
64
65
65
$ this ->withContainer ([
66
66
\get_class ($ testClass ) => new CallableEntry ([\get_class ($ testClass ), 'initialize ' ]),
67
- 'foo_value ' => new ProviderEntry ([$ testClass , 'getFoo ' ]),
67
+ 'now ' => new ProviderEntry ([$ testClass , 'getNow ' ]),
68
68
], function (Container $ container ) {
69
- $ this ->assertSame ('foo ' , $ container ->get ('foo_value ' ));
69
+ $ now = $ container ->get ('now ' );
70
+
71
+ $ this ->assertInstanceOf (\DateTime::class, $ now );
72
+ $ this ->assertSame ($ now , $ container ->get ('now ' ));
70
73
});
71
74
}
72
75
@@ -82,6 +85,11 @@ public function testWiredEntry()
82
85
83
86
$ this ->assertInstanceOf (\DateTime::class, $ date );
84
87
$ this ->assertSame (strtotime ($ time ), $ date ->getTimestamp ());
88
+
89
+ $ other = $ container ->get (\DateTime::class);
90
+
91
+ $ this ->assertInstanceOf (\DateTime::class, $ other );
92
+ $ this ->assertSame ($ date , $ other );
85
93
});
86
94
}
87
95
@@ -178,6 +186,23 @@ public function testDoubleCaching()
178
186
});
179
187
}
180
188
189
+ public function testSortingOnCache ()
190
+ {
191
+ $ container = $ this ->getCachedContainer ([
192
+ 'b ' => 'b_value ' ,
193
+ 'c ' => 'c_value ' ,
194
+ 'a ' => 'a_value ' ,
195
+ ]);
196
+
197
+ $ types = new \ReflectionProperty ($ container , 'types ' );
198
+ $ types ->setAccessible (true );
199
+ $ parameters = new \ReflectionProperty ($ container , 'parameters ' );
200
+ $ parameters ->setAccessible (true );
201
+
202
+ $ this ->assertSame (['a ' , 'b ' , 'c ' ], array_keys ($ types ->getValue ($ container )));
203
+ $ this ->assertSame (['a ' , 'b ' , 'c ' ], array_keys ($ parameters ->getValue ($ container )));
204
+ }
205
+
181
206
private function withContainer (array $ values , \Closure $ suite )
182
207
{
183
208
$ suite ($ this ->getContainer ($ values ));
0 commit comments