Skip to content

Commit 4685940

Browse files
committed
#71: Add initial DW standard Unit Test for this plugin
- .github/workflows/dokuwiki.yml: - add DW standard action for code style checks and generic Unit Test execution - _test/GeneralTest.php: - initial test for general DW plugin configurations - update CHANGELOG.md
1 parent 2762023 commit 4685940

File tree

3 files changed

+112
-2
lines changed

3 files changed

+112
-2
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: '22 21 12 * *'
7+
8+
9+
jobs:
10+
all:
11+
uses: dokuwiki/github-action/.github/workflows/all.yml@main

CHANGELOG.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
3030
These links provide direct access to the GitHub compare vs. the previous release.
3131
The particular link of a released version will be copied to the release notes of a release accordingly.
3232
At the end of this file appropriate compare links have to be maintained for each release version in format:
33-
33+
3434
+-current release version
3535
|
3636
| +-URL to this repo previous release version tag-+ +-current release version tag
@@ -65,6 +65,19 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
6565
- TBD
6666

6767

68+
## [2025-03-03]
69+
70+
### Added
71+
- Add code style config files
72+
- Add code style check
73+
- Add auto loader `loader.php`
74+
75+
### Fixed
76+
- Replace references to deprecated classes by non deprecated classes
77+
- Update code to meet DokuWiki standard code style
78+
- Make use of plugin specific namespace for `classes/*.php` classes
79+
80+
6881
## [2025-02-26]
6982

7083
### Added
@@ -173,7 +186,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
173186
- This is just a dummy placeholder to make the parser of GHCICD/release-notes-from-changelog@v1 happy!
174187
-->
175188

176-
[Unreleased]: https://github.com/woolfg/dokuwiki-plugin-gitbacked/compare/v2025-02-26..HEAD
189+
[Unreleased]: https://github.com/woolfg/dokuwiki-plugin-gitbacked/compare/v2025-03-01..HEAD
190+
[2025-03-01]: https://github.com/woolfg/dokuwiki-plugin-gitbacked/compare/v2025-02-26..v2025-03-01
177191
[2025-02-26]: https://github.com/woolfg/dokuwiki-plugin-gitbacked/compare/v2023-05-07..v2025-02-26
178192
[2023-05-07]: https://github.com/woolfg/dokuwiki-plugin-gitbacked/compare/v2023-03-07..v2023-05-07
179193
[2023-03-07]: https://github.com/woolfg/dokuwiki-plugin-gitbacked/compare/v2022-02-06..v2023-03-07

_test/GeneralTest.php

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?php
2+
3+
namespace dokuwiki\plugin\gitbacked\test;
4+
5+
use DokuWikiTest;
6+
7+
/**
8+
* General tests for the gitbacked plugin
9+
*
10+
* @group plugin_gitbacked
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('gitbacked', $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 . 'gitbacked/conf/default.php and ' . DOKU_PLUGIN . 'gitbacked/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 . 'gitbacked/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 . 'gitbacked/conf/default.php'
81+
);
82+
}
83+
}
84+
}
85+
}

0 commit comments

Comments
 (0)