@@ -157,4 +157,41 @@ public function testCreate(): void
157157 $ this ->assertEquals ('1976 ' , $ inventory ['plantingYear ' ]);
158158 $ this ->assertEquals ('1267.13 ' , $ inventory ['volumePerSubcompartment ' ]);
159159 }
160+
161+ // A test to lookup all of a user's listings and then get more information
162+ // about one of them.
163+ public function testLookup (): void
164+ {
165+ // This is a short cut for now - log in directly using the stored user/pass
166+ // Eventually this should use an access token obtained from the OAuth exchange
167+ $ access = $ this ->login ();
168+ $ this ->assertIsString ($ access );
169+ $ this ->assertNotEmpty ($ access );
170+
171+ // Get the API client and set the access token from above.
172+ $ api = $ this ->getCloudForestClient ();
173+ $ api ->setAccess ($ access );
174+
175+ // Get all of the user's listings
176+ $ ownListings = $ api ->listing ->findOwn ();
177+
178+ // We don't know how many users there will be are because the marketplace
179+ // test server is out of our control here. But there should be at least
180+ // one because we created one above.
181+ $ this ->assertGreaterThan (1 , count ($ ownListings ));
182+
183+ // Get the first listing
184+ $ first = $ ownListings [0 ];
185+ $ title = $ first ['title ' ];
186+ $ state = $ first ['state ' ];
187+ $ this ->assertIsString ($ title );
188+ $ this ->assertIsString ($ state );
189+
190+ // Verify that we can also get this listing by its UUID
191+ $ uuid = $ first ['id ' ];
192+ $ listing = $ api ->listing ->findOne ($ uuid );
193+ $ this ->assertIsArray ($ listing );
194+ $ this ->assertEquals ($ listing ['title ' ], $ title );
195+ $ this ->assertEquals ($ listing ['state ' ], $ state );
196+ }
160197}
0 commit comments