Files
luxtools-plugin/_test/GeneralTest.php
luxick 6a396ce511
Some checks failed
DokuWiki Default Tasks / all (push) Has been cancelled
Add own admin page for the plugin
2026-01-06 22:39:21 +01:00

83 lines
2.4 KiB
PHP

<?php
namespace dokuwiki\plugin\luxtools\test;
use DokuWikiTest;
/**
* General tests for the luxtools plugin
*
* @group plugin_luxtools
* @group plugins
*/
class GeneralTest extends DokuWikiTest
{
/**
* Simple test to make sure the plugin.info.txt is in correct format
*/
public function testPluginInfo(): void
{
$file = __DIR__ . '/../plugin.info.txt';
$this->assertFileExists($file);
$info = confToHash($file);
$this->assertArrayHasKey('base', $info);
$this->assertArrayHasKey('author', $info);
$this->assertArrayHasKey('email', $info);
$this->assertArrayHasKey('date', $info);
$this->assertArrayHasKey('name', $info);
$this->assertArrayHasKey('desc', $info);
$this->assertArrayHasKey('url', $info);
$this->assertEquals('luxtools', $info['base']);
$this->assertRegExp('/^https?:\/\//', $info['url']);
$this->assertTrue(mail_isvalid($info['email']));
$this->assertRegExp('/^\d\d\d\d-\d\d-\d\d$/', $info['date']);
$this->assertTrue(false !== strtotime($info['date']));
}
/**
* luxtools settings are managed via the plugin's admin page, not via the Configuration Manager.
* Ensure default config exists and (when present) metadata.php does not expose any settings.
*/
public function testPluginConf(): void
{
$conf_file = __DIR__ . '/../conf/default.php';
$meta_file = __DIR__ . '/../conf/metadata.php';
if (!file_exists($conf_file)) {
self::markTestSkipped('No config default.php exists -> skipping test');
}
$conf = null;
$meta = null;
include($conf_file);
$this->assertIsArray(
$conf,
'The ' . DOKU_PLUGIN . 'luxtools/conf/default.php file needs to define $conf as an array.'
);
if (file_exists($meta_file)) {
include($meta_file);
if ($meta === null) {
// If the file exists but does not define $meta, treat it as empty.
$meta = [];
}
$this->assertIsArray(
$meta,
'The ' . DOKU_PLUGIN . 'luxtools/conf/metadata.php file needs to define $meta as an array.'
);
$this->assertEmpty(
$meta,
'luxtools should not expose settings via the Configuration Manager.'
);
}
}
}