Skip to content

Commit 3b5e004

Browse files
committed
Add default GitHub workflow
1 parent c6d79ae commit 3b5e004

File tree

2 files changed

+97
-0
lines changed

2 files changed

+97
-0
lines changed

.github/workflows/dokuwiki.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: DokuWiki Default Tasks
2+
on:
3+
push:
4+
pull_request:
5+
schedule:
6+
- cron: '54 0 2 * *'
7+
8+
9+
jobs:
10+
all:
11+
uses: dokuwiki/github-action/.github/workflows/all.yml@main

_test/GeneralTest.php

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?php
2+
3+
namespace dokuwiki\plugin\pluginrepo\test;
4+
5+
use DokuWikiTest;
6+
7+
/**
8+
* General tests for the pluginrepo plugin
9+
*
10+
* @group plugin_pluginrepo
11+
* @group plugins
12+
*/
13+
class GeneralTest extends DokuWikiTest
14+
{
15+
16+
/**
17+
* Simple test to make sure the plugin.info.txt is in correct format
18+
*/
19+
public function testPluginInfo(): void
20+
{
21+
$file = __DIR__ . '/../plugin.info.txt';
22+
$this->assertFileExists($file);
23+
24+
$info = confToHash($file);
25+
26+
$this->assertArrayHasKey('base', $info);
27+
$this->assertArrayHasKey('author', $info);
28+
$this->assertArrayHasKey('email', $info);
29+
$this->assertArrayHasKey('date', $info);
30+
$this->assertArrayHasKey('name', $info);
31+
$this->assertArrayHasKey('desc', $info);
32+
$this->assertArrayHasKey('url', $info);
33+
34+
$this->assertEquals('pluginrepo', $info['base']);
35+
$this->assertRegExp('/^https?:\/\//', $info['url']);
36+
$this->assertTrue(mail_isvalid($info['email']));
37+
$this->assertRegExp('/^\d\d\d\d-\d\d-\d\d$/', $info['date']);
38+
$this->assertTrue(false !== strtotime($info['date']));
39+
}
40+
41+
/**
42+
* Test to ensure that every conf['...'] entry in conf/default.php has a corresponding meta['...'] entry in
43+
* conf/metadata.php.
44+
*/
45+
public function testPluginConf(): void
46+
{
47+
$conf_file = __DIR__ . '/../conf/default.php';
48+
$meta_file = __DIR__ . '/../conf/metadata.php';
49+
50+
if (!file_exists($conf_file) && !file_exists($meta_file)) {
51+
self::markTestSkipped('No config files exist -> skipping test');
52+
}
53+
54+
if (file_exists($conf_file)) {
55+
include($conf_file);
56+
}
57+
if (file_exists($meta_file)) {
58+
include($meta_file);
59+
}
60+
61+
$this->assertEquals(
62+
gettype($conf),
63+
gettype($meta),
64+
'Both ' . DOKU_PLUGIN . 'pluginrepo/conf/default.php and ' . DOKU_PLUGIN . 'pluginrepo/conf/metadata.php have to exist and contain the same keys.'
65+
);
66+
67+
if ($conf !== null && $meta !== null) {
68+
foreach ($conf as $key => $value) {
69+
$this->assertArrayHasKey(
70+
$key,
71+
$meta,
72+
'Key $meta[\'' . $key . '\'] missing in ' . DOKU_PLUGIN . 'pluginrepo/conf/metadata.php'
73+
);
74+
}
75+
76+
foreach ($meta as $key => $value) {
77+
$this->assertArrayHasKey(
78+
$key,
79+
$conf,
80+
'Key $conf[\'' . $key . '\'] missing in ' . DOKU_PLUGIN . 'pluginrepo/conf/default.php'
81+
);
82+
}
83+
}
84+
85+
}
86+
}

0 commit comments

Comments
 (0)