-
-
Notifications
You must be signed in to change notification settings - Fork 317
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
/** | ||
* SPDX-License-Identifier: MIT | ||
* Copyright (c) 2017-2018 Tobias Reich | ||
* Copyright (c) 2018-2025 LycheeOrg. | ||
*/ | ||
|
||
/** | ||
* We don't care for unhandled exceptions in tests. | ||
* It is the nature of a test to throw an exception. | ||
* Without this suppression we had 100+ Linter warning in this file which | ||
* don't help anything. | ||
* | ||
* @noinspection PhpDocMissingThrowsInspection | ||
* @noinspection PhpUnhandledExceptionInspection | ||
*/ | ||
|
||
namespace Tests\Unit\Middleware; | ||
|
||
use App\Http\Middleware\ConfigIntegrity; | ||
use Illuminate\Support\Facades\DB; | ||
use Symfony\Component\Console\Output\ConsoleOutput; | ||
use Symfony\Component\Console\Output\ConsoleSectionOutput; | ||
use Tests\AbstractTestCase; | ||
|
||
class ConfigIntegrityTest extends AbstractTestCase | ||
{ | ||
private ConsoleSectionOutput $msgSection; | ||
private bool $failed = false; | ||
|
||
public function testConfiguration(): void | ||
{ | ||
$this->msgSection = (new ConsoleOutput())->section(); | ||
|
||
$keys = DB::table('configs')->select('key')->where('level', '=', '1')->pluck('key'); | ||
foreach ($keys as $key) { | ||
if (!in_array($key, ConfigIntegrity::SE_FIELDS, true)) { | ||
$this->msgSection->writeln(sprintf('<comment>Error:</comment> Key %s is not in the list of keys.', $key)); | ||
$this->failed = true; | ||
} | ||
} | ||
|
||
static::assertFalse($this->failed); | ||
} | ||
} |