phpan/phpstan checks and fixes

This commit is contained in:
Clemens Schwaighofer
2022-01-13 16:11:19 +09:00
parent 13c0fcd869
commit 1bd45d8a8a
9 changed files with 97 additions and 23 deletions

View File

@@ -13,12 +13,81 @@ use PHPUnit\Framework\TestCase;
*/
final class CoreLibsDebugLoggingTest extends TestCase
{
public $log;
public function optionsProvider(): array
{
return [
'log folder set' => [
[
'log_folder' => '/tmp'
],
[
'log_folder' => '/tmp/'
],
[]
],
'nothing set' => [
null,
[
'log_folder' => getcwd() . DIRECTORY_SEPARATOR
],
[]
],
'no options set, constant set' => [
null,
[
'log_folder' => '/tmp/'
],
[
'constant' => [
'BASE' => '/tmp',
'LOG' => '/'
]
]
],
];
}
// init tests
// - __construct call with options
/**
* Undocumented function
*
* @dataProvider optionsProvider
* @testdox init test [$_dataName]
*
* @param array|null $options
* @param array $expected
* @param array $override
* @return void
*/
public function testClassInit(?array $options, array $expected, array $override): void
{
if (!empty($override['constant'])) {
foreach ($override['constant'] as $var => $value) {
define($var, $value);
}
}
if ($options === null) {
$this->log = new \CoreLibs\Debug\Logging();
} else {
$this->log = new \CoreLibs\Debug\Logging($options);
}
// check that settings match
// print "LOG: " . $this->log->getSetting('log_folder') . "\n";
$this->assertEquals(
$expected['log_folder'],
$this->log->getSetting('log_folder')
);
}
// setting tests
// - basicSetLogId
// - getLogLevelAll
// - getLogId
// - setLogLevelAll
// - getLogLevelAll
// - debugFor
// - setLogLevel
// - getLogLevel