diff --git a/src/Illuminate/Foundation/Application.php b/src/Illuminate/Foundation/Application.php index 6a21efb68027..04d49afccf26 100755 --- a/src/Illuminate/Foundation/Application.php +++ b/src/Illuminate/Foundation/Application.php @@ -631,6 +631,16 @@ public function runningUnitTests() return $this->bound('env') && $this['env'] === 'testing'; } + /** + * Determine if the application is running with debug mode enabled. + * + * @return bool + */ + public function hasDebugModeEnabled() + { + return (bool) $this['config']->get('app.debug'); + } + /** * Register all of the configured providers. * diff --git a/tests/Foundation/FoundationApplicationTest.php b/tests/Foundation/FoundationApplicationTest.php index 1f8849f3d419..63abffc4e3ef 100755 --- a/tests/Foundation/FoundationApplicationTest.php +++ b/tests/Foundation/FoundationApplicationTest.php @@ -2,6 +2,7 @@ namespace Illuminate\Tests\Foundation; +use Illuminate\Config\Repository; use Illuminate\Contracts\Support\DeferrableProvider; use Illuminate\Foundation\Application; use Illuminate\Foundation\Bootstrap\RegisterFacades; @@ -239,6 +240,19 @@ public function testEnvironmentHelpers() $this->assertFalse($testing->isProduction()); } + public function testDebugHelper() + { + $debugOff = new Application; + $debugOff['config'] = new Repository(['app' => ['debug' => false]]); + + $this->assertFalse($debugOff->hasDebugModeEnabled()); + + $debugOn = new Application; + $debugOn['config'] = new Repository(['app' => ['debug' => true]]); + + $this->assertTrue($debugOn->hasDebugModeEnabled()); + } + public function testMethodAfterLoadingEnvironmentAddsClosure() { $app = new Application;