2
2
3
3
namespace Http \HttplugBundle \Tests \Functional ;
4
4
5
+ use Http \Client \HttpClient ;
6
+ use Http \HttplugBundle \Collector \DebugPluginCollector ;
7
+ use Http \HttplugBundle \Collector \PluginJournal ;
5
8
use Symfony \Bundle \FrameworkBundle \Test \WebTestCase ;
9
+ use Symfony \Component \HttpKernel \Profiler \Profiler ;
6
10
7
11
class ServiceInstantiationTest extends WebTestCase
8
12
{
@@ -12,7 +16,7 @@ public function testHttpClient()
12
16
$ container = static ::$ kernel ->getContainer ();
13
17
$ this ->assertTrue ($ container ->has ('httplug.client ' ));
14
18
$ client = $ container ->get ('httplug.client ' );
15
- $ this ->assertInstanceOf (' Http\Client\ HttpClient' , $ client );
19
+ $ this ->assertInstanceOf (HttpClient::class , $ client );
16
20
}
17
21
18
22
public function testHttpClientNoDebug ()
@@ -21,6 +25,25 @@ public function testHttpClientNoDebug()
21
25
$ container = static ::$ kernel ->getContainer ();
22
26
$ this ->assertTrue ($ container ->has ('httplug.client ' ));
23
27
$ client = $ container ->get ('httplug.client ' );
24
- $ this ->assertInstanceOf ('Http\Client\HttpClient ' , $ client );
28
+ $ this ->assertInstanceOf (HttpClient::class, $ client );
29
+ }
30
+
31
+ public function testDebugToolbar ()
32
+ {
33
+ static ::bootKernel (['debug ' => true ]);
34
+ $ container = static ::$ kernel ->getContainer ();
35
+ $ this ->assertTrue ($ container ->has ('profiler ' ));
36
+ $ profiler = $ container ->get ('profiler ' );
37
+ $ this ->assertInstanceOf (Profiler::class, $ profiler );
38
+ $ this ->assertTrue ($ profiler ->has ('httplug ' ));
39
+ $ collector = $ profiler ->get ('httplug ' );
40
+ $ this ->assertInstanceOf (DebugPluginCollector::class, $ collector );
41
+ /** @var PluginJournal $journal */
42
+ $ journal = $ collector ->getJournal ();
43
+ $ plugins = $ journal ->getPlugins ('acme ' );
44
+ $ this ->assertEquals ([
45
+ 'httplug.plugin.stopwatch ' ,
46
+ 'httplug.plugin.redirect ' ,
47
+ ], $ plugins );
25
48
}
26
49
}
0 commit comments