Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/Hi-Folks/lara-lens into …
Browse files Browse the repository at this point in the history
…develop
  • Loading branch information
roberto-butti committed Apr 10, 2021
2 parents 3b9e30b + bdd59f2 commit f0cbbb7
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
26 changes: 26 additions & 0 deletions src/Lens/Traits/ConfigLens.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,31 @@ public function getConfigsDatabaseFromEnv(ResultLens $results = null)
return $results;
}

public function checkDebugEnv(ResultLens $results = null)
{
if (is_null($results)) {
$results = new ResultLens();
}
$debug = config("app.debug");
$env = config("app.env");
$results->add(
"ENV",
$env
);
$results->add(
"DEBUG",
$debug
);
if ($debug && $env === "production") {
$this->checksBag->addWarningAndHint(
"Check config ENV and DEBUG",
"You have DEBUG mode in Production.",
"Change you APP_DEBUG env parameter to false for Production environments"
);
}
return $results;
}

public function getConfigsDatabase(ResultLens $results = null)
{
if (is_null($results)) {
Expand Down Expand Up @@ -70,6 +95,7 @@ public function getConfigs()
config($value)
);
}
$results = $this->checkDebugEnv($results);
$results = $this->getConfigsDatabase($results);
return $results;
}
Expand Down
19 changes: 18 additions & 1 deletion tests/ConsistencyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace HiFolks\LaraLens\Tests;

use HiFolks\LaraLens\Lens\LaraLens;
use Illuminate\Support\Facades\Config;
use Orchestra\Testbench\TestCase;
use HiFolks\LaraLens\LaraLensServiceProvider;
use Illuminate\Support\Facades\Http;
Expand All @@ -21,7 +22,23 @@ public function test_config_array()
$l = new LaraLens();
$a = $l->getConfigs();
$this->assertIsArray($a->toArray());
$this->assertCount(12, $a->toArray());
$this->assertCount(14, $a->toArray());
$arrayChecks = $l->checksBag->toArray();

$this->assertCount(0, $arrayChecks, "test check config length 0");

$l = new LaraLens();
$a = $l->getConfigs();
config(['app.debug' => true]);
config(['app.env' => "production"]);
$l = new LaraLens();
$a = $l->getConfigs();
$arrayChecks = $l->checksBag->toArray();

// 2 = 1 for the warning , 1 for the hint
$this->assertCount(2, $arrayChecks);



}
/** @test */
Expand Down

0 comments on commit f0cbbb7

Please sign in to comment.