@@ -100,7 +100,7 @@ public function testCommunityList()
100
100
$ this ->resetAll ();
101
101
$ this ->params ['token ' ] = $ this ->_loginUsingApiKey ();
102
102
$ this ->params ['method ' ] = 'midas.community.list ' ;
103
-
103
+
104
104
$ this ->request ->setMethod ('POST ' );
105
105
$ resp = $ this ->_callJsonApi ();
106
106
$ this ->_assertStatusOk ($ resp );
@@ -115,4 +115,73 @@ public function testCommunityList()
115
115
116
116
//TODO test that a private community is not returned (requires another community in the data set)
117
117
}
118
+
119
+ /** Test listing of child folders */
120
+ public function testFolderChildren ()
121
+ {
122
+ $ this ->resetAll ();
123
+ $ token = $ this ->_loginUsingApiKey ();
124
+ $ this ->params ['token ' ] = $ token ;
125
+ $ this ->params ['method ' ] = 'midas.folder.children ' ;
126
+ $ this ->params ['id ' ] = 1000 ;
127
+ $ this ->request ->setMethod ('POST ' );
128
+ $ resp = $ this ->_callJsonApi ();
129
+ $ this ->_assertStatusOk ($ resp );
130
+
131
+ // Should contain 2 folders and 0 items
132
+ $ this ->assertEquals (count ($ resp ->data ->folders ), 2 );
133
+ $ this ->assertEquals (count ($ resp ->data ->items ), 0 );
134
+
135
+ $ this ->assertEquals ($ resp ->data ->folders [0 ]->_model , 'Folder ' );
136
+ $ this ->assertEquals ($ resp ->data ->folders [1 ]->_model , 'Folder ' );
137
+ $ this ->assertEquals ($ resp ->data ->folders [0 ]->folder_id , 1001 );
138
+ $ this ->assertEquals ($ resp ->data ->folders [1 ]->folder_id , 1002 );
139
+ $ this ->assertEquals ($ resp ->data ->folders [0 ]->name , 'User 1 name Folder 2 ' );
140
+ $ this ->assertEquals ($ resp ->data ->folders [1 ]->name , 'User 1 name Folder 3 ' );
141
+ $ this ->assertEquals ($ resp ->data ->folders [0 ]->description , 'Description Folder 2 ' );
142
+ $ this ->assertEquals ($ resp ->data ->folders [1 ]->description , 'Description Folder 3 ' );
143
+
144
+ $ this ->resetAll ();
145
+ $ this ->params ['token ' ] = $ token ;
146
+ $ this ->params ['method ' ] = 'midas.folder.children ' ;
147
+ $ this ->params ['id ' ] = 1001 ;
148
+ $ this ->request ->setMethod ('POST ' );
149
+ $ resp = $ this ->_callJsonApi ();
150
+ $ this ->_assertStatusOk ($ resp );
151
+
152
+ // Should contain 0 folders and 2 items
153
+ $ this ->assertEquals (count ($ resp ->data ->folders ), 0 );
154
+ $ this ->assertEquals (count ($ resp ->data ->items ), 2 );
155
+
156
+ $ this ->assertEquals ($ resp ->data ->items [0 ]->_model , 'Item ' );
157
+ $ this ->assertEquals ($ resp ->data ->items [1 ]->_model , 'Item ' );
158
+ $ this ->assertEquals ($ resp ->data ->items [0 ]->item_id , 1 );
159
+ $ this ->assertEquals ($ resp ->data ->items [1 ]->item_id , 2 );
160
+ $ this ->assertEquals ($ resp ->data ->items [0 ]->name , 'name 1 ' );
161
+ $ this ->assertEquals ($ resp ->data ->items [1 ]->name , 'name 2 ' );
162
+ $ this ->assertEquals ($ resp ->data ->items [0 ]->description , 'Description 1 ' );
163
+ $ this ->assertEquals ($ resp ->data ->items [1 ]->description , 'Description 2 ' );
164
+ }
165
+
166
+ /** Test get user's default API key using username and password */
167
+ public function testUserApikeyDefault ()
168
+ {
169
+ $ this ->resetAll ();
170
+ $ usersFile = $ this ->loadData ('User ' , 'default ' );
171
+ $ userDao = $ this ->User ->load ($ usersFile [0 ]->getKey ());
172
+ $ this ->params ['method ' ] = 'midas.user.apikey.default ' ;
173
+ $ this ->params ['email ' ] = $ userDao ->getEmail ();
174
+ $ this ->params ['password ' ] = 'test ' ;
175
+ $ this ->request ->setMethod ('POST ' );
176
+ $ resp = $ this ->_callJsonApi ();
177
+ $ this ->_assertStatusOk ($ resp );
178
+
179
+ // Expected API key
180
+ $ modelLoad = new MIDAS_ModelLoader ();
181
+ $ userApiModel = $ modelLoad ->loadModel ('Userapi ' , 'api ' );
182
+ $ userApiModel ->createDefaultApiKey ($ userDao );
183
+ $ apiKey = $ userApiModel ->getByAppAndUser ('Default ' , $ userDao )->getApikey ();
184
+
185
+ $ this ->assertEquals ($ resp ->data ->apikey , $ apiKey );
186
+ }
118
187
}
0 commit comments