Skip to content

test that journal is set up correctly #118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions Tests/Functional/ServiceInstantiationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

namespace Http\HttplugBundle\Tests\Functional;

use Http\Client\HttpClient;
use Http\HttplugBundle\Collector\DebugPluginCollector;
use Http\HttplugBundle\Collector\PluginJournal;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\HttpKernel\Profiler\Profiler;

class ServiceInstantiationTest extends WebTestCase
{
Expand All @@ -12,7 +16,7 @@ public function testHttpClient()
$container = static::$kernel->getContainer();
$this->assertTrue($container->has('httplug.client'));
$client = $container->get('httplug.client');
$this->assertInstanceOf('Http\Client\HttpClient', $client);
$this->assertInstanceOf(HttpClient::class, $client);
}

public function testHttpClientNoDebug()
Expand All @@ -21,6 +25,25 @@ public function testHttpClientNoDebug()
$container = static::$kernel->getContainer();
$this->assertTrue($container->has('httplug.client'));
$client = $container->get('httplug.client');
$this->assertInstanceOf('Http\Client\HttpClient', $client);
$this->assertInstanceOf(HttpClient::class, $client);
}

public function testDebugToolbar()
{
static::bootKernel(['debug' => true]);
$container = static::$kernel->getContainer();
$this->assertTrue($container->has('profiler'));
$profiler = $container->get('profiler');
$this->assertInstanceOf(Profiler::class, $profiler);
$this->assertTrue($profiler->has('httplug'));
$collector = $profiler->get('httplug');
$this->assertInstanceOf(DebugPluginCollector::class, $collector);
/** @var PluginJournal $journal */
$journal = $collector->getJournal();
$plugins = $journal->getPlugins('acme');
$this->assertEquals([
'httplug.plugin.stopwatch',
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Nyholm its expected that the journal also tracks the stopwatch, right? or should we hide that from the journal?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, The stopwatch plugin should always be available when we do profiling.

It should not be hidden from the journal.

'httplug.plugin.redirect',
], $plugins);
}
}
9 changes: 8 additions & 1 deletion Tests/Resources/app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ public function registerBundles()
{
$bundles = [
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new \Symfony\Bundle\TwigBundle\TwigBundle(),
new \Http\HttplugBundle\HttplugBundle(),
];

if (in_array($this->getEnvironment(), array('dev', 'test'))) {
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
}

return $bundles;
}

Expand All @@ -23,7 +28,9 @@ public function registerBundles()
*/
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(__DIR__.'/config/config.yml');
$this->isDebug()
? $loader->load(__DIR__.'/config/config_debug.yml')
: $loader->load(__DIR__.'/config/config.yml');
}

/**
Expand Down
8 changes: 6 additions & 2 deletions Tests/Resources/app/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@ framework:
secret: php-http
test: ~

# Use auto discovery
httplug: ~
httplug:
clients:
acme:
factory: httplug.factory.curl
plugins:
- httplug.plugin.redirect
5 changes: 5 additions & 0 deletions Tests/Resources/app/config/config_debug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
imports:
- { resource: config.yml }

framework:
profiler: ~