@@ -23,11 +23,15 @@ protected function setUp(): void
23
23
24
24
$ plugin = new Loader ($ this ->container );
25
25
$ plugin ->scan ();
26
+
27
+ $ authManager = new AuthenticationManager ($ this ->container );
28
+ $ authManager ->register (new DatabaseAuth ($ this ->container ));
29
+
30
+ $ _SESSION ['user ' ] = array ('id ' => 1 , 'username ' => 'test ' , 'role ' => 'app-admin ' );
26
31
}
27
32
28
33
public function testCreation ()
29
34
{
30
-
31
35
$ projectModel = new ProjectModel ($ this ->container );
32
36
33
37
$ this ->assertEquals ($ projectModel ->create (array ('name ' => 'UnitTest ' )), 1 , 'Failed to create project ' );
@@ -36,8 +40,8 @@ public function testCreation()
36
40
37
41
$ wikimodel = new Wiki ($ this ->container );
38
42
// 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 ' );
43
+ $ this ->assertEquals (1 , $ wikimodel ->createpage ($ project ['id ' ], "Security " , "Some content " , '2015-01-01 ' ), 'Failed to a create wiki page on project ' );
44
+ $ this ->assertEquals (2 , $ wikimodel ->createpage ($ project ['id ' ], "Conventions " , 'More content ' ), 'Failed to an additional create wiki page on project ' );
41
45
42
46
// grab editions for first wiki page
43
47
$ editions = $ wikimodel ->getEditions (1 );
@@ -49,12 +53,6 @@ public function testCreation()
49
53
];
50
54
51
55
// create wiki page edition
52
-
53
- $ authManager = new AuthenticationManager ($ this ->container );
54
- $ authManager ->register (new DatabaseAuth ($ this ->container ));
55
-
56
- $ _SESSION ['user ' ] = array ('id ' => 1 , 'username ' => 'test ' , 'role ' => 'app-admin ' );
57
-
58
56
$ this ->assertTrue ($ this ->container ['userSession ' ]->isLogged (), 'Failed to login ' );
59
57
60
58
$ this ->userSession = new UserSession ($ this ->container );
@@ -68,4 +66,34 @@ public function testCreation()
68
66
$ this ->assertEquals ('Security ' , $ editions [0 ]['title ' ]);
69
67
$ this ->assertEquals ('Some content ' , $ editions [0 ]['content ' ]);
70
68
}
69
+
70
+ public function testReOrder (){
71
+
72
+ $ projectModel = new ProjectModel ($ this ->container );
73
+
74
+ $ this ->assertEquals ($ projectModel ->create (array ('name ' => 'reorder ' )), 1 , 'Failed to create project ' );
75
+
76
+ $ project = $ projectModel ->getById (1 );
77
+
78
+ $ wikimodel = new Wiki ($ this ->container );
79
+
80
+ // create wiki pages
81
+ $ this ->assertEquals (1 , $ wikimodel ->createpage ($ project ['id ' ], "Home " , "" , '2015-01-01 ' ), 1 , 'Failed to a create wiki page home on project ' );
82
+ $ this ->assertEquals (2 , $ wikimodel ->createpage ($ project ['id ' ], "Page 2 " , "" ), 'Failed to a create wiki page 2 on project ' );
83
+ $ this ->assertEquals (3 , $ wikimodel ->createpage ($ project ['id ' ], "Page 3 " , "" ), 'Failed to a create wiki page 3 on project ' );
84
+ $ this ->assertEquals (4 , $ wikimodel ->createpage ($ project ['id ' ], "Page 4 " , "" ), 'Failed to a create wiki page 4 on project ' );
85
+ $ this ->assertEquals (5 , $ wikimodel ->createpage ($ project ['id ' ], "Page 5 " , "" ), 'Failed to a create wiki page 5 on project ' );
86
+
87
+ // reorder
88
+ $ wikimodel ->reorderPages ($ project ['id ' ], 5 , 3 );
89
+ // expected by id
90
+ $ expectedColumnOrders = [1 ,2 ,4 ,5 ,3 ];
91
+
92
+ $ wikiPages = $ wikimodel ->getWikipages ($ project ['id ' ]);
93
+ $ this ->assertEquals (count ($ expectedColumnOrders ), count ($ wikiPages ), 'expected column order count doesn \'t match pages ' );
94
+
95
+ for ($ i =0 ; $ i < count ($ expectedColumnOrders ); $ i ++) {
96
+ $ this ->assertEquals ($ expectedColumnOrders [$ wikiPages [$ i ]['id ' ]-1 ], $ wikiPages [$ i ]['ordercolumn ' ], 'Failed to reorder page id: ' . $ wikiPages [$ i ]['id ' ]);
97
+ }
98
+ }
71
99
}
0 commit comments