Skip to content

Commit ec48ab0

Browse files
authored
Merge pull request #118 from php-http/test-journal
test that journal is set up correctly
2 parents 4408c9a + f358ae6 commit ec48ab0

File tree

4 files changed

+44
-5
lines changed

4 files changed

+44
-5
lines changed

Tests/Functional/ServiceInstantiationTest.php

+25-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
namespace Http\HttplugBundle\Tests\Functional;
44

5+
use Http\Client\HttpClient;
6+
use Http\HttplugBundle\Collector\DebugPluginCollector;
7+
use Http\HttplugBundle\Collector\PluginJournal;
58
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
9+
use Symfony\Component\HttpKernel\Profiler\Profiler;
610

711
class 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
}

Tests/Resources/app/AppKernel.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,14 @@ public function registerBundles()
1212
{
1313
$bundles = [
1414
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
15+
new \Symfony\Bundle\TwigBundle\TwigBundle(),
1516
new \Http\HttplugBundle\HttplugBundle(),
1617
];
1718

19+
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
20+
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
21+
}
22+
1823
return $bundles;
1924
}
2025

@@ -23,7 +28,9 @@ public function registerBundles()
2328
*/
2429
public function registerContainerConfiguration(LoaderInterface $loader)
2530
{
26-
$loader->load(__DIR__.'/config/config.yml');
31+
$this->isDebug()
32+
? $loader->load(__DIR__.'/config/config_debug.yml')
33+
: $loader->load(__DIR__.'/config/config.yml');
2734
}
2835

2936
/**

Tests/Resources/app/config/config.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,9 @@ framework:
22
secret: php-http
33
test: ~
44

5-
# Use auto discovery
6-
httplug: ~
5+
httplug:
6+
clients:
7+
acme:
8+
factory: httplug.factory.curl
9+
plugins:
10+
- httplug.plugin.redirect
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
imports:
2+
- { resource: config.yml }
3+
4+
framework:
5+
profiler: ~

0 commit comments

Comments
 (0)