20 lines
742 B
PHP
20 lines
742 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
require_once PLUGIN_ROOT . '/exec/lib/PluginLogger.php';
|
|
|
|
test('plugin logger writes exceptions to plugin log file', function (): void {
|
|
$path = TEST_TMP . '/plugin.log';
|
|
|
|
PluginLogger::init($path);
|
|
assert_true(is_file($path), 'Logger should create plugin.log during init');
|
|
assert_same('0600', substr(sprintf('%o', fileperms($path)), -4));
|
|
|
|
PluginLogger::exception(new RuntimeException('DirectAdmin API command failed'), 'CREATE');
|
|
|
|
$log = file_get_contents($path) ?: '';
|
|
assert_contains('CREATE RuntimeException: DirectAdmin API command failed', $log);
|
|
assert_contains('plugin_logger_test.php', $log);
|
|
assert_same('0600', substr(sprintf('%o', fileperms($path)), -4));
|
|
});
|