Skip to content

Commit 5a17172

Browse files
authored
Merge pull request #71 from funktechno/f/tests
update test
2 parents 37996f9 + b82167f commit 5a17172

File tree

1 file changed

+32
-35
lines changed

1 file changed

+32
-35
lines changed

Test/Model/WikiPageTest.php

+32-35
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
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
{
@@ -23,52 +27,45 @@ protected function setUp(): void
2327

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

31-
// $editions = $wikimodel->getEditions(1);
32-
// $this->assertEmpty($editions);
33-
34-
// $values = [
35-
// 'title' => "Security",
36-
// 'content' => "Some content",
37-
// ];
31+
$projectModel = new ProjectModel($this->container);
3832

39-
// $this->assertEquals(1, $wikimodel->createEdition($values, 1, 1));
33+
$this->assertEquals($projectModel->create(array('name' => 'UnitTest')), 1, 'Failed to create project');
4034

41-
// createpage
35+
$project = $projectModel->getById(1);
4236

43-
// $rates = $hr->getAllByUser(0);
44-
// $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');
4541

46-
// $editions = $wikimodel->getEditions(1);
47-
// $this->assertNotEmpty($editions);
48-
// $rates = $hr->getAllByUser(1);
49-
// $this->assertNotEmpty($rates);
50-
// $this->assertCount(1, $editions);
42+
// grab editions for first wiki page
43+
$editions = $wikimodel->getEditions(1);
44+
$this->assertEmpty($editions);
5145

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

56-
// $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));
5755

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

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

65-
// $this->assertTrue($wikimodel->removepage(1));
66-
// $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');
6764

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

71-
// $rates = $hr->getAllByUser(1);
72-
// $this->assertEmpty($rates);
68+
$this->assertEquals('Security', $editions[0]['title']);
69+
$this->assertEquals('Some content', $editions[0]['content']);
7370
}
7471
}

0 commit comments

Comments
 (0)