Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add working tests to master #72

Merged
merged 42 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
029eed3
minor readme update
lastlink Jul 19, 2024
fb7d160
Merge pull request #68 from funktechno/f/readme_updates
lastlink Jul 19, 2024
a50a71a
update todo
lastlink Jul 19, 2024
2f8030e
Merge pull request #69 from funktechno/f/readme_updates
lastlink Jul 19, 2024
ad11d92
test pipeline
lastlink Jul 19, 2024
0ad27d2
Merge branch 'dev' of github.com:funktechno/kanboard-plugin-wiki into…
lastlink Jul 19, 2024
fa47f91
another attempt
lastlink Jul 19, 2024
03f364a
fix step order
lastlink Jul 19, 2024
6d11e75
install phpenv
lastlink Jul 19, 2024
efbd886
another attempt
lastlink Jul 19, 2024
38afc5e
php env init
lastlink Jul 19, 2024
3cf4b34
try 5
lastlink Jul 19, 2024
a3f6c84
again
lastlink Jul 19, 2024
60aa7ea
again
lastlink Jul 19, 2024
efccb07
again
lastlink Jul 19, 2024
27d77b5
again
lastlink Jul 19, 2024
695206f
again
lastlink Jul 19, 2024
215ead8
try 6
lastlink Jul 19, 2024
c2d0dcb
rm src
lastlink Jul 19, 2024
dcf4fcf
try 7
lastlink Jul 19, 2024
a984e3b
try 7
lastlink Jul 19, 2024
e8be557
try 8
lastlink Jul 19, 2024
60e9ce1
try 9
lastlink Jul 19, 2024
15d628e
rm config add
lastlink Jul 19, 2024
2af39b7
try 10
lastlink Jul 19, 2024
db5dac1
update test
lastlink Jul 19, 2024
3927044
update test
lastlink Jul 19, 2024
37996f9
Merge pull request #70 from funktechno/f/tests
lastlink Jul 19, 2024
e5bb7db
update test
lastlink Jul 19, 2024
6607468
create project
lastlink Jul 19, 2024
000e967
add use
lastlink Jul 19, 2024
3eef382
update test
lastlink Jul 19, 2024
e326137
fix syntax
lastlink Jul 19, 2024
aecdd53
add use session to test
lastlink Jul 19, 2024
6aa0fc8
try 1
lastlink Jul 19, 2024
c90750b
tweak
lastlink Jul 19, 2024
129b444
error log test
lastlink Jul 19, 2024
39f859b
test without assert
lastlink Jul 19, 2024
f611f17
cleanup test
lastlink Jul 19, 2024
b82167f
Merge branch 'dev' into f/tests
lastlink Jul 19, 2024
5a17172
Merge pull request #71 from funktechno/f/tests
lastlink Jul 19, 2024
f48202a
Merge branch 'master' into dev
lastlink Jul 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: 'Unit Tests'
on:
workflow_dispatch:
push:
branches:
- master
pull_request:
jobs:
Sqlite:
runs-on: ubuntu-latest
container: kanboard/tests:latest
steps:
- name: Checkout Kanboard repo
uses: actions/checkout@v2
with:
repository: kanboard/kanboard
- name: Checkout Plugin repo
uses: actions/checkout@v2
with:
path: plugins/Wiki
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest
- name: Unit tests with Sqlite
run: ./vendor/bin/phpunit -c tests/units.sqlite.xml plugins/Wiki/Test/

Postgres:
runs-on: ubuntu-latest
container: kanboard/tests:latest
services:
postgres:
image: postgres:9.4
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout Kanboard repo
uses: actions/checkout@v2
with:
repository: kanboard/kanboard
- name: Checkout Plugin repo
uses: actions/checkout@v2
with:
path: plugins/Wiki
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest
- name: Unit tests with Postgres
run: ./vendor/bin/phpunit -c tests/units.postgres.xml plugins/Wiki/Test/
env:
DB_HOSTNAME: postgres
DB_PORT: ${{ job.services.postgres.ports[5432] }}

MariaDB:
runs-on: ubuntu-latest
container: kanboard/tests:latest
services:
mariadb:
image: mariadb:latest
env:
MYSQL_ROOT_PASSWORD: secret
ports:
- 3306:3306
steps:
- name: Checkout Kanboard repo
uses: actions/checkout@v2
with:
repository: kanboard/kanboard
- name: Checkout Plugin repo
uses: actions/checkout@v2
with:
path: plugins/Wiki
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest
- name: Unit tests with MariaDB
run: ./vendor/bin/phpunit -c tests/units.mysql.xml plugins/Wiki/Test/
env:
DB_HOSTNAME: mariadb
DB_PASSWORD: secret
DB_PORT: ${{ job.services.mariadb.ports[3306] }}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Note that you can only restore **saved** editions. So you if you have the global
- [] ordering
- [] drop down to switch
- [] drag to move, require css magic
- [] subpages and pagination
- [x] fix wiki sidebar
- use html template render properly to list wiki pages
- still having difficulty getting template helper working, manually added for each page
Expand Down Expand Up @@ -112,6 +113,7 @@ version=0.2.6
```

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.
* windows install make `choco install make`

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.

Expand Down
75 changes: 39 additions & 36 deletions Test/Model/WikiPageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,65 +4,68 @@

use Kanboard\Core\Plugin\Loader;
use Kanboard\Plugin\Wiki\Model\Wiki;
use Kanboard\Model\ProjectModel;
use Kanboard\Core\User\UserSession;
use Kanboard\Core\Security\AuthenticationManager;
use Kanboard\Auth\DatabaseAuth;

class WikiPageTest extends Base
{
public function setUp()
/**
* @var Plugin
*/
protected $plugin;

protected function setUp(): void
{
parent::setUp();
// $this->plugin = new Plugin($this->container);

$plugin = new Loader($this->container);
$plugin->scan();
}

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


// $editions = $wikimodel->getEditions(1);
// $this->assertEmpty($editions);
$projectModel = new ProjectModel($this->container);

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

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

// createpage

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

// $editions = $wikimodel->getEditions(1);
// $this->assertNotEmpty($editions);
// $rates = $hr->getAllByUser(1);
// $this->assertNotEmpty($rates);
// $this->assertCount(1, $editions);
// grab editions for first wiki page
$editions = $wikimodel->getEditions(1);
$this->assertEmpty($editions);

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

// $this->assertEquals('2015-02-01', date('Y-m-d', $rates[0]['date_effective']));
// create wiki page edition

$authManager = new AuthenticationManager($this->container);
$authManager->register(new DatabaseAuth($this->container));

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

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

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

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

// $rates = $hr->getAllByUser(1);
// $this->assertEmpty($rates);
$this->assertEquals('Security', $editions[0]['title']);
$this->assertEquals('Some content', $editions[0]['content']);
}
}
Loading