22
33namespace Http \HttplugBundle \Tests \Functional ;
44
5+ use Http \Client \HttpClient ;
6+ use Http \HttplugBundle \Collector \DebugPluginCollector ;
7+ use Http \HttplugBundle \Collector \PluginJournal ;
58use Symfony \Bundle \FrameworkBundle \Test \WebTestCase ;
9+ use Symfony \Component \HttpKernel \Profiler \Profiler ;
610
711class ServiceInstantiationTest extends WebTestCase
812{
@@ -12,7 +16,7 @@ public function testHttpClient()
1216 $ container = static ::$ kernel ->getContainer ();
1317 $ this ->assertTrue ($ container ->has ('httplug.client ' ));
1418 $ client = $ container ->get ('httplug.client ' );
15- $ this ->assertInstanceOf (' Http\Client\ HttpClient' , $ client );
19+ $ this ->assertInstanceOf (HttpClient::class , $ client );
1620 }
1721
1822 public function testHttpClientNoDebug ()
@@ -21,6 +25,25 @@ public function testHttpClientNoDebug()
2125 $ container = static ::$ kernel ->getContainer ();
2226 $ this ->assertTrue ($ container ->has ('httplug.client ' ));
2327 $ 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 );
2548 }
2649}
0 commit comments