@@ -299,4 +299,82 @@ public function test_is_activity_with_invalid_input() {
299299 );
300300 }
301301 }
302+
303+ /**
304+ * Test is_post_disabled function.
305+ *
306+ * @covers ::is_post_disabled
307+ */
308+ public function test_is_post_disabled () {
309+ // Test standard public post.
310+ $ public_post_id = self ::factory ()->post ->create ();
311+ $ this ->assertFalse ( \Activitypub \is_post_disabled ( $ public_post_id ) );
312+
313+ // Test local-only post.
314+ $ local_post_id = self ::factory ()->post ->create ();
315+ add_post_meta ( $ local_post_id , 'activitypub_content_visibility ' , ACTIVITYPUB_CONTENT_VISIBILITY_LOCAL );
316+ $ this ->assertTrue ( \Activitypub \is_post_disabled ( $ local_post_id ) );
317+
318+ // Test private post.
319+ $ private_post_id = self ::factory ()->post ->create (
320+ array (
321+ 'post_status ' => 'private ' ,
322+ )
323+ );
324+ $ this ->assertTrue ( \Activitypub \is_post_disabled ( $ private_post_id ) );
325+
326+ // Test password protected post.
327+ $ password_post_id = self ::factory ()->post ->create (
328+ array (
329+ 'post_password ' => 'test123 ' ,
330+ )
331+ );
332+ $ this ->assertTrue ( \Activitypub \is_post_disabled ( $ password_post_id ) );
333+
334+ // Test unsupported post type.
335+ register_post_type ( 'unsupported ' , array () );
336+ $ unsupported_post_id = self ::factory ()->post ->create (
337+ array (
338+ 'post_type ' => 'unsupported ' ,
339+ )
340+ );
341+ $ this ->assertTrue ( \Activitypub \is_post_disabled ( $ unsupported_post_id ) );
342+ unregister_post_type ( 'unsupported ' );
343+
344+ // Test with filter.
345+ add_filter ( 'activitypub_is_post_disabled ' , '__return_true ' );
346+ $ this ->assertTrue ( \Activitypub \is_post_disabled ( $ public_post_id ) );
347+ remove_filter ( 'activitypub_is_post_disabled ' , '__return_true ' );
348+
349+ // Clean up.
350+ wp_delete_post ( $ public_post_id , true );
351+ wp_delete_post ( $ local_post_id , true );
352+ wp_delete_post ( $ private_post_id , true );
353+ wp_delete_post ( $ password_post_id , true );
354+ }
355+
356+ /**
357+ * Test is_post_disabled with private visibility.
358+ *
359+ * @covers ::is_post_disabled
360+ */
361+ public function test_is_post_disabled_private_visibility () {
362+ $ visible_private_post_id = self ::factory ()->post ->create ();
363+
364+ add_post_meta ( $ visible_private_post_id , 'activitypub_content_visibility ' , ACTIVITYPUB_CONTENT_VISIBILITY_PRIVATE );
365+ $ this ->assertFalse ( \Activitypub \is_post_disabled ( $ visible_private_post_id ) );
366+
367+ wp_delete_post ( $ visible_private_post_id , true );
368+ }
369+
370+ /**
371+ * Test is_post_disabled with invalid post.
372+ *
373+ * @covers ::is_post_disabled
374+ */
375+ public function test_is_post_disabled_invalid_post () {
376+ $ this ->assertTrue ( \Activitypub \is_post_disabled ( 0 ) );
377+ $ this ->assertTrue ( \Activitypub \is_post_disabled ( null ) );
378+ $ this ->assertTrue ( \Activitypub \is_post_disabled ( 999999 ) );
379+ }
302380}
0 commit comments