From 5dfd6806eb7355a72c25ca2acb68c6baa38c7c4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Tue, 24 Sep 2024 17:37:44 +0200 Subject: [PATCH] add test class for vs event llist --- tests/test-class-plugin-vs-event-list.php | 63 +++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 tests/test-class-plugin-vs-event-list.php diff --git a/tests/test-class-plugin-vs-event-list.php b/tests/test-class-plugin-vs-event-list.php new file mode 100644 index 0000000..df669f2 --- /dev/null +++ b/tests/test-class-plugin-vs-event-list.php @@ -0,0 +1,63 @@ +activate_activitypub_support_for_active_event_plugins(); + + // Delete all posts afterwards. + _delete_all_posts(); + } + + /** + * Test that the right transformer gets applied. + */ + public function test_transformer_class() { + // We only test for one event plugin being active at the same time, + // even though we support multiple onces in theory. + // But testing all combinations is beyond scope. + $active_event_plugins = \Activitypub_Event_Extensions\Setup::get_instance()->get_active_event_plugins(); + $this->assertEquals( 1, count( $active_event_plugins ) ); + + // Enable ActivityPub support for the event plugin. + $this->assertContains( 'event', get_option( 'activitypub_support_post_types' ) ); + + // Insert a new Event. + $wp_post_id = wp_insert_post( + array( + 'post_title' => 'VSEL Test Event', + 'post_status' => 'published', + 'post_type' => 'event', + 'meta_input' => array( + 'event-start-time' => strtotime( '+10 days 15:00:00' ), + ), + ) + ); + + $wp_object = get_post( $wp_post_id ); + + // Call the transformer Factory. + $transformer = \Activitypub\Transformer\Factory::get_transformer( $wp_object ); + + // Check that we got the right transformer. + $this->assertInstanceOf( \Activitypub_Event_Extensions\Activitypub\Transformer\VS_Event_List::class, $transformer ); + } +}