diff --git a/src/DebuggerManager.php b/src/DebuggerManager.php index 8c979f4..921741d 100644 --- a/src/DebuggerManager.php +++ b/src/DebuggerManager.php @@ -315,13 +315,9 @@ protected function renderBuffer(callable $callback) */ protected function replacePath($content) { - static $path; - - if (is_null($path) === true) { - $path = is_null($this->urlGenerator) === false - ? $this->urlGenerator->route(Arr::get($this->config, 'route.as').'bar') - : null; - } + $path = is_null($this->urlGenerator) === false + ? $this->urlGenerator->route(Arr::get($this->config, 'route.as').'bar') + : null; return is_null($path) === false ? str_replace('?_tracy_bar', $path.'?_tracy_bar', $content) diff --git a/src/LaravelTracyServiceProvider.php b/src/LaravelTracyServiceProvider.php index 7a7ddae..6b627d9 100644 --- a/src/LaravelTracyServiceProvider.php +++ b/src/LaravelTracyServiceProvider.php @@ -41,12 +41,8 @@ class LaravelTracyServiceProvider extends ServiceProvider */ public function boot(Kernel $kernel, View $view, Router $router) { - $view->getEngineResolver() - ->resolve('blade') - ->getCompiler() - ->directive('bdump', function ($expression) { - return ""; - }); + $config = $this->app['config']['tracy']; + $this->handleRoutes($router, Arr::get($config, 'route', [])); if ($this->app->runningInConsole() === true) { $this->publishes([__DIR__.'/../config/tracy.php' => config_path('tracy.php')], 'config'); @@ -54,7 +50,13 @@ public function boot(Kernel $kernel, View $view, Router $router) return; } - $config = $this->app['config']['tracy']; + $view->getEngineResolver() + ->resolve('blade') + ->getCompiler() + ->directive('bdump', function ($expression) { + return ""; + }); + $enabled = Arr::get($config, 'enabled', true) === true; if ($enabled === false) { return; @@ -69,7 +71,6 @@ public function boot(Kernel $kernel, View $view, Router $router) $showBar = Arr::get($config, 'showBar', true); if ($showBar === true) { - $this->handleRoutes($router, Arr::get($config, 'route', [])); $kernel->prependMiddleware(RenderBar::class); } } diff --git a/tests/DebuggerManagerTest.php b/tests/DebuggerManagerTest.php index 5c79987..1630459 100644 --- a/tests/DebuggerManagerTest.php +++ b/tests/DebuggerManagerTest.php @@ -290,7 +290,7 @@ public function testReplacePath() $urlGenerator = m::mock('Illuminate\Contracts\Routing\UrlGenerator') ); - $urlGenerator->shouldReceive('route')->once()->andReturn($root = 'foo'); + $urlGenerator->shouldReceive('route')->twice()->andReturn($root = 'foo'); $bar->shouldReceive('renderLoader')->once()->andReturnUsing(function () { echo ''; diff --git a/tests/LaravelTracyServiceProviderTest.php b/tests/LaravelTracyServiceProviderTest.php index 665f5ff..562a88f 100644 --- a/tests/LaravelTracyServiceProviderTest.php +++ b/tests/LaravelTracyServiceProviderTest.php @@ -133,19 +133,19 @@ public function testBootRunningInConsole() $app = m::mock('Illuminate\Contracts\Foundation\Application, ArrayAccess') ); + $app->shouldReceive('offsetGet')->once()->with('config')->andReturn($config = [ + 'tracy' => [ + 'panels' => [ + 'terminal' => true, + ], + ], + ]); + + $app->shouldReceive('routesAreCached')->once()->andReturn(true); + $app->shouldReceive('runningInConsole')->once()->andReturn(true); $view = m::mock('Illuminate\Contracts\View\Factory'); - $view - ->shouldReceive('getEngineResolver')->once()->andReturnSelf() - ->shouldReceive('resolve')->once()->with('blade')->andReturnSelf() - ->shouldReceive('getCompiler')->once()->andReturnSelf() - ->shouldReceive('directive')->once()->with('bdump', m::on(function ($closure) { - $expression = '$foo'; - $compiled = $closure($expression); - - return $compiled === ""; - })); $serviceProvider->boot( $kernel = m::mock('Illuminate\Contracts\Http\Kernel'),