@@ -289,12 +289,10 @@ public function test_delete_invalidates_all_activities() {
289289 * @dataProvider data_provider_get_object_id
290290 * @covers ::get_object_id
291291 *
292- * @param array $activity_data The activity data to test.
293- * @param string $expected The expected object ID.
292+ * @param Activity $activity The activity data to test.
293+ * @param string $expected The expected object ID.
294294 */
295- public function test_get_object_id ( $ activity_data , $ expected ) {
296- $ activity = Generic_Object::init_from_array ( $ activity_data );
297-
295+ public function test_get_object_id ( $ activity , $ expected ) {
298296 // Get the object ID using reflection since it's a private method.
299297 $ get_object_id = new \ReflectionMethod ( Outbox::class, 'get_object_id ' );
300298 $ get_object_id ->setAccessible ( true );
@@ -310,64 +308,67 @@ public function test_get_object_id( $activity_data, $expected ) {
310308 * @return array
311309 */
312310 public function data_provider_get_object_id () {
311+ $ create_with_id = Activity::init_from_array (
312+ array (
313+ 'type ' => 'Create ' ,
314+ 'object ' => array (
315+ 'type ' => 'Note ' ,
316+ 'id ' => 'https://example.com/note/123 ' ,
317+ ),
318+ )
319+ );
320+ $ create_no_id = Activity::init_from_array (
321+ array (
322+ 'type ' => 'Create ' ,
323+ 'object ' => array (
324+ 'type ' => 'Note ' ,
325+ 'content ' => 'Test content ' ,
326+ ),
327+ )
328+ );
329+
313330 return array (
314331 'object is a string ' => array (
315- 'activity ' => array (
316- 'type ' => 'Create ' ,
317- 'object ' => 'https://example.com/note/123 ' ,
332+ 'activity ' => Activity::init_from_array (
333+ array (
334+ 'type ' => 'Create ' ,
335+ 'object ' => 'https://example.com/note/123 ' ,
336+ )
318337 ),
319338 'expected ' => 'https://example.com/note/123 ' ,
320339 ),
321340 'object is an object with id ' => array (
322- 'activity ' => array (
323- 'type ' => 'Create ' ,
324- 'object ' => array (
325- 'type ' => 'Note ' ,
326- 'id ' => 'https://example.com/note/123 ' ,
327- ),
328- ),
341+ 'activity ' => $ create_with_id ,
329342 'expected ' => 'https://example.com/note/123 ' ,
330343 ),
331344 'object is an object without id ' => array (
332- 'activity ' => array (
333- 'type ' => 'Create ' ,
334- 'object ' => array (
335- 'type ' => 'Note ' ,
336- 'content ' => 'Test content ' ,
337- ),
338- ),
345+ 'activity ' => $ create_no_id ,
339346 'expected ' => null , // Will use activity ID as fallback.
340347 ),
341348 'nested object with id ' => array (
342- 'activity ' => array (
343- 'type ' => 'Create ' ,
344- 'object ' => array (
345- 'type ' => 'Article ' ,
346- 'object ' => array (
347- 'type ' => 'Note ' ,
348- 'id ' => 'https://example.com/note/123 ' ,
349- ),
350- ),
349+ 'activity ' => Activity::init_from_array (
350+ array (
351+ 'type ' => 'Announce ' ,
352+ 'object ' => $ create_with_id ,
353+ )
351354 ),
352355 'expected ' => 'https://example.com/note/123 ' ,
353356 ),
354357 'nested object without id ' => array (
355- 'activity ' => array (
356- 'type ' => 'Create ' ,
357- 'object ' => array (
358- 'type ' => 'Article ' ,
359- 'object ' => array (
360- 'type ' => 'Note ' ,
361- 'content ' => 'Test content ' ,
362- ),
363- ),
358+ 'activity ' => Activity::init_from_array (
359+ array (
360+ 'type ' => 'Announce ' ,
361+ 'object ' => $ create_no_id ,
362+ )
364363 ),
365364 'expected ' => null , // Will use activity ID as fallback.
366365 ),
367366 'activity with no object ' => array (
368- 'activity ' => array (
369- 'type ' => 'Delete ' ,
370- 'actor ' => 'https://example.com/user/1 ' ,
367+ 'activity ' => Activity::init_from_array (
368+ array (
369+ 'type ' => 'Delete ' ,
370+ 'actor ' => 'https://example.com/user/1 ' ,
371+ )
371372 ),
372373 'expected ' => 'https://example.com/user/1 ' , // Will use actor as fallback.
373374 ),
0 commit comments