Skip to content

Commit c305c06

Browse files
authored
Merge pull request #95 from mhoffrog/feature/migrate_to_dw_codestyle_and_unit_testing
Migrate code to meet DokuWiki standard code style and Unit Testing
2 parents 740d45a + 4685940 commit c305c06

File tree

18 files changed

+1610
-1213
lines changed

18 files changed

+1610
-1213
lines changed

.editorconfig

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
; http://editorconfig.org/
2+
3+
root = true
4+
5+
[*]
6+
indent_style = space
7+
indent_size = 4
8+
end_of_line = lf
9+
charset = utf-8
10+
trim_trailing_whitespace = true
11+
insert_final_newline = true
12+
13+
[*.{yml,yaml}]
14+
indent_size = 2
15+
16+
[{vendor,inc/phpseclib}/**]
17+
; Use editor default (possible autodetection).
18+
indent_style =
19+
indent_size =
20+
end_of_line =
21+
trim_trailing_whitespace =
22+
insert_final_newline =

.github/workflows/build_release.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
name: Build a release
1515

1616
on:
17-
# Triggers the workflow on push of a tag filtering the tag to meet
17+
# Triggers the workflow on push of a tag filtering the tag to meet
1818
# semantic version numbering according to https://semver.org
1919
# Here we use the DokuWiki conform version number pattern.
2020
push:
@@ -48,8 +48,8 @@ jobs:
4848
APP_INFO_FILE: plugin.info.txt
4949
APP_INFO_FILE_VERSION_KEY: date
5050
BUILD_DIR: build
51-
ZIP_EXCLUSIONS: '*.git* .editorconfig /*.github/* /*build/* RELEASE_HEAD.md'
52-
51+
ZIP_EXCLUSIONS: '*.git* .editorconfig /*.github/* /*.vscode/* /*build/* /*_test/* RELEASE_HEAD.md'
52+
5353
steps:
5454
# Log use case if triggered manually
5555
- name: Log use case if triggered manually
@@ -170,7 +170,7 @@ jobs:
170170
with:
171171
version: ${{ env.RELEASE_VERSION }}
172172
working-directory: ${{ env.BUILD_DIR }}
173-
173+
174174
- name: Log RELEASE.md
175175
run: |
176176
echo ">>>>> build/RELEASE.md:"
@@ -193,4 +193,4 @@ jobs:
193193
artifactContentType: application/zip
194194
#
195195
# EOF
196-
#
196+
#

.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

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
manager.dat

.vscode/settings.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"editor.formatOnPaste": true,
3+
"git.autofetch": true,
4+
"[php]": {
5+
"editor.detectIndentation": false,
6+
"editor.defaultFormatter": "bmewburn.vscode-intelephense-client",
7+
"editor.formatOnSave": true,
8+
"editor.insertSpaces": true,
9+
"editor.tabSize": 4,
10+
//"prettier.tabWidth": 4,
11+
//"prettier.useTabs": false
12+
"editor.wordWrap": "wordWrapColumn",
13+
"editor.wordWrapColumn": 120,
14+
"editor.rulers": [120]
15+
},
16+
"[markdown]": {
17+
"editor.wordWrap": "on"
18+
},
19+
"[json]": {
20+
"editor.defaultFormatter": "esbenp.prettier-vscode"
21+
},
22+
"[jsonc]": {
23+
"editor.defaultFormatter": "esbenp.prettier-vscode"
24+
},
25+
"[html]": {
26+
"editor.defaultFormatter": "esbenp.prettier-vscode"
27+
},
28+
"[javascript]": {
29+
"editor.detectIndentation": false,
30+
"editor.defaultFormatter": "esbenp.prettier-vscode",
31+
//"editor.insertSpaces": true,
32+
//"editor.tabSize": 4,
33+
//"prettier.tabWidth": 4,
34+
//"prettier.useTabs": false
35+
},
36+
"[typescript]": {
37+
"editor.defaultFormatter": "esbenp.prettier-vscode"
38+
//"prettier.tabWidth": 4,
39+
//"prettier.useTabs": true
40+
},
41+
}

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)