Skip to content

Commit

Permalink
Merge pull request #48 from Hi-Folks/develop
Browse files Browse the repository at this point in the history
v0.2.3
  • Loading branch information
roberto-butti authored Apr 10, 2021
2 parents a5c3007 + c93d9c3 commit 79e5860
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.2.3 - 2021-04-10
### Add
- Check DEBUG and ENV configuration for production (if production avoid having debug on);
- Check Storage Links and sohw the user a waring if some directory links are missing

### Change
- improve tests and checks script for Workflows

## 0.2.2 - 2020-11-05
### Add
- Add configuration parameters (config/lara-lens.php) for managing webview: LARALENS_PREFIX, LARALENS_MIDDLEWARE, LARALENS_WEB_ENABLED, thanks to @yogendra-revanna, @JexPY, @Zuruckt;
Expand Down
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 79e5860

Please sign in to comment.