4
4
5
5
use Kanboard \Core \Plugin \Loader ;
6
6
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 ;
7
11
8
12
class WikiPageTest extends Base
9
13
{
@@ -23,52 +27,45 @@ protected function setUp(): void
23
27
24
28
public function testCreation ()
25
29
{
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
-
30
30
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 );
38
32
39
- // $this->assertEquals(1, $wikimodel->createEdition($values , 1, 1) );
33
+ $ this ->assertEquals ($ projectModel -> create ( array ( ' name ' => ' UnitTest ' )) , 1 , ' Failed to create project ' );
40
34
41
- // createpage
35
+ $ project = $ projectModel -> getById ( 1 );
42
36
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 ' );
45
41
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 );
51
45
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
+ ];
55
50
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 ));
57
55
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 ' );
61
57
62
- // $this->assertEquals(0, $hr->getCurrentRate(0));
63
- // $this->assertEquals(42, $hr->getCurrentRate(1));
58
+ $ this ->assertTrue ($ this ->container ['userSession ' ]->isLogged (), 'Failed to login ' );
64
59
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');
67
64
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 ' );
70
67
71
- // $rates = $hr->getAllByUser(1 );
72
- // $this->assertEmpty($rates );
68
+ $ this -> assertEquals ( ' Security ' , $ editions [ 0 ][ ' title ' ] );
69
+ $ this ->assertEquals ( ' Some content ' , $ editions [ 0 ][ ' content ' ] );
73
70
}
74
71
}
0 commit comments