Adding upstream version 20241201.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
5f5109ce41
commit
f8d74cc725
216 changed files with 7490 additions and 0 deletions
86
plugins/55/wrap/_test/GeneralTest.php
Normal file
86
plugins/55/wrap/_test/GeneralTest.php
Normal file
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
|
||||
namespace dokuwiki\plugin\wrap\test;
|
||||
|
||||
use DokuWikiTest;
|
||||
|
||||
/**
|
||||
* General tests for the wrap plugin
|
||||
*
|
||||
* @group plugin_wrap
|
||||
* @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('wrap', $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']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test to ensure that every conf['...'] entry in conf/default.php has a corresponding meta['...'] entry in
|
||||
* conf/metadata.php.
|
||||
*/
|
||||
public function testPluginConf(): void
|
||||
{
|
||||
$conf_file = __DIR__ . '/../conf/default.php';
|
||||
$meta_file = __DIR__ . '/../conf/metadata.php';
|
||||
|
||||
if (!file_exists($conf_file) && !file_exists($meta_file)) {
|
||||
self::markTestSkipped('No config files exist -> skipping test');
|
||||
}
|
||||
|
||||
if (file_exists($conf_file)) {
|
||||
include($conf_file);
|
||||
}
|
||||
if (file_exists($meta_file)) {
|
||||
include($meta_file);
|
||||
}
|
||||
|
||||
$this->assertEquals(
|
||||
gettype($conf),
|
||||
gettype($meta),
|
||||
'Both ' . DOKU_PLUGIN . 'wrap/conf/default.php and ' . DOKU_PLUGIN . 'wrap/conf/metadata.php have to exist and contain the same keys.'
|
||||
);
|
||||
|
||||
if ($conf !== null && $meta !== null) {
|
||||
foreach ($conf as $key => $value) {
|
||||
$this->assertArrayHasKey(
|
||||
$key,
|
||||
$meta,
|
||||
'Key $meta[\'' . $key . '\'] missing in ' . DOKU_PLUGIN . 'wrap/conf/metadata.php'
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($meta as $key => $value) {
|
||||
$this->assertArrayHasKey(
|
||||
$key,
|
||||
$conf,
|
||||
'Key $conf[\'' . $key . '\'] missing in ' . DOKU_PLUGIN . 'wrap/conf/default.php'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
246
plugins/55/wrap/_test/SyntaxTest.php
Normal file
246
plugins/55/wrap/_test/SyntaxTest.php
Normal file
|
@ -0,0 +1,246 @@
|
|||
<?php
|
||||
|
||||
namespace dokuwiki\plugin\wrap\test;
|
||||
|
||||
use DokuWikiTest;
|
||||
|
||||
/**
|
||||
* Tests to ensure wrap syntax is correctly processed
|
||||
*
|
||||
* @group plugin_wrap
|
||||
* @group plugins
|
||||
*/
|
||||
class SyntaxTest extends DokuWikiTest {
|
||||
|
||||
protected $pluginsEnabled = ['wrap'];
|
||||
|
||||
public function testNestedHeading() {
|
||||
$instructions = p_get_instructions("<WRAP>\n==== Heading ====\n\nSome text\n</WRAP>");
|
||||
$expected =
|
||||
[
|
||||
[
|
||||
'document_start',
|
||||
[],
|
||||
0
|
||||
],
|
||||
[
|
||||
'plugin',
|
||||
[
|
||||
'wrap_divwrap',
|
||||
[
|
||||
DOKU_LEXER_ENTER,
|
||||
'<wrap'
|
||||
],
|
||||
DOKU_LEXER_ENTER,
|
||||
'<WRAP>'
|
||||
],
|
||||
1
|
||||
],
|
||||
[
|
||||
'header',
|
||||
[
|
||||
'Heading',
|
||||
3,
|
||||
8
|
||||
],
|
||||
8
|
||||
],
|
||||
[
|
||||
'plugin',
|
||||
[
|
||||
'wrap_closesection',
|
||||
[],
|
||||
DOKU_LEXER_SPECIAL,
|
||||
false
|
||||
],
|
||||
8
|
||||
],
|
||||
[
|
||||
'p_open',
|
||||
[],
|
||||
8
|
||||
],
|
||||
[
|
||||
'cdata',
|
||||
[
|
||||
'Some text'
|
||||
],
|
||||
27
|
||||
],
|
||||
[
|
||||
'p_close',
|
||||
[],
|
||||
37
|
||||
],
|
||||
[
|
||||
'plugin',
|
||||
[
|
||||
'wrap_divwrap',
|
||||
[
|
||||
DOKU_LEXER_EXIT,
|
||||
''
|
||||
],
|
||||
DOKU_LEXER_EXIT,
|
||||
'</WRAP>'
|
||||
],
|
||||
37
|
||||
],
|
||||
[
|
||||
'document_end',
|
||||
[],
|
||||
37
|
||||
]
|
||||
];
|
||||
$this->assertEquals($expected, $instructions);
|
||||
}
|
||||
|
||||
public function testBlockNesting() {
|
||||
$instructions = p_get_instructions("<WRAP>\nFoo\n\n</div> </block> Bar\n</WRAP>");
|
||||
$expected =
|
||||
[
|
||||
[
|
||||
'document_start',
|
||||
[],
|
||||
0
|
||||
],
|
||||
[
|
||||
'plugin',
|
||||
[
|
||||
'wrap_divwrap',
|
||||
[
|
||||
DOKU_LEXER_ENTER,
|
||||
'<wrap'
|
||||
],
|
||||
DOKU_LEXER_ENTER,
|
||||
'<WRAP>'
|
||||
],
|
||||
1
|
||||
],
|
||||
[
|
||||
'p_open',
|
||||
[
|
||||
],
|
||||
1
|
||||
],
|
||||
[
|
||||
'cdata',
|
||||
[
|
||||
'Foo'
|
||||
],
|
||||
8
|
||||
],
|
||||
[
|
||||
'p_close',
|
||||
[],
|
||||
11
|
||||
],
|
||||
[
|
||||
'p_open',
|
||||
[
|
||||
],
|
||||
11
|
||||
],
|
||||
[
|
||||
'cdata',
|
||||
[
|
||||
'</div> </block> Bar'
|
||||
],
|
||||
13
|
||||
],
|
||||
[
|
||||
'p_close',
|
||||
[],
|
||||
33
|
||||
],
|
||||
[
|
||||
'plugin',
|
||||
[
|
||||
'wrap_divwrap',
|
||||
[
|
||||
DOKU_LEXER_EXIT,
|
||||
''
|
||||
],
|
||||
DOKU_LEXER_EXIT,
|
||||
'</WRAP>'
|
||||
],
|
||||
33
|
||||
],
|
||||
[
|
||||
'document_end',
|
||||
[],
|
||||
33
|
||||
]
|
||||
];
|
||||
$this->assertEquals($expected, $instructions);
|
||||
}
|
||||
|
||||
public function testInlineNesting() {
|
||||
$instructions = p_get_instructions("<wrap>Foo </span> </inline> Bar</wrap>");
|
||||
$expected =
|
||||
[
|
||||
[
|
||||
'document_start',
|
||||
[],
|
||||
0
|
||||
],
|
||||
[
|
||||
'p_open',
|
||||
[
|
||||
],
|
||||
0
|
||||
],
|
||||
[
|
||||
'plugin',
|
||||
[
|
||||
'wrap_spanwrap',
|
||||
[
|
||||
DOKU_LEXER_ENTER,
|
||||
'<wrap'
|
||||
],
|
||||
DOKU_LEXER_ENTER,
|
||||
'<wrap>'
|
||||
],
|
||||
1
|
||||
],
|
||||
[
|
||||
'cdata',
|
||||
[
|
||||
'Foo </span> </inline> Bar'
|
||||
],
|
||||
7
|
||||
],
|
||||
[
|
||||
'plugin',
|
||||
[
|
||||
'wrap_spanwrap',
|
||||
[
|
||||
DOKU_LEXER_EXIT,
|
||||
''
|
||||
],
|
||||
DOKU_LEXER_EXIT,
|
||||
'</wrap>'
|
||||
],
|
||||
32
|
||||
],
|
||||
[
|
||||
'cdata',
|
||||
[
|
||||
''
|
||||
],
|
||||
39
|
||||
],
|
||||
[
|
||||
'p_close',
|
||||
[],
|
||||
39
|
||||
],
|
||||
[
|
||||
'document_end',
|
||||
[],
|
||||
39
|
||||
]
|
||||
];
|
||||
$this->assertEquals($expected, $instructions);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue