@@ -19,8 +19,8 @@ public function setUp()
19
19
$ this ->setupDatabase (array ('default ' )); //core dataset
20
20
$ this ->setupDatabase (array ('default ' ), 'api ' ); // module dataset
21
21
$ this ->enabledModules = array ('api ' );
22
- $ this ->_models = array ('User ' , 'Folder ' );
23
- $ this ->_daos = array ('User ' , 'Folder ' );
22
+ $ this ->_models = array ('User ' , 'Folder ' , ' Item ' );
23
+ $ this ->_daos = array ('User ' , 'Folder ' , ' Item ' );
24
24
25
25
parent ::setUp ();
26
26
}
@@ -164,6 +164,46 @@ public function testFolderChildren()
164
164
$ this ->assertEquals ($ resp ->data ->items [1 ]->description , 'Description 2 ' );
165
165
}
166
166
167
+ /** Test the item.get method */
168
+ public function testItemGet ()
169
+ {
170
+ $ itemsFile = $ this ->loadData ('Item ' , 'default ' );
171
+ $ itemDao = $ this ->Item ->load ($ itemsFile [0 ]->getKey ());
172
+
173
+ $ this ->resetAll ();
174
+ $ token = $ this ->_loginUsingApiKey ();
175
+ $ this ->params ['token ' ] = $ token ;
176
+ $ this ->params ['method ' ] = 'midas.item.get ' ;
177
+ $ this ->params ['id ' ] = $ itemsFile [0 ]->getKey ();
178
+ $ this ->request ->setMethod ('POST ' );
179
+ $ resp = $ this ->_callJsonApi ();
180
+ $ this ->_assertStatusOk ($ resp );
181
+
182
+ $ this ->assertEquals ($ resp ->data ->item_id , $ itemDao ->getKey ());
183
+ $ this ->assertEquals ($ resp ->data ->uuid , $ itemDao ->getUuid ());
184
+ $ this ->assertEquals ($ resp ->data ->description , $ itemDao ->getDescription ());
185
+ $ this ->assertTrue (is_array ($ resp ->data ->revisions ));
186
+ $ this ->assertEquals (count ($ resp ->data ->revisions ), 2 ); //make sure we get both revisions
187
+ $ this ->assertTrue (is_array ($ resp ->data ->revisions [0 ]->bitstreams ));
188
+ $ this ->assertEquals ($ resp ->data ->revisions [0 ]->revision , '1 ' );
189
+ $ this ->assertEquals ($ resp ->data ->revisions [1 ]->revision , '2 ' );
190
+
191
+ // Test the 'head' parameter
192
+ $ this ->resetAll ();
193
+ $ token = $ this ->_loginUsingApiKey ();
194
+ $ this ->params ['token ' ] = $ token ;
195
+ $ this ->params ['method ' ] = 'midas.item.get ' ;
196
+ $ this ->params ['id ' ] = $ itemsFile [0 ]->getKey ();
197
+ $ this ->params ['head ' ] = 'true ' ;
198
+ $ this ->request ->setMethod ('POST ' );
199
+ $ resp = $ this ->_callJsonApi ();
200
+ $ this ->_assertStatusOk ($ resp );
201
+
202
+ $ this ->assertEquals (count ($ resp ->data ->revisions ), 1 ); //make sure we get only one revision
203
+ $ this ->assertTrue (is_array ($ resp ->data ->revisions [0 ]->bitstreams ));
204
+ $ this ->assertEquals ($ resp ->data ->revisions [0 ]->revision , '2 ' );
205
+ }
206
+
167
207
/** Test get user's default API key using username and password */
168
208
public function testUserApikeyDefault ()
169
209
{
0 commit comments