Skip to content

Commit 8829850

Browse files
authored
Merge pull request #72 from funktechno/dev
add working tests to master
2 parents 63b3a40 + f48202a commit 8829850

File tree

3 files changed

+127
-36
lines changed

3 files changed

+127
-36
lines changed

.github/workflows/tests.yaml

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: 'Unit Tests'
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
jobs:
9+
Sqlite:
10+
runs-on: ubuntu-latest
11+
container: kanboard/tests:latest
12+
steps:
13+
- name: Checkout Kanboard repo
14+
uses: actions/checkout@v2
15+
with:
16+
repository: kanboard/kanboard
17+
- name: Checkout Plugin repo
18+
uses: actions/checkout@v2
19+
with:
20+
path: plugins/Wiki
21+
- name: Install dependencies
22+
run: composer install --prefer-dist --no-progress --no-suggest
23+
- name: Unit tests with Sqlite
24+
run: ./vendor/bin/phpunit -c tests/units.sqlite.xml plugins/Wiki/Test/
25+
26+
Postgres:
27+
runs-on: ubuntu-latest
28+
container: kanboard/tests:latest
29+
services:
30+
postgres:
31+
image: postgres:9.4
32+
env:
33+
POSTGRES_USER: postgres
34+
POSTGRES_PASSWORD: postgres
35+
POSTGRES_DB: postgres
36+
ports:
37+
- 5432:5432
38+
options: >-
39+
--health-cmd pg_isready
40+
--health-interval 10s
41+
--health-timeout 5s
42+
--health-retries 5
43+
steps:
44+
- name: Checkout Kanboard repo
45+
uses: actions/checkout@v2
46+
with:
47+
repository: kanboard/kanboard
48+
- name: Checkout Plugin repo
49+
uses: actions/checkout@v2
50+
with:
51+
path: plugins/Wiki
52+
- name: Install dependencies
53+
run: composer install --prefer-dist --no-progress --no-suggest
54+
- name: Unit tests with Postgres
55+
run: ./vendor/bin/phpunit -c tests/units.postgres.xml plugins/Wiki/Test/
56+
env:
57+
DB_HOSTNAME: postgres
58+
DB_PORT: ${{ job.services.postgres.ports[5432] }}
59+
60+
MariaDB:
61+
runs-on: ubuntu-latest
62+
container: kanboard/tests:latest
63+
services:
64+
mariadb:
65+
image: mariadb:latest
66+
env:
67+
MYSQL_ROOT_PASSWORD: secret
68+
ports:
69+
- 3306:3306
70+
steps:
71+
- name: Checkout Kanboard repo
72+
uses: actions/checkout@v2
73+
with:
74+
repository: kanboard/kanboard
75+
- name: Checkout Plugin repo
76+
uses: actions/checkout@v2
77+
with:
78+
path: plugins/Wiki
79+
- name: Install dependencies
80+
run: composer install --prefer-dist --no-progress --no-suggest
81+
- name: Unit tests with MariaDB
82+
run: ./vendor/bin/phpunit -c tests/units.mysql.xml plugins/Wiki/Test/
83+
env:
84+
DB_HOSTNAME: mariadb
85+
DB_PASSWORD: secret
86+
DB_PORT: ${{ job.services.mariadb.ports[3306] }}

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ Note that you can only restore **saved** editions. So you if you have the global
7373
- [] ordering
7474
- [] drop down to switch
7575
- [] drag to move, require css magic
76+
- [] subpages and pagination
7677
- [x] fix wiki sidebar
7778
- use html template render properly to list wiki pages
7879
- still having difficulty getting template helper working, manually added for each page
@@ -112,6 +113,7 @@ version=0.2.6
112113
```
113114

114115
To run a new build type `make`. NOTE: this only zips files in the last commit in the branch you are on. If you haven't commited your changes these won't be included in the zip.
116+
* windows install make `choco install make`
115117

116118
After testing create a new tag in github or via cli. `git tag -a 0.2.6 -m "Translations Updates"`. Then `git push origin --tags` Then upload the new **Wiki-version.zip** produced from `make`. Then do a pull request on https://github.com/kanboard/website for the plugins.json to update the plugin url. The `version` & `download` attributes are important to be correct.
117119

Test/Model/WikiPageTest.php

+39-36
Original file line numberDiff line numberDiff line change
@@ -4,65 +4,68 @@
44

55
use Kanboard\Core\Plugin\Loader;
66
use Kanboard\Plugin\Wiki\Model\Wiki;
7+
use Kanboard\Model\ProjectModel;
8+
use Kanboard\Core\User\UserSession;
9+
use Kanboard\Core\Security\AuthenticationManager;
10+
use Kanboard\Auth\DatabaseAuth;
711

812
class WikiPageTest extends Base
913
{
10-
public function setUp()
14+
/**
15+
* @var Plugin
16+
*/
17+
protected $plugin;
18+
19+
protected function setUp(): void
1120
{
1221
parent::setUp();
22+
// $this->plugin = new Plugin($this->container);
1323

1424
$plugin = new Loader($this->container);
1525
$plugin->scan();
1626
}
1727

1828
public function testCreation()
1929
{
20-
$wikimodel = new Wiki($this->container);
21-
// $this->assertEquals(1, $wikimodel->createpage(1, "Security", "Some content", '2015-01-01'));
22-
// $this->assertEquals(2, $wikimodel->createpage(1, "Conventions", 'More content'));
23-
2430

25-
// $editions = $wikimodel->getEditions(1);
26-
// $this->assertEmpty($editions);
31+
$projectModel = new ProjectModel($this->container);
2732

28-
// $values = [
29-
// 'title' => "Security",
30-
// 'content' => "Some content",
31-
// ];
33+
$this->assertEquals($projectModel->create(array('name' => 'UnitTest')), 1, 'Failed to create project');
3234

33-
// $this->assertEquals(1, $wikimodel->createEdition($values, 1, 1));
35+
$project = $projectModel->getById(1);
3436

35-
// createpage
36-
37-
// $rates = $hr->getAllByUser(0);
38-
// $this->assertEmpty($rates);
37+
$wikimodel = new Wiki($this->container);
38+
// create wiki pages
39+
$this->assertEquals($wikimodel->createpage($project['id'], "Security", "Some content", '2015-01-01'), 1, 'Failed to a create wiki page on project');
40+
$this->assertEquals($wikimodel->createpage($project['id'], "Conventions", 'More content'), 2, 'Failed to an additional create wiki page on project');
3941

40-
// $editions = $wikimodel->getEditions(1);
41-
// $this->assertNotEmpty($editions);
42-
// $rates = $hr->getAllByUser(1);
43-
// $this->assertNotEmpty($rates);
44-
// $this->assertCount(1, $editions);
42+
// grab editions for first wiki page
43+
$editions = $wikimodel->getEditions(1);
44+
$this->assertEmpty($editions);
4545

46-
// $this->assertEquals(42, $rates[0]['rate']);
47-
// $this->assertEquals('Security', $editions[0]['title']);
48-
// $this->assertEquals('Some content', $editions[0]['content']);
46+
$values = [
47+
'title' => "Security",
48+
'content' => "Some content",
49+
];
4950

50-
// $this->assertEquals('2015-02-01', date('Y-m-d', $rates[0]['date_effective']));
51+
// create wiki page edition
52+
53+
$authManager = new AuthenticationManager($this->container);
54+
$authManager->register(new DatabaseAuth($this->container));
5155

52-
// $this->assertEquals(32.4, $rates[1]['rate']);
53-
// $this->assertEquals('EUR', $rates[1]['currency']);
54-
// $this->assertEquals('2015-01-01', date('Y-m-d', $rates[1]['date_effective']));
56+
$_SESSION['user'] = array('id' => 1, 'username' => 'test', 'role' => 'app-admin');
5557

56-
// $this->assertEquals(0, $hr->getCurrentRate(0));
57-
// $this->assertEquals(42, $hr->getCurrentRate(1));
58+
$this->assertTrue($this->container['userSession']->isLogged(), 'Failed to login');
5859

59-
// $this->assertTrue($wikimodel->removepage(1));
60-
// $this->assertEquals(32.4, $hr->getCurrentRate(1));
60+
$this->userSession = new UserSession($this->container);
61+
// result is not a consistent 1. is this true or id for new edition?
62+
$createEditionResult = $wikimodel->createEdition($values, 1, 1);
63+
// $this->assertEquals($wikimodel->createEdition($values, 1, 1), 1, 'Failed to create wiki edition');
6164

62-
// $this->assertTrue($hr->remove(1));
63-
// $this->assertEquals(0, $hr->getCurrentRate(1));
65+
$editions = $wikimodel->getEditions(1);
66+
$this->assertNotEmpty($editions, 'Failed to get wiki editions');
6467

65-
// $rates = $hr->getAllByUser(1);
66-
// $this->assertEmpty($rates);
68+
$this->assertEquals('Security', $editions[0]['title']);
69+
$this->assertEquals('Some content', $editions[0]['content']);
6770
}
6871
}

0 commit comments

Comments
 (0)