diff --git a/includes/activitypub/transformer/class-event-organiser.php b/includes/activitypub/transformer/class-event-organiser.php index 4d65dfa..077a74f 100644 --- a/includes/activitypub/transformer/class-event-organiser.php +++ b/includes/activitypub/transformer/class-event-organiser.php @@ -20,18 +20,39 @@ use ActivityPub_Event_Bridge\Activitypub\Transformer\Event; * @since 1.0.0 */ final class Event_Organiser extends Event { + /** + * Extended constructor. + * + * The wp_object is overridden with a the wp_object with filters. This object + * also contains attributes specific to the Event organiser plugin like the + * occurrence id. + * + * @param WP_Post $wp_object The WordPress object. + * @param string $wp_taxonomy The taxonomy slug of the event post type. + */ + public function __construct( $wp_object, $wp_taxonomy ) { + parent::__construct( $wp_object, $wp_taxonomy ); + $this->wp_object = get_posts( + array( + 'ID' => $wp_object->ID, + 'post_type' => 'event', + 'suppress_filters' => false, + ) + )[0]; + } + /** * Get the end time from the event object. */ protected function get_end_time(): ?string { - return eo_get_the_end( 'Y-m-d\TH:i:s\Z', $this->wp_object->ID ); + return eo_get_the_end( 'Y-m-d\TH:i:s\Z', $this->wp_object->ID, $this->wp_object->occurrence_id ); } /** * Get the end time from the event object. */ protected function get_start_time(): string { - return eo_get_the_start( 'Y-m-d\TH:i:s\Z', $this->wp_object->ID ); + return eo_get_the_start( 'Y-m-d\TH:i:s\Z', $this->wp_object->ID, $this->wp_object->occurrence_id ); } /** diff --git a/tests/bootstrap.php b/tests/bootstrap.php index ecaebc2..514f8c2 100755 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -103,9 +103,9 @@ function _manually_load_plugin() { $mec_factory->install(); } - if ( 'event-organiser' === $activitypub_event_bridge_integration_filter ) { + if ( 'event_organiser' === $activitypub_event_bridge_integration_filter ) { require_once $plugin_dir . 'event-organiser/includes/event-organiser-install.php'; - eventorganiser_install(); + // eventorganiser_install(); } // At last manually load our WordPress plugin. diff --git a/tests/test-class-plugin-event-organiser.php b/tests/test-class-plugin-event-organiser.php index 939b5b6..2a1b45a 100644 --- a/tests/test-class-plugin-event-organiser.php +++ b/tests/test-class-plugin-event-organiser.php @@ -15,7 +15,7 @@ class Test_Event_Organiser extends WP_UnitTestCase { public function set_up() { parent::set_up(); - if ( ! class_exists( '\EO_Query_Result' ) ) { + if ( ! function_exists( 'eo_get_events' ) ) { self::markTestSkipped( 'Event Organiser plugin is not active.' ); } @@ -50,6 +50,7 @@ class Test_Event_Organiser extends WP_UnitTestCase { $post_data = array( 'post_title' => 'Unit Test Event', 'post_content' => 'Unit Test description.', + 'post_status' => 'publish', ); $post_id = eo_insert_event( $post_data, $event_data ); @@ -59,6 +60,7 @@ class Test_Event_Organiser extends WP_UnitTestCase { // Check that we got the right transformer. $this->assertInstanceOf( \ActivityPub_Event_Bridge\Activitypub\Transformer\Event_Organiser::class, $transformer ); + } /** @@ -76,6 +78,7 @@ class Test_Event_Organiser extends WP_UnitTestCase { $post_data = array( 'post_title' => 'Unit Test Event', 'post_content' => 'Unit Test description.', + 'post_status' => 'publish', ); $post_id = eo_insert_event( $post_data, $event_data );