public function testShowNotFound() { $profiler = ProfilerFactory::build([ProfilerFactory::OPTION_ENABLE => true, ProfilerFactory::OPTION_DATASOURCE_CLASS => File::class, ProfilerFactory::OPTION_DATASOURCE_PROFILES_FOLDER => '/tmp']); $bar = new Bar($profiler); $result = $bar->show('FooBarr'); $this->assertNotEmpty($result); }
/** * Register the service provider. * * @return void */ public function register() { $this->mergeConfigFrom(__DIR__ . '/../config/profiler.php', 'profiler'); if (!$this->app->bound('hash')) { $hash = $this->app->share(function () { return new BcryptHasher(); }); $this->app->bind('hash', $hash); } $config = $this->app->make('config'); $enable = $config->get('app.debug'); $enable = boolval($enable); $profilerRequest = $this->isProfilerCall(); /** @var Logger $logger */ $logger = $this->app->make('log'); try { $profiler = ProfilerFactory::build($this->buildConfiguration($enable, $profilerRequest)); } catch (\Exception $e) { $logger->error('Fail to build profiler error: ' . $e->getMessage(), [' message : ' => $e->getMessage(), ' file : ' => $e->getFile(), ' line : ' => $e->getLine(), ' trace : ' => $e->getTraceAsString()]); $profiler = new NullProfiler(); } if ($enable) { if (!$profilerRequest) { $logger->getMonolog()->pushHandler($profiler->getLogger()); } $this->registerCors(); $this->registerRoutes(); } $this->registerProfiler($profiler); $profiler->initiate(); $profiler->getContext()->sendDebugIds(); Event::listen('kernel.handled', function () use($profiler) { $profiler->terminate(); }); }
public function testSetData() { $profiler = ProfilerFactory::build([ProfilerFactory::OPTION_ENABLE => true, ProfilerFactory::OPTION_DATASOURCE_CLASS => File::class, ProfilerFactory::OPTION_DATASOURCE_PROFILES_FOLDER => '/tmp']); $renderer = new Cache([], $profiler); $renderer->setData(["value" => [['action' => 'GET', 'value' => 'XXX', 'lifetime' => 100, 'key' => 'bwa', 'result' => 'XXX', 'success' => true]]]); $this->assertEquals('GET', $renderer->getData()['value'][0]['action']); $this->assertEquals('XXX', $renderer->getData()['value'][0]['value']); }
public function testContext() { Profiler::$environment = 'http'; $this->profiler = ProfilerFactory::build([]); $this->assertInstanceOf(ContextInterface::class, $this->profiler->getContext()); $this->assertInstanceOf(Http::class, $this->profiler->getContext()); $this->profiler->getContext()->sendDebugIds(); }
public function testData() { $profiler = ProfilerFactory::build([ProfilerFactory::OPTION_ENABLE => true, ProfilerFactory::OPTION_DATASOURCE_CLASS => File::class, ProfilerFactory::OPTION_DATASOURCE_PROFILES_FOLDER => '/tmp']); $renderer = new Timeline(["value" => [['label' => 'foo', 'start' => time() - 10, 'end' => time(), 'key' => 'bar'], ['label' => 'foo2', 'start' => 0, 'end' => time(), 'key' => 'bar2'], ['label' => 'foo3', 'start' => time() - 10, 'end' => 0, 'key' => 'bar3']]], $profiler); $this->assertInternalType('array', $renderer->getData()); $this->assertNotEmpty($renderer->getData()); $this->assertNotEmpty($renderer->getTitle()); $this->assertNotEmpty($renderer->getIcon()); $this->assertNotEmpty($renderer->content()); }
public function testData() { $profiler = ProfilerFactory::build([ProfilerFactory::OPTION_ENABLE => true, ProfilerFactory::OPTION_DATASOURCE_CLASS => File::class, ProfilerFactory::OPTION_DATASOURCE_PROFILES_FOLDER => '/tmp']); $renderer = new Template(["value" => [['name' => 'foo.html.twig', 'data' => 'XX', 'time' => 'XX', 'file' => 'XX']]], $profiler); $this->assertInternalType('array', $renderer->getData()); $this->assertNotEmpty($renderer->getData()); $this->assertNotEmpty($renderer->getTitle()); $this->assertNotEmpty($renderer->getIcon()); $this->assertNotEmpty($renderer->content()); }
public function testData() { $profiler = ProfilerFactory::build([ProfilerFactory::OPTION_ENABLE => true, ProfilerFactory::OPTION_DATASOURCE_CLASS => File::class, ProfilerFactory::OPTION_DATASOURCE_PROFILES_FOLDER => '/tmp']); $renderer = new Included(["value" => ['XXX', 'XXX']], $profiler); $this->assertInternalType('array', $renderer->getData()); $this->assertNotEmpty($renderer->getData()); $this->assertNotEmpty($renderer->getTitle()); $this->assertNotEmpty($renderer->getIcon()); $this->assertNotEmpty($renderer->content()); }
public function testData() { $profiler = ProfilerFactory::build([ProfilerFactory::OPTION_ENABLE => true, ProfilerFactory::OPTION_DATASOURCE_CLASS => File::class, ProfilerFactory::OPTION_DATASOURCE_PROFILES_FOLDER => '/tmp']); $renderer = new Route(["value" => [['method' => 'GET', 'uri' => '/foo', 'name' => 'foo', 'action' => 'foo.do', 'middleware' => null]]], $profiler); $this->assertInternalType('array', $renderer->getData()); $this->assertNotEmpty($renderer->getData()); $this->assertNotEmpty($renderer->getTitle()); $this->assertNotEmpty($renderer->getIcon()); $this->assertNotEmpty($renderer->content()); }
public function testData() { $profiler = ProfilerFactory::build([ProfilerFactory::OPTION_ENABLE => true, ProfilerFactory::OPTION_DATASOURCE_CLASS => File::class, ProfilerFactory::OPTION_DATASOURCE_PROFILES_FOLDER => '/tmp']); $renderer = new PhpVersion(["value" => 'PHP 5.6 Foo-bar'], $profiler); $this->assertEquals('PHP 5.6 Foo-bar', $renderer->getBarContent()); $this->assertInternalType('array', $renderer->getData()); $this->assertNotEmpty($renderer->getData()); $this->assertNotEmpty($renderer->getTitle()); $this->assertEquals('PHP', $renderer->getBadge()); $this->assertNotEmpty($renderer->getIcon()); }
public function testData() { $profiler = ProfilerFactory::build([ProfilerFactory::OPTION_ENABLE => true, ProfilerFactory::OPTION_DATASOURCE_CLASS => File::class, ProfilerFactory::OPTION_DATASOURCE_PROFILES_FOLDER => '/tmp']); $renderer = new Config(["value" => [['value' => 'XXX']]], $profiler); $this->assertFalse($renderer->getBarContent()); $this->assertInternalType('array', $renderer->getData()); $this->assertNotEmpty($renderer->getData()); $this->assertNotEmpty($renderer->getTitle()); $this->assertEmpty($renderer->getBarContent()); $this->assertEquals('-', $renderer->getBadge()); $this->assertNotEmpty($renderer->content()); }
public function testData() { $profiler = ProfilerFactory::build([ProfilerFactory::OPTION_ENABLE => true, ProfilerFactory::OPTION_DATASOURCE_CLASS => File::class, ProfilerFactory::OPTION_DATASOURCE_PROFILES_FOLDER => '/tmp']); $renderer = new Response(["value" => ['status' => ['code' => '200', 'text' => 'ok'], 'charset' => 'utf8', 'maxAge' => null, 'expires' => null, 'lastModified' => null, 'ttl' => null]], $profiler); $this->assertFalse($renderer->getBarContent()); $this->assertInternalType('array', $renderer->getData()); $this->assertNotEmpty($renderer->getData()); $this->assertNotEmpty($renderer->getTitle()); $this->assertEmpty($renderer->getBarContent()); $this->assertEquals('200', $renderer->getBadge()); $this->assertNotEmpty($renderer->getIcon()); $this->assertNotEmpty($renderer->content()); }
public function testData() { $profiler = ProfilerFactory::build([ProfilerFactory::OPTION_ENABLE => true, ProfilerFactory::OPTION_DATASOURCE_CLASS => File::class, ProfilerFactory::OPTION_DATASOURCE_PROFILES_FOLDER => '/tmp']); $renderer = new Request(["value" => ['method' => "get", 'real-method' => "XXX", 'uri' => "/foo", 'scriptName' => "XXX", 'port' => "XXX", 'ssl' => "XXX", 'scheme' => "XXX", 'accept-content-types' => "XXX", 'cookies' => "XXX", 'headers' => "XXX", 'data' => ['get' => "XXX", 'post' => "XXX"], 'charsets' => "XXX", 'default-local' => "XXX", 'local' => "XXX", 'encodings' => "XXX", 'etags' => "XXX", 'session' => ['id' => "XXX", 'data' => "XXX"]]], $profiler); $this->assertFalse($renderer->getBarContent()); $this->assertInternalType('array', $renderer->getData()); $this->assertNotEmpty($renderer->getData()); $this->assertNotEmpty($renderer->getTitle()); $this->assertEmpty($renderer->getBarContent()); $this->assertEquals('GET /foo', $renderer->getBadge()); $this->assertNotEmpty($renderer->getIcon()); $this->assertNotEmpty($renderer->content()); }
public function testData() { $profiler = ProfilerFactory::build([ProfilerFactory::OPTION_ENABLE => true, ProfilerFactory::OPTION_DATASOURCE_CLASS => File::class, ProfilerFactory::OPTION_DATASOURCE_PROFILES_FOLDER => '/tmp']); $renderer = new User(["value" => ['id' => 1, 'identifier' => 'foo', 'detail' => ['foo' => 'bar']]], $profiler); $this->assertFalse($renderer->getBarContent()); $this->assertInternalType('array', $renderer->getData()); $this->assertNotEmpty($renderer->getData()); $this->assertNotEmpty($renderer->getTitle()); $this->assertEmpty($renderer->getBarContent()); $this->assertEquals('foo', $renderer->getBadge()); $this->assertNotEmpty($renderer->getIcon()); $this->assertNotEmpty($renderer->content()); }
public function testData() { $profiler = ProfilerFactory::build([ProfilerFactory::OPTION_ENABLE => true, ProfilerFactory::OPTION_DATASOURCE_CLASS => File::class, ProfilerFactory::OPTION_DATASOURCE_PROFILES_FOLDER => '/tmp']); $renderer = new BarLoader([], $profiler); $this->assertInternalType('array', $renderer->getData()); $this->assertNotEmpty($renderer->getData()); $this->assertArrayHasKey('processId', $renderer->getData()); $this->assertEquals($profiler->getContext()->getProcess()->getId(), $renderer->getData()['processId']); $this->assertNotEmpty($renderer->getTitle()); $this->assertNotEmpty($renderer->getIcon()); $this->assertNotEmpty($renderer->getTitle()); $this->assertNotEmpty($renderer->content()); }
public function testData() { $profiler = ProfilerFactory::build([ProfilerFactory::OPTION_ENABLE => true, ProfilerFactory::OPTION_DATASOURCE_CLASS => File::class, ProfilerFactory::OPTION_DATASOURCE_PROFILES_FOLDER => '/tmp']); $renderer = new Database(["value" => [['query' => 'SELECT foo FROM bar where id = ?', 'bindQuery' => 'SELECT foo FROM bar where id = 1', 'bindings' => ['id' => 1], 'duration' => microtime(true), 'connection' => 'mysql', 'explain' => []]]], $profiler); $this->assertFalse($renderer->getBarContent()); $this->assertInternalType('array', $renderer->getData()); $this->assertNotEmpty($renderer->getData()); $this->assertNotEmpty($renderer->getTitle()); $this->assertEmpty($renderer->getBarContent()); $this->assertEquals('Database (1)', $renderer->getBadge()); $this->assertNotEmpty($renderer->getIcon()); $this->assertNotEmpty($renderer->content()); }
public function testData() { $profiler = ProfilerFactory::build([ProfilerFactory::OPTION_ENABLE => true, ProfilerFactory::OPTION_DATASOURCE_CLASS => File::class, ProfilerFactory::OPTION_DATASOURCE_PROFILES_FOLDER => '/tmp']); $renderer = new Event(["value" => [['name' => self::class, 'param' => ['foo' => 'bar'], 'time' => microtime(true)]]], $profiler); $this->assertFalse($renderer->getBarContent()); $this->assertInternalType('array', $renderer->getData()); $this->assertNotEmpty($renderer->getData()); $this->assertNotEmpty($renderer->getTitle()); $this->assertEmpty($renderer->getBarContent()); $this->assertEquals('Event (1)', $renderer->getBadge()); $this->assertNotEmpty($renderer->getIcon()); $this->assertNotEmpty($renderer->content()); }
public function testData() { $profiler = ProfilerFactory::build([ProfilerFactory::OPTION_ENABLE => true, ProfilerFactory::OPTION_DATASOURCE_CLASS => File::class, ProfilerFactory::OPTION_DATASOURCE_PROFILES_FOLDER => '/tmp', ProfilerFactory::OPTION_COLLECTORS => [PhpVersion::class]]); $profiler->initiate(); $profiler->terminate(); $profiles = $profiler->getDatasource()->all(0, 10); $renderer = new ProcessList($profiles); $this->assertInternalType('array', $renderer->getData()); $this->assertNotEmpty($renderer->getData()); $this->assertArrayHasKey('profiles', $renderer->getData()); $this->assertNotEmpty($renderer->getTitle()); $this->assertNotEmpty($renderer->getIcon()); $this->assertNotEmpty($renderer->content()); }
public function testData() { $profiler = ProfilerFactory::build([ProfilerFactory::OPTION_ENABLE => true, ProfilerFactory::OPTION_DATASOURCE_CLASS => File::class, ProfilerFactory::OPTION_DATASOURCE_PROFILES_FOLDER => '/tmp', ProfilerFactory::OPTION_COLLECTORS => [PhpVersion::class]]); $profiler->initiate(); $profiler->terminate(); $renderer = new Process($this->objectToArray($profiler->getProfile($profiler->getContext()->getProcess()->getId())), $profiler); $this->assertInternalType('array', $renderer->getData()); $this->assertNotEmpty($renderer->getData()); $this->assertArrayHasKey('collectors', $renderer->getData()); $this->assertArrayHasKey('bar', $renderer->getData()); $this->assertNotEmpty($renderer->getTitle()); $this->assertNotEmpty($renderer->getIcon()); $this->assertNotEmpty($renderer->content()); }
public function testHttpContext() { $profiler = ProfilerFactory::build([ProfilerFactory::OPTION_ENVIRONMENT => 'http']); $this->assertInstanceOf(Profiler::class, $profiler); $this->assertInstanceOf(Http::class, $profiler->getContext()); }