From 82dca423e152507b1860bea6f19a13f215494cb8 Mon Sep 17 00:00:00 2001 From: ruru4143 Date: Mon, 7 Oct 2024 17:42:31 +0200 Subject: [PATCH 1/7] added basic my-calendar transformer --- .../transformer/class-my-calendar.php | 88 +++++++++++++++++++ includes/class-setup.php | 9 +- includes/plugins/class-my-calendar.php | 63 +++++++++++++ 3 files changed, 156 insertions(+), 4 deletions(-) create mode 100644 includes/activitypub/transformer/class-my-calendar.php create mode 100644 includes/plugins/class-my-calendar.php diff --git a/includes/activitypub/transformer/class-my-calendar.php b/includes/activitypub/transformer/class-my-calendar.php new file mode 100644 index 0000000..71475df --- /dev/null +++ b/includes/activitypub/transformer/class-my-calendar.php @@ -0,0 +1,88 @@ +mc_event = get_post_meta( $wp_object->ID, '_mc_event_data', true); + } + + + /** + * Formats time from the plugin to the activitypub standard + */ + private function convert_time( $date_string, $time_string ): string { + // Create a DateTime object with the given date, time, and timezone. + $datetime = new DateTime( $date_string . ' ' . $time_string ); + + // Set the timezone for proper formatting. + $datetime->setTimezone( new DateTimeZone( 'UTC' ) ); + + // Format the DateTime object as 'Y-m-d\TH:i:s\Z'. + $formatted_date = $datetime->format( 'Y-m-d\TH:i:s\Z' ); + return $formatted_date; + } + /** + * Get the start time from the events metadata. + */ + public function get_start_time(): string { + return $this->convert_time( $this->mc_event['event_begin'], $this->mc_event['event_time']); + } + + /** + * Get the end time from the events metadata. + */ + public function get_end_time(): ?string { + return $this->convert_time( $this->mc_event['event_end'], $this->mc_event['event_endtime']); + } + + public function to_object(): Event { + $activitypub_object = parent::to_object(); + + return $activitypub_object; + } + + +} diff --git a/includes/class-setup.php b/includes/class-setup.php index 39a4766..09d9f23 100644 --- a/includes/class-setup.php +++ b/includes/class-setup.php @@ -124,10 +124,11 @@ class Setup { * @var array */ private const EVENT_PLUGIN_CLASSES = array( - '\ActivityPub_Event_Bridge\Plugins\Events_Manager', - '\ActivityPub_Event_Bridge\Plugins\GatherPress', - '\ActivityPub_Event_Bridge\Plugins\The_Events_Calendar', - '\ActivityPub_Event_Bridge\Plugins\VS_Event_List', + '\Activitypub_Event_Extensions\Plugins\Events_Manager', + '\Activitypub_Event_Extensions\Plugins\GatherPress', + '\Activitypub_Event_Extensions\Plugins\The_Events_Calendar', + '\Activitypub_Event_Extensions\Plugins\VS_Event_List', + '\Activitypub_Event_Extensions\Plugins\My_Calendar', ); /** diff --git a/includes/plugins/class-my-calendar.php b/includes/plugins/class-my-calendar.php new file mode 100644 index 0000000..35604ed --- /dev/null +++ b/includes/plugins/class-my-calendar.php @@ -0,0 +1,63 @@ + Date: Thu, 10 Oct 2024 14:41:22 +0200 Subject: [PATCH 2/7] fixed naming --- includes/activitypub/transformer/class-my-calendar.php | 4 ++-- includes/class-setup.php | 10 +++++----- includes/plugins/class-my-calendar.php | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/includes/activitypub/transformer/class-my-calendar.php b/includes/activitypub/transformer/class-my-calendar.php index 71475df..179d709 100644 --- a/includes/activitypub/transformer/class-my-calendar.php +++ b/includes/activitypub/transformer/class-my-calendar.php @@ -6,14 +6,14 @@ * @license AGPL-3.0-or-later */ -namespace Activitypub_Event_Extensions\Activitypub\Transformer; +namespace ActivityPub_Event_Bridge\Activitypub\Transformer; // Exit if accessed directly. defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore use Activitypub\Activity\Extended_Object\Event; use Activitypub\Activity\Extended_Object\Place; -use Activitypub_Event_Extensions\Activitypub\Transformer\Event as Event_Transformer; +use ActivityPub_Event_Bridge\Activitypub\Transformer\Event as Event_Transformer; use DateTime; use DateTimeZone; use EM_Event; diff --git a/includes/class-setup.php b/includes/class-setup.php index 09d9f23..fc742e5 100644 --- a/includes/class-setup.php +++ b/includes/class-setup.php @@ -124,11 +124,11 @@ class Setup { * @var array */ private const EVENT_PLUGIN_CLASSES = array( - '\Activitypub_Event_Extensions\Plugins\Events_Manager', - '\Activitypub_Event_Extensions\Plugins\GatherPress', - '\Activitypub_Event_Extensions\Plugins\The_Events_Calendar', - '\Activitypub_Event_Extensions\Plugins\VS_Event_List', - '\Activitypub_Event_Extensions\Plugins\My_Calendar', + '\ActivityPub_Event_Bridge\Plugins\Events_Manager', + '\ActivityPub_Event_Bridge\Plugins\GatherPress', + '\ActivityPub_Event_Bridge\Plugins\The_Events_Calendar', + '\ActivityPub_Event_Bridge\Plugins\VS_Event_List', + '\ActivityPub_Event_Bridge\Plugins\My_Calendar', ); /** diff --git a/includes/plugins/class-my-calendar.php b/includes/plugins/class-my-calendar.php index 35604ed..4959984 100644 --- a/includes/plugins/class-my-calendar.php +++ b/includes/plugins/class-my-calendar.php @@ -10,7 +10,7 @@ * @since 1.0.0 */ -namespace Activitypub_Event_Extensions\Plugins; +namespace ActivityPub_Event_Bridge\Plugins; use Activitypub_Event_Extensions\Event_Plugins; -- 2.39.5 From 41363f3feec3c445e0161645bf34649a5ff99a8d Mon Sep 17 00:00:00 2001 From: ruru4143 Date: Thu, 10 Oct 2024 14:42:26 +0200 Subject: [PATCH 3/7] get schema directly --- includes/activitypub/transformer/class-my-calendar.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/includes/activitypub/transformer/class-my-calendar.php b/includes/activitypub/transformer/class-my-calendar.php index 179d709..4aa1da5 100644 --- a/includes/activitypub/transformer/class-my-calendar.php +++ b/includes/activitypub/transformer/class-my-calendar.php @@ -34,6 +34,7 @@ final class My_Calendar extends Event_Transformer { * @var array */ protected $mc_event; + protected $mc_event_schema; /** * Extend the constructor, to also set the Eventsmanager objects. @@ -46,7 +47,10 @@ final class My_Calendar extends Event_Transformer { */ public function __construct( $wp_object, $wp_taxonomy ) { parent::__construct( $wp_object, $wp_taxonomy ); - $this->mc_event = get_post_meta( $wp_object->ID, '_mc_event_data', true); + $mc_event_id = get_post_meta( $this->wp_object->ID, '_mc_event_id', true ); + $this->mc_event = mc_get_event( $mc_event_id ); + + $this->mc_event_schema = mc_event_schema( $this->mc_event ); } @@ -68,14 +72,14 @@ final class My_Calendar extends Event_Transformer { * Get the start time from the events metadata. */ public function get_start_time(): string { - return $this->convert_time( $this->mc_event['event_begin'], $this->mc_event['event_time']); + return $this->convert_time( $this->mc_event->event_begin, $this->mc_event->event_time); } /** * Get the end time from the events metadata. */ public function get_end_time(): ?string { - return $this->convert_time( $this->mc_event['event_end'], $this->mc_event['event_endtime']); + return $this->convert_time( $this->mc_event->event_end, $this->mc_event->event_endtime); } public function to_object(): Event { -- 2.39.5 From 2e8d7306bfd15df22c7ad885d36e41d40b5833f9 Mon Sep 17 00:00:00 2001 From: ruru4143 Date: Thu, 10 Oct 2024 14:44:08 +0200 Subject: [PATCH 4/7] added location --- .../transformer/class-my-calendar.php | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/includes/activitypub/transformer/class-my-calendar.php b/includes/activitypub/transformer/class-my-calendar.php index 4aa1da5..0425cb8 100644 --- a/includes/activitypub/transformer/class-my-calendar.php +++ b/includes/activitypub/transformer/class-my-calendar.php @@ -82,11 +82,32 @@ final class My_Calendar extends Event_Transformer { return $this->convert_time( $this->mc_event->event_end, $this->mc_event->event_endtime); } + /** + * Get the event location. + * + * @return Place|null The place/venue if one is set. + */ + public function get_location(): ?Place { + if ( array_key_exists('location', $this->mc_event_schema ) && $this->mc_event_schema['location']['@type'] == 'Place' ) { + $mc_place = $this->mc_event_schema['location']; + + $place = new Place(); + $place->set_name( $mc_place['name'] ); + $place->set_url( $mc_place['url'] ); + $place->set_address( $mc_place['address'] ); + + if ( ! empty( $mc_place['geo'] ) ) { + $place->set_latitude( $mc_place['geo']['latitude'] ); + $place->set_longitude( $mc_place['geo']['longitude'] ); + } + return $place; + } + return null; + } + public function to_object(): Event { $activitypub_object = parent::to_object(); return $activitypub_object; } - - } -- 2.39.5 From fdb4f000a36986872eec9f8e92c4e9af26b6e412 Mon Sep 17 00:00:00 2001 From: ruru4143 Date: Thu, 10 Oct 2024 14:44:26 +0200 Subject: [PATCH 5/7] added static status --- includes/activitypub/transformer/class-my-calendar.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/includes/activitypub/transformer/class-my-calendar.php b/includes/activitypub/transformer/class-my-calendar.php index 0425cb8..a041374 100644 --- a/includes/activitypub/transformer/class-my-calendar.php +++ b/includes/activitypub/transformer/class-my-calendar.php @@ -105,6 +105,16 @@ final class My_Calendar extends Event_Transformer { return null; } + /** + * Get status of the event + * + * @return string status of the event + */ + public function get_status(): ?string { + return 'CONFIRMED'; # my-calender doesn't implement canceled events. + } + + public function to_object(): Event { $activitypub_object = parent::to_object(); -- 2.39.5 From 1504b3a23bed2abc6733e080bbf8714c9bfe626e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sat, 26 Oct 2024 17:05:58 +0200 Subject: [PATCH 6/7] phpcs --- .../transformer/class-my-calendar.php | 58 ++++++++++--------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/includes/activitypub/transformer/class-my-calendar.php b/includes/activitypub/transformer/class-my-calendar.php index a041374..0508266 100644 --- a/includes/activitypub/transformer/class-my-calendar.php +++ b/includes/activitypub/transformer/class-my-calendar.php @@ -1,6 +1,8 @@ wp_object->ID, '_mc_event_id', true ); - $this->mc_event = mc_get_event( $mc_event_id ); - + $mc_event_id = get_post_meta( $this->wp_object->ID, '_mc_event_id', true ); + $this->mc_event = mc_get_event( $mc_event_id ); $this->mc_event_schema = mc_event_schema( $this->mc_event ); } - /** - * Formats time from the plugin to the activitypub standard + * Formats time from the plugin to the activitypub standard. + * + * @param string $date_string The plugins string representation for a date without time. + * @param string $time_string The plugins string representation for a time. + * + * @return string */ private function convert_time( $date_string, $time_string ): string { // Create a DateTime object with the given date, time, and timezone. @@ -70,16 +77,20 @@ final class My_Calendar extends Event_Transformer { } /** * Get the start time from the events metadata. + * + * @return string The events start date-time. */ public function get_start_time(): string { - return $this->convert_time( $this->mc_event->event_begin, $this->mc_event->event_time); + return $this->convert_time( $this->mc_event->event_begin, $this->mc_event->event_time ); } /** * Get the end time from the events metadata. + * + * @return string The events start end-time. */ public function get_end_time(): ?string { - return $this->convert_time( $this->mc_event->event_end, $this->mc_event->event_endtime); + return $this->convert_time( $this->mc_event->event_end, $this->mc_event->event_endtime ); } /** @@ -88,7 +99,7 @@ final class My_Calendar extends Event_Transformer { * @return Place|null The place/venue if one is set. */ public function get_location(): ?Place { - if ( array_key_exists('location', $this->mc_event_schema ) && $this->mc_event_schema['location']['@type'] == 'Place' ) { + if ( array_key_exists( 'location', $this->mc_event_schema, true ) && 'Place' === $this->mc_event_schema['location']['@type'] ) { $mc_place = $this->mc_event_schema['location']; $place = new Place(); @@ -111,13 +122,6 @@ final class My_Calendar extends Event_Transformer { * @return string status of the event */ public function get_status(): ?string { - return 'CONFIRMED'; # my-calender doesn't implement canceled events. - } - - - public function to_object(): Event { - $activitypub_object = parent::to_object(); - - return $activitypub_object; + return 'CONFIRMED'; // My Calendar doesn't implement canceled events. } } -- 2.39.5 From 44a5ddc463b3005d42c9fe48a9ab9adbffa1140b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sun, 27 Oct 2024 21:36:52 +0100 Subject: [PATCH 7/7] wip --- .forgejo/workflows/phpunit.yml | 2 +- bin/install-wp-tests.sh | 3 +- composer.json | 3 +- .../transformer/class-my-calendar.php | 12 +- tests/bootstrap.php | 8 + tests/test-class-plugin-my-calendar.php | 232 ++++++++++++++++++ 6 files changed, 256 insertions(+), 4 deletions(-) create mode 100644 tests/test-class-plugin-my-calendar.php diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index a893dce..10d25e1 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -37,7 +37,7 @@ jobs: path: | ${{ env.WP_CORE_DIR }} ${{ env.WP_TESTS_DIR }} - key: cache-wordpress-9 + key: cache-wordpress-10 - name: Cache Composer id: cache-composer-phpunit diff --git a/bin/install-wp-tests.sh b/bin/install-wp-tests.sh index f0bf333..728aa58 100755 --- a/bin/install-wp-tests.sh +++ b/bin/install-wp-tests.sh @@ -208,7 +208,7 @@ install_wp_plugin() { fi # Get the latest tag. - LATEST_TAG=$(svn log https://plugins.svn.wordpress.org/$PLUGIN_NAME/tags --limit 1 | awk 'NR == 4 { print $4 }') + LATEST_TAG=$(svn log https://plugins.svn.wordpress.org/$PLUGIN_NAME/tags --limit 1 | awk 'NR == 4 { print $4 }' | sed 's/,$//') if [ -n "$LATEST_TAG" ]; then PLUGIN_FILE="$PLUGIN_NAME.$LATEST_TAG.zip" else @@ -254,6 +254,7 @@ install_wp_plugins() { install_wp_plugin events-manager install_wp_plugin wp-event-manager install_wp_plugin wp-event-solution + install_wp_plugin my-calendar # Mec is not installable via wordpress.org, we use our own mirror. install_wp_plugin_mec } diff --git a/composer.json b/composer.json index 6236dfc..5e21aaa 100644 --- a/composer.json +++ b/composer.json @@ -58,7 +58,7 @@ ], "test-debug": [ "@prepare-test", - "@test-gatherpress" + "@test-my-calendar" ], "test-vs-event-list": "phpunit --filter=vs_event_list", "test-the-events-calendar": "phpunit --filter=the_events_calendar", @@ -67,6 +67,7 @@ "test-wp-event-manager": "phpunit --filter=wp_event_manager", "test-eventin": "phpunit --filter=eventin", "test-modern-events-calendar-lite": "phpunit --filter=modern_events_calendar_lite", + "test-my-calendar": "phpunit --filter=my_calendar", "test-all": "phpunit" } } diff --git a/includes/activitypub/transformer/class-my-calendar.php b/includes/activitypub/transformer/class-my-calendar.php index 0508266..79328f0 100644 --- a/includes/activitypub/transformer/class-my-calendar.php +++ b/includes/activitypub/transformer/class-my-calendar.php @@ -99,7 +99,7 @@ final class My_Calendar extends Event_Transformer { * @return Place|null The place/venue if one is set. */ public function get_location(): ?Place { - if ( array_key_exists( 'location', $this->mc_event_schema, true ) && 'Place' === $this->mc_event_schema['location']['@type'] ) { + if ( array_key_exists( 'location', $this->mc_event_schema ) && 'Place' === $this->mc_event_schema['location']['@type'] ) { $mc_place = $this->mc_event_schema['location']; $place = new Place(); @@ -124,4 +124,14 @@ final class My_Calendar extends Event_Transformer { public function get_status(): ?string { return 'CONFIRMED'; // My Calendar doesn't implement canceled events. } + + /** + * Extract the external participation url. + * + * @return ?string The external participation URL. + */ + public function get_external_participation_url(): ?string { + + return $this->mc_event->event_tickets ? $this->mc_event->event_tickets : null; + } } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index df5b41e..a3afd79 100755 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -71,6 +71,9 @@ function _manually_load_plugin() { case 'wp_event_manager': $plugin_file = 'wp-event-manager/wp-event-manager.php'; break; + case 'my_calendar': + $plugin_file = 'my-calendar/my-calendar.php'; + break; } if ( $plugin_file ) { @@ -97,6 +100,11 @@ function _manually_load_plugin() { $mec_factory->install(); } + if ( 'my_calendar' === $activitypub_event_extension_integration_filter ) { + require_once $plugin_dir . 'my-calendar/my-calendar.php'; + add_action( 'init', 'mc_default_settings' ); + } + // At last manually load our WordPress plugin. require dirname( __DIR__ ) . '/activitypub-event-bridge.php'; } diff --git a/tests/test-class-plugin-my-calendar.php b/tests/test-class-plugin-my-calendar.php new file mode 100644 index 0000000..62124e3 --- /dev/null +++ b/tests/test-class-plugin-my-calendar.php @@ -0,0 +1,232 @@ +mockup_event = array( + // Begin strings. + 'event_begin' => date( 'Y-m-d', strtotime( '+10 days' ) ), // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date + 'event_end' => date( 'Y-m-d', strtotime( '+10 days', ) ), // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date + 'event_title' => 'Demo: Florence Price: Symphony No. 3 in c minor', + 'event_desc' => "

Florence Price's Symphony No. 3 was commissioned by the Works Progress Administration's Federal Music Project during the height of the Great Depression. It was first performed at the Detroit Institute of Arts on November 6, 1940, by the Detroit Civic Orchestra under the conductor Valter Poole.

The composition is Price's third symphony, following her Symphony in E minor—the first symphony by a black woman to be performed by a major American orchestra—and her lost Symphony No. 2.

", + 'event_short' => "Florence Price's Symphony No.3 was first performed on November 6th, 1940. It was Ms. Price's third symphony, following her lost Symphony No. 2", + 'event_time' => '15:00:00', + 'event_endtime' => '16:00:00', + 'event_link' => 'https://www.youtube.com/watch?v=1jgJ1OkjnaI&list=OLAK5uy_lKldgbFTYBDa7WN6jf2ubB595wncDU7yc&index=2', + 'event_recur' => 'S1', + 'event_image' => plugins_url( '/.wordpress-org/banner-772x250.jpg', ACTIVITYPUB_EVENT_BRIDGE_PLUGIN_FILE ), + 'event_access' => '', + 'event_tickets' => '', + 'event_registration' => '', + 'event_repeats' => '', + // Begin integers. + 'event_author' => wp_get_current_user()->ID, + 'event_category' => 1, + 'event_link_expires' => 0, + 'event_zoom' => 16, + 'event_approved' => 1, + 'event_host' => wp_get_current_user()->ID, + 'event_flagged' => 0, + 'event_fifth_week' => 0, + 'event_holiday' => 0, + 'event_group_id' => 1, + 'event_span' => 0, + 'event_hide_end' => 0, + // Array: removed before DB insertion. + 'event_categories' => array( 1 ), + ); + + $access = array( 1, 2, 3, 4, 6, 8, 9 ); + + $this->mockup_location = array( + 'location_label' => 'Demo: Minnesota Orchestra', + 'location_street' => '1111 Nicollet Mall', + 'location_street2' => '', + 'location_city' => 'Minneapolis', + 'location_state' => 'MN', + 'location_postcode' => '55403', + 'location_region' => '', + 'location_country' => 'United States', + 'location_url' => 'https://www.minnesotaorchestra.org', + 'location_latitude' => '44.9722', + 'location_longitude' => '-93.2749', + 'location_zoom' => 16, + 'location_phone' => '612-371-5600', + 'location_phone2' => '', + 'location_access' => serialize( $access ), + ); + + $this->mockup_category = array( + 'category_name' => 'General', + 'category_color' => '#243f82', + 'category_icon' => 'event.svg', + ); + } + + + + /** + * Override the setup function, so that tests don't run if the Events Calendar is not active. + */ + public function set_up() { + parent::set_up(); + + if ( ! function_exists( 'mc_get_event' ) ) { + self::markTestSkipped( 'My Calendar plugin is not active.' ); + } + + self::setUpMockupEvents(); + + // Make sure that ActivityPub support is enabled for The Events Calendar. + $aec = \ActivityPub_Event_Bridge\Setup::get_instance(); + $aec->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_Bridge\Setup::get_instance()->get_active_event_plugins(); + $this->assertEquals( 1, count( $active_event_plugins ) ); + + // Enable ActivityPub support for the event plugin. + $this->assertContains( 'mc-events', get_option( 'activitypub_support_post_types' ) ); + + // mc_create_category( $this->mockup_category ); + // $location = mc_insert_location( $this->mockup_location ); + // $location = apply_filters( 'mc_save_location', $location, $this->mockup_location, $this->mockup_location ); + // $event = array( true, false, $this->mockup_event, false, array() ); + // $event = my_calendar_save( 'add', $event ); + // mc_update_event( 'event_location', (int) $location, $event['event_id'] ); + + // Insert a category. + mc_create_category( + array( + 'category_name' => 'General', + 'category_color' => '#243f82', + 'category_icon' => 'event.svg', + ) + ); + // Insert a location. + $access = array( 1, 2, 3, 4, 6, 8, 9 ); + $add = array( + 'location_label' => 'Demo: Minnesota Orchestra', + 'location_street' => '1111 Nicollet Mall', + 'location_street2' => '', + 'location_city' => 'Minneapolis', + 'location_state' => 'MN', + 'location_postcode' => '55403', + 'location_region' => '', + 'location_country' => 'United States', + 'location_url' => 'https://www.minnesotaorchestra.org', + 'location_latitude' => '44.9722', + 'location_longitude' => '-93.2749', + 'location_zoom' => 16, + 'location_phone' => '612-371-5600', + 'location_phone2' => '', + 'location_access' => serialize( $access ), + ); + $results = mc_insert_location( $add ); + /** + * Executed an action when the demo location is saved at installation. + * + * @hook mc_save_location + * + * @param {int|false} $results Result of database insertion. Row ID or false. + * @param {array} $add Array of location parameters to add. + * @param {array} $add Demo location array. + */ + $results = apply_filters( 'mc_save_location', $results, $add, $add ); + // Insert an event. + $submit = array( + // Begin strings. + 'event_begin' => date( 'Y-m-d', strtotime( '+1 day' ) ), // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date + 'event_end' => date( 'Y-m-d', strtotime( '+1 day' ) ), // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date + 'event_title' => 'Demo: Florence Price: Symphony No. 3 in c minor', + 'event_desc' => "

Florence Price's Symphony No. 3 was commissioned by the Works Progress Administration's Federal Music Project during the height of the Great Depression. It was first performed at the Detroit Institute of Arts on November 6, 1940, by the Detroit Civic Orchestra under the conductor Valter Poole.

The composition is Price's third symphony, following her Symphony in E minor—the first symphony by a black woman to be performed by a major American orchestra—and her lost Symphony No. 2.

", + 'event_short' => "Florence Price's Symphony No.3 was first performed on November 6th, 1940. It was Ms. Price's third symphony, following her lost Symphony No. 2", + 'event_time' => '19:30:00', + 'event_endtime' => '21:00:00', + 'event_link' => 'https://www.youtube.com/watch?v=1jgJ1OkjnaI&list=OLAK5uy_lKldgbFTYBDa7WN6jf2ubB595wncDU7yc&index=2', + 'event_recur' => 'S1', + 'event_image' => plugins_url( '/images/demo/event.jpg', __FILE__ ), + 'event_access' => '', + 'event_tickets' => '', + 'event_registration' => '', + 'event_repeats' => '', + // Begin integers. + 'event_author' => wp_get_current_user()->ID, + 'event_category' => 1, + 'event_link_expires' => 0, + 'event_zoom' => 16, + 'event_approved' => 1, + 'event_host' => wp_get_current_user()->ID, + 'event_flagged' => 0, + 'event_fifth_week' => 0, + 'event_holiday' => 0, + 'event_group_id' => 1, + 'event_span' => 0, + 'event_hide_end' => 0, + // Array: removed before DB insertion. + 'event_categories' => array( 1 ), + ); + + $event = array( true, false, $submit, false, array() ); + $response = my_calendar_save( 'add', $event ); + $event_id = $response['event_id']; + $r = mc_update_event( 'event_location', (int) $results, $event_id ); + + $e = mc_get_first_event( $event_id ); + $post_id = $e->event_post; + $image = media_sideload_image( plugins_url( '/images/demo/event.jpg', __FILE__ ), $post_id, null, 'id' ); + + if ( ! is_wp_error( $image ) ) { + set_post_thumbnail( $post_id, $image ); + } + + $wp_object = get_post( $event['event_post'] ); + + // Call the transformer Factory. + $transformer = \Activitypub\Transformer\Factory::get_transformer( $wp_object ); + + // Check that we got the right transformer. + $this->assertInstanceOf( \ActivityPub_Event_Bridge\Activitypub\Transformer\My_Calendar::class, $transformer ); + } +} -- 2.39.5