Add script 'get-openssl-version.sh'.

This commit is contained in:
2023-06-21 11:09:08 +02:00
parent 0a7a61049a
commit 14056b44dd
5032 changed files with 340126 additions and 0 deletions

View File

@ -0,0 +1,99 @@
<?php
namespace dokuwiki\plugin\config\test\Setting;
use dokuwiki\plugin\config\core\Setting\Setting;
abstract class AbstractSettingTest extends \DokuWikiTest {
/** @var string the class to test */
protected $class;
/**
* Sets up the proper class to test based on the test's class name
* @throws \Exception
*/
public function setUp() : void {
parent::setUp();
$class = get_class($this);
$class = substr($class, strrpos($class, '\\') + 1, -4);
$class = 'dokuwiki\\plugin\\config\\core\\Setting\\' . $class;
$this->class = $class;
}
public function testInitialBasics() {
/** @var Setting $setting */
$setting = new $this->class('test');
$this->assertEquals('test', $setting->getKey());
$this->assertSame(false, $setting->isProtected());
$this->assertSame(true, $setting->isDefault());
$this->assertSame(false, $setting->hasError());
$this->assertSame(false, $setting->shouldBeSaved());
}
public function testShouldHaveDefault() {
/** @var Setting $setting */
$setting = new $this->class('test');
$this->assertSame(true, $setting->shouldHaveDefault());
}
public function testPrettyKey() {
/** @var Setting $setting */
$setting = new $this->class('test');
$this->assertEquals('test', $setting->getPrettyKey(false));
$setting = new $this->class('test____foo');
$this->assertEquals('test»foo', $setting->getPrettyKey(false));
$setting = new $this->class('test');
$this->assertEquals(
'<a href="https://www.dokuwiki.org/config:test">test</a>',
$setting->getPrettyKey(true)
);
$setting = new $this->class('test____foo');
$this->assertEquals('test»foo', $setting->getPrettyKey(true));
$setting = new $this->class('start');
$this->assertEquals(
'<a href="https://www.dokuwiki.org/config:startpage">start</a>',
$setting->getPrettyKey(true)
);
}
public function testType() {
/** @var Setting $setting */
$setting = new $this->class('test');
$this->assertEquals('dokuwiki', $setting->getType());
$setting = new $this->class('test_foo');
$this->assertEquals('dokuwiki', $setting->getType());
$setting = new $this->class('plugin____test');
$this->assertEquals('plugin', $setting->getType());
$setting = new $this->class('tpl____test');
$this->assertEquals('template', $setting->getType());
}
public function testCaution() {
/** @var Setting $setting */
$setting = new $this->class('test');
$this->assertEquals(false, $setting->caution());
$setting = new $this->class('test', ['_caution' => 'warning']);
$this->assertEquals('warning', $setting->caution());
$setting = new $this->class('test', ['_caution' => 'danger']);
$this->assertEquals('danger', $setting->caution());
$setting = new $this->class('test', ['_caution' => 'security']);
$this->assertEquals('security', $setting->caution());
$setting = new $this->class('test', ['_caution' => 'flargh']);
$this->expectException(\RuntimeException::class);
$setting->caution();
}
}

View File

@ -0,0 +1,20 @@
<?php
namespace dokuwiki\plugin\config\test\Setting;
/**
* @group plugin_config
* @group admin_plugins
* @group plugins
* @group bundled_plugins
*/
class SettingArrayTest extends SettingTest {
/** @inheritdoc */
public function dataOut() {
return [
[ ['foo','bar'], "\$conf['test'] = array('foo', 'bar');\n"]
];
}
}

View File

@ -0,0 +1,24 @@
<?php
namespace dokuwiki\plugin\config\test\Setting;
/**
* @group plugin_config
* @group admin_plugins
* @group plugins
* @group bundled_plugins
*/
class SettingNumericTest extends SettingTest {
/** @inheritdoc */
public function dataOut() {
return [
[42, "\$conf['test'] = 42;\n"],
[0, "\$conf['test'] = 0;\n"],
[-42, "\$conf['test'] = -42;\n"],
[-42.13, "\$conf['test'] = -42.13;\n"],
['12*13', "\$conf['test'] = 12*13;\n"],
];
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace dokuwiki\plugin\config\test\Setting;
/**
* @group plugin_config
* @group admin_plugins
* @group plugins
* @group bundled_plugins
*/
class SettingNumericoptTest extends SettingNumericTest {
/** @inheritdoc */
public function dataOut() {
return array_merge(
parent::dataOut(),
[
['', "\$conf['test'] = '';\n"],
]
);
}
}

View File

@ -0,0 +1,72 @@
<?php
namespace dokuwiki\plugin\config\test\Setting;
/**
* @group plugin_config
* @group admin_plugins
* @group plugins
* @group bundled_plugins
*/
class SettingOnoffTest extends SettingTest {
/** @inheritdoc */
public function dataOut() {
return [
[1, "\$conf['test'] = 1;\n"],
[0, "\$conf['test'] = 0;\n"],
['1', "\$conf['test'] = 1;\n"],
['0', "\$conf['test'] = 0;\n"],
['on', "\$conf['test'] = 1;\n"],
['off', "\$conf['test'] = 0;\n"],
['true', "\$conf['test'] = 1;\n"],
['false', "\$conf['test'] = 0;\n"],
['On', "\$conf['test'] = 1;\n"],
['Off', "\$conf['test'] = 0;\n"],
['True', "\$conf['test'] = 1;\n"],
['False', "\$conf['test'] = 0;\n"],
[true, "\$conf['test'] = 1;\n"],
[false, "\$conf['test'] = 0;\n"],
[3, "\$conf['test'] = 1;\n"],
['3', "\$conf['test'] = 1;\n"],
['', "\$conf['test'] = 0;\n"],
[' ', "\$conf['test'] = 0;\n"],
];
}
/** @inheritdoc */
public function dataShouldBeSaved() {
return [
[0, null, false],
[1, null, false],
[0, 0, false],
[1, 1, false],
[0, 1, true],
[1, 0, true],
['0', '0', false],
['1', '1', false],
['0', '1', true],
['1', '0', true],
['0', 0, false],
['1', 1, false],
['0', 1, true],
['1', 0, true],
[0, '0', false],
[1, '1', false],
[0, '1', true],
[1, '0', true],
];
}
}

View File

@ -0,0 +1,13 @@
<?php
namespace dokuwiki\plugin\config\test\Setting;
/**
* @group plugin_config
* @group admin_plugins
* @group plugins
* @group bundled_plugins
*/
class SettingStringTest extends SettingTest {
}

View File

@ -0,0 +1,70 @@
<?php
namespace dokuwiki\plugin\config\test\Setting;
use dokuwiki\plugin\config\core\Setting\Setting;
/**
* @group plugin_config
* @group admin_plugins
* @group plugins
* @group bundled_plugins
*/
class SettingTest extends AbstractSettingTest {
/**
* Dataprovider for testOut()
*
* @return array
*/
public function dataOut() {
return [
['bar', "\$conf['test'] = 'bar';\n"],
["foo'bar", "\$conf['test'] = 'foo\\'bar';\n"],
];
}
/**
* Check the output
*
* @param mixed $in The value to initialize the setting with
* @param string $out The expected output (for conf[test])
* @dataProvider dataOut
*/
public function testOut($in, $out) {
/** @var Setting $setting */
$setting = new $this->class('test');
$setting->initialize('ignore', $in);
$this->assertEquals($out, $setting->out('conf'));
}
/**
* DataProvider for testShouldBeSaved()
*
* @return array
*/
public function dataShouldBeSaved() {
return [
['default', null, false],
['default', 'default', false],
['default', 'new', true],
];
}
/**
* Check if shouldBeSaved works as expected
*
* @dataProvider dataShouldBeSaved
* @param mixed $default The default value
* @param mixed $local The current local value
* @param bool $expect The expected outcome
*/
public function testShouldBeSaved($default, $local, $expect) {
/** @var Setting $setting */
$setting = new $this->class('test');
$setting->initialize($default, $local, null);
$this->assertSame($expect, $setting->shouldBeSaved());
}
}