diff --git a/composer.json b/composer.json
index d091876..28fb046 100644
--- a/composer.json
+++ b/composer.json
@@ -54,7 +54,7 @@
],
"test-debug": [
"@prepare-test",
- "@test-vs-event-list"
+ "@test-gatherpress"
],
"test-vs-event-list": "phpunit --filter=vs_event_list",
"test-the-events-calendar": "phpunit --filter=the_events_calendar",
diff --git a/includes/activitypub/transformer/class-event.php b/includes/activitypub/transformer/class-event.php
index 893778f..7b144a6 100644
--- a/includes/activitypub/transformer/class-event.php
+++ b/includes/activitypub/transformer/class-event.php
@@ -21,6 +21,11 @@ use DateTime;
*
* Everything that transforming several WordPress post types that represent events
* have in common, as well as sane defaults for events should be defined here.
+ *
+ * BeforeFirstRelease:
+ * [ ] remove link at the end of the content.
+ * [ ] add organizer.
+ * [ ] do add Cancelled reason in the content.
*/
abstract class Event extends Post {
@@ -31,17 +36,6 @@ abstract class Event extends Post {
*/
protected $wp_taxonomy;
- /**
- * Returns the User-URL of the Author of the Post.
- *
- * If `single_user` mode is enabled, the URL of the Blog-User is returned.
- *
- * @return string The User-URL.
- */
- protected function get_actor(): ?string {
- return $this->get_attributed_to();
- }
-
/**
* Returns the ActivityStreams 2.0 Object-Type for an Event.
*
@@ -60,6 +54,16 @@ abstract class Event extends Post {
return comments_open( $this->wp_object );
}
+ /**
+ * Set a hardcoded template for the content.
+ *
+ * This actually disabled templates for the content.
+ * Maybe this independent templates for events will be added later.
+ */
+ protected function get_post_content_template(): string {
+ return '[ap_content]';
+ }
+
/**
* Returns the title of the event.
*
@@ -77,7 +81,7 @@ abstract class Event extends Post {
* @param WP_Post $wp_object The WordPress post object (event).
* @param string $wp_taxonomy The taxonomy slug of the event post type.
*/
- public function __construct( $wp_object, $wp_taxonomy ) {
+ public function __construct( $wp_object, $wp_taxonomy = 'category' ) {
parent::__construct( $wp_object );
$this->wp_taxonomy = $wp_taxonomy;
}
@@ -107,8 +111,13 @@ abstract class Event extends Post {
/**
* Set the event category, via the mapping setting.
+ *
+ * @return ?string
*/
public function get_category(): ?string {
+ if ( is_null( $this->wp_taxonomy ) ) {
+ return null;
+ }
$current_category_mapping = \get_option( 'activitypub_event_extensions_event_category_mappings', array() );
$terms = \get_the_terms( $this->wp_object, $this->wp_taxonomy );
@@ -126,8 +135,8 @@ abstract class Event extends Post {
*
* @return ?string
*/
- protected function extract_excerpt(): ?string {
- if ( $this->wp_object->excerpt ) {
+ protected function retrieve_excerpt(): ?string {
+ if ( $this->wp_object->post_excerpt ) {
return $this->wp_object->post_excerpt;
} else {
return null;
@@ -161,11 +170,24 @@ abstract class Event extends Post {
/**
* Compose a human readable formatted start time.
- *
- * @param bool $is_start_time Whether format the events start or end time.
*/
- protected function format_time( $is_start_time = true ) {
- $time = $is_start_time ? $this->get_start_time() : $this->get_end_time();
+ protected function format_start_time(): string {
+ return $this->format_time( $this->get_start_time() );
+ }
+
+ /**
+ * Compose a human readable formatted end time.
+ */
+ protected function format_end_time(): string {
+ return $this->format_time( $this->get_end_time() );
+ }
+
+ /**
+ * Compose a human readable formatted time.
+ *
+ * @param ?string $time The time which needs to be formatted.
+ */
+ private static function format_time( $time ) {
if ( is_null( $time ) ) {
return '';
}
@@ -199,14 +221,31 @@ abstract class Event extends Post {
/**
* Format the category using the translation.
*/
- protected function format_category(): string {
- require_once ACTIVITYPUB_EVENT_EXTENSIONS_PLUGIN_DIR . '/includes/event-categories.php';
- $category = $this->get_category();
- if ( array_key_exists( $category, ACTIVITYPUB_EVENT_EXTENSIONS_EVENT_CATEGORIES ) ) {
- return ACTIVITYPUB_EVENT_EXTENSIONS_EVENT_CATEGORIES[ $category ];
- } else {
- return ACTIVITYPUB_EVENT_EXTENSIONS_EVENT_CATEGORIES['MEETING'];
+ protected function format_categories(): string {
+ if ( is_null( $this->wp_taxonomy ) ) {
+ return '';
}
+ $categories = array();
+
+ // Add the federated category string.
+ require_once ACTIVITYPUB_EVENT_EXTENSIONS_PLUGIN_DIR . '/includes/event-categories.php';
+ $federated_category = $this->get_category();
+ if ( array_key_exists( $federated_category, ACTIVITYPUB_EVENT_EXTENSIONS_EVENT_CATEGORIES ) ) {
+ $categories[] = ACTIVITYPUB_EVENT_EXTENSIONS_EVENT_CATEGORIES[ $federated_category ];
+ }
+
+ // Add all category terms.
+ $terms = \get_the_terms( $this->wp_object, $this->wp_taxonomy );
+ if ( $terms && ! is_wp_error( $terms ) ) {
+ foreach ( $terms as $term ) {
+ $categories[] = $term->name;
+ }
+ }
+
+ if ( ! empty( $categories ) ) {
+ return implode( ' ยท ', array_unique( $categories ) );
+ }
+ return '';
}
/**
@@ -218,36 +257,37 @@ abstract class Event extends Post {
* @return string $summary The custom event summary.
*/
public function get_summary(): ?string {
- add_filter( 'activitypub_object_content_template', array( self::class, 'remove_ap_permalink_from_template' ), 2 );
- $excerpt = $this->extract_excerpt();
+ add_filter( 'activitypub_object_content_template', array( self::class, 'remove_ap_permalink_from_template' ), 2, 2 );
+ $excerpt = $this->retrieve_excerpt();
// BeforeFirstRelease: decide whether this should be a admin setting.
$fallback_to_content = true;
if ( is_null( $excerpt ) && $fallback_to_content ) {
- $excerpt = $this->get_content();
+ $excerpt = parent::get_content();
}
remove_filter( 'activitypub_object_content_template', array( self::class, 'remove_ap_permalink_from_template' ) );
- $category = $this->format_category();
- $start_time = $this->format_time();
- $end_time = $this->format_time( false );
+ $category = $this->format_categories();
+ $start_time = $this->format_start_time();
+ $end_time = $this->format_end_time();
$address = $this->format_address();
$formatted_items = array();
if ( ! empty( $category ) ) {
- $formatted_items[] = "๐ท๏ธ $category";
+ $formatted_items[] = '๐ท๏ธ ' . __( 'Category', 'activitypub-event-extensions' ) . ': ' . $category;
}
if ( ! empty( $start_time ) ) {
- $formatted_items[] = "๐๏ธ {$start_time}";
+ $formatted_items[] = '๐๏ธ ' . __( 'Start', 'activitypub-event-extensions' ) . ': ' . $start_time;
}
if ( ! empty( $end_time ) ) {
- $formatted_items[] = "โณ {$end_time}";
+ $formatted_items[] = 'โณ ' . __( 'End', 'activitypub-event-extensions' ) . ': ' . $end_time;
}
if ( ! empty( $address ) ) {
- $formatted_items[] = "๐ {$address}";
+ $formatted_items[] = '๐ ' . __( 'Address', 'activitypub-event-extensions' ) . ': ' . $address;
}
+
// Compose the summary based on the number of meta items.
if ( count( $formatted_items ) > 1 ) {
$summary = '
- ' . implode( '
- ', $formatted_items ) . '
';
@@ -267,11 +307,17 @@ abstract class Event extends Post {
* This used for the summary template, because the summary usually gets,
* used when converting a object, where the URL is usually appended anyway.
*
- * @param string $template The template string.
+ * @param string $template The template string.
+ * @param WP_Post|WP_Comment $wp_object The wp_object which was used to select the template.
*/
- public static function remove_ap_permalink_from_template( $template ) {
- $template = str_replace( '[ap_permalink]', '', $template );
- $template = str_replace( '[ap_permalink type="html"]', '', $template );
+ public static function remove_ap_permalink_from_template( $template, $wp_object ) {
+
+ // we could override the template here, to get out custom template from an option.
+
+ if ( 'event' === $wp_object->post_type ) {
+ $template = str_replace( '[ap_permalink]', '', $template );
+ $template = str_replace( '[ap_permalink type="html"]', '', $template );
+ }
return $template;
}
@@ -285,6 +331,8 @@ abstract class Event extends Post {
$activitypub_object = new Event_Object();
$activitypub_object = $this->transform_object_properties( $activitypub_object );
+ // maybe move the following logic (till end of the function) into getter functions.
+
$published = \strtotime( $this->wp_object->post_date_gmt );
$activitypub_object->set_published( \gmdate( 'Y-m-d\TH:i:s\Z', $published ) );
@@ -304,7 +352,7 @@ abstract class Event extends Post {
$activitypub_object->set_to(
array(
'https://www.w3.org/ns/activitystreams#Public',
- $this->get_actor_object()->get_followers(),
+ $this->get_actor_object()->get_followers(), // this fails on my machine.
)
);
diff --git a/includes/activitypub/transformer/class-events-manager.php b/includes/activitypub/transformer/class-events-manager.php
index 8d7bfd6..a760d2e 100644
--- a/includes/activitypub/transformer/class-events-manager.php
+++ b/includes/activitypub/transformer/class-events-manager.php
@@ -37,42 +37,17 @@ final class Events_Manager extends Event_Transformer {
protected $em_event;
/**
- * Get transformer name.
+ * Extend the constructor, to also set the Eventsmanager objects.
*
- * Retrieve the transformers name.
+ * This is a special class object form The Events Calendar which
+ * has a lot of useful functions, we make use of our getter functions.
*
- * @since 1.0.0
- * @access public
- * @return string Widget name.
+ * @param WP_Post $wp_object The WordPress object.
+ * @param string $wp_taxonomy The taxonomy slug of the event post type.
*/
- public function get_transformer_name() {
- return 'activitypub-event-transformers/events-manager';
- }
-
- /**
- * Get transformer title.
- *
- * Retrieve the transformers label.
- *
- * @since 1.0.0
- * @access public
- * @return string Widget title.
- */
- public function get_transformer_label() {
- return 'Events Manager';
- }
-
- /**
- * Get supported post types.
- *
- * Retrieve the list of supported WordPress post types this transformer widget can handle.
- *
- * @since 1.0.0
- * @access public
- * @return array Widget categories.
- */
- public static function get_supported_post_types() {
- return array();
+ public function __construct( $wp_object, $wp_taxonomy ) {
+ parent::__construct( $wp_object, $wp_taxonomy );
+ $this->em_event = new EM_Event( $this->wp_object->ID, 'post_id' );
}
/**
@@ -114,9 +89,6 @@ final class Events_Manager extends Event_Transformer {
if ( $em_location->location_state ) {
$address['addressRegion'] = $em_location->location_state;
}
- if ( $em_location->location_postcode ) {
- $address['postalCode'] = $em_location->location_postcode;
- }
$location->set_address( $address );
return $location;
@@ -163,8 +135,8 @@ final class Events_Manager extends Event_Transformer {
* @return int
*/
public function get_remaining_attendee_capacity() {
- $em_bookings = $this->em_event->get_bookings()->get_bookings();
- $remaining_attendee_capacity = $this->em_event->event_spaces - count( $em_bookings->bookings );
+ $em_bookings_count = $this->get_participant_count();
+ $remaining_attendee_capacity = $this->em_event->event_spaces - $em_bookings_count;
return $remaining_attendee_capacity;
}
@@ -178,23 +150,6 @@ final class Events_Manager extends Event_Transformer {
return count( $em_bookings->bookings );
}
- /**
- * Hardcoded function for generating a summary.
- */
- public function get_summary(): ?string {
- if ( $this->em_event->post_excerpt ) {
- $excerpt = $this->em_event->post_excerpt;
- } else {
- $excerpt = $this->get_content();
- }
- $address = $this->em_event->get_location()->location_name;
- $start_time = strtotime( $this->get_start_time() );
- $datetime_format = get_option( 'date_format' ) . ' ' . get_option( 'time_format' );
- $start_time_string = wp_date( $datetime_format, $start_time );
- $summary = "๐ {$address}\n๐
{$start_time_string}\n\n{$excerpt}";
- return $summary;
- }
-
/**
* Get the event link as an ActivityPub Link object, but as an associative array.
*
@@ -260,20 +215,4 @@ final class Events_Manager extends Event_Transformer {
protected function get_name(): string {
return $this->em_event->event_name;
}
-
- /**
- * Transform the WordPress Object into an ActivityPub Object.
- *
- * @return Activitypub\Activity\Event
- */
- public function to_object(): Event {
- $this->em_event = new EM_Event( $this->wp_object->ID, 'post_id' );
- $activitypub_object = new Event();
-
- $activitypub_object = $this->transform_object_properties( $activitypub_object );
-
- $activitypub_object->set_external_participation_url( $this->get_url() );
-
- return $activitypub_object;
- }
}
diff --git a/includes/activitypub/transformer/class-gatherpress.php b/includes/activitypub/transformer/class-gatherpress.php
index 81f2f22..bfe1e92 100644
--- a/includes/activitypub/transformer/class-gatherpress.php
+++ b/includes/activitypub/transformer/class-gatherpress.php
@@ -24,13 +24,6 @@ use GatherPress\Core\Event as GatherPress_Event;
*/
final class GatherPress extends Event {
- /**
- * The target ActivityPub Event object of the transformer.
- *
- * @var Event
- */
- protected $ap_object;
-
/**
* The current GatherPress Event object.
*
@@ -60,19 +53,6 @@ final class GatherPress extends Event {
$this->gp_venue = $this->gp_event->get_venue_information();
}
- /**
- * Get supported post types.
- *
- * Retrieve the list of supported WordPress post types this transformer widget can handle.
- *
- * @since 1.0.0
- * @access public
- * @return array Widget categories.
- */
- public static function get_supported_post_types() {
- return array( GatherPress_Event::POST_TYPE );
- }
-
/**
* Get the event location.
*
@@ -138,47 +118,30 @@ final class GatherPress extends Event {
}
/**
- * Returns the User-URL of the Author of the Post.
+ * Prevents gatherpress blocks from being rendered for the content.
*
- * If `single_user` mode is enabled, the URL of the Blog-User is returned.
- *
- * @return string The User-URL.
+ * @param mixed $block_content The blocks content.
+ * @param mixed $block The block.
*/
- protected function get_attributed_to(): string {
- $user = new Blog();
- return $user->get_url();
- }
-
- /**
- * Create a custom summary.
- *
- * It contains also the most important meta-information. The summary is often used when the
- * ActivityPub object type 'Event' is not supported, e.g. in Mastodon.
- *
- * @return string $summary The custom event summary.
- */
- public function get_summary(): string {
- if ( $this->wp_object->excerpt ) {
- $excerpt = $this->wp_object->post_excerpt;
- } elseif ( get_post_meta( $this->wp_object->ID, 'event-summary', true ) ) {
- $excerpt = get_post_meta( $this->wp_object->ID, 'event-summary', true );
- } else {
- $excerpt = $this->get_content();
+ public static function filter_gatherpress_blocks( $block_content, $block ) {
+ // Check if the block name starts with 'gatherpress'.
+ if ( strpos( $block['blockName'], 'gatherpress/' ) === 0 ) {
+ return ''; // Skip rendering this block.
}
- $address = get_post_meta( $this->wp_object->ID, 'event-location', true );
- $start_time = get_post_meta( $this->wp_object->ID, 'event-start-date', true );
- $datetime_format = get_option( 'date_format' ) . ' ' . get_option( 'time_format' );
- $start_time_string = wp_date( $datetime_format, $start_time );
- $summary = "๐ {$address}\n๐
{$start_time_string}\n\n{$excerpt}";
- return $summary;
+ return $block_content; // Return the content for other blocks.
}
/**
- * Get the content.
+ * Apply the filter for preventing the rendering off gatherpress blocks just in time.
+ *
+ * @return Event_Object
*/
- public function get_content(): string {
- return $this->wp_object->post_content;
+ public function to_object(): Event_Object {
+ add_filter( 'render_block', array( self::class, 'filter_gatherpress_blocks' ), 10, 2 );
+ $activitypub_object = parent::to_object();
+ remove_filter( 'render_block', array( self::class, 'filter_gatherpress_blocks' ) );
+ return $activitypub_object;
}
/**
@@ -189,16 +152,4 @@ final class GatherPress extends Event {
public function get_is_online(): bool {
return $this->gp_event->maybe_get_online_event_link() ? true : false;
}
-
-
- /**
- * Transform the WordPress Object into an ActivityPub Object.
- *
- * @return Activitypub\Activity\Event
- */
- public function to_object(): Event_Object {
- $activitypub_object = parent::to_object();
-
- return $activitypub_object;
- }
}
diff --git a/includes/activitypub/transformer/class-the-events-calendar.php b/includes/activitypub/transformer/class-the-events-calendar.php
index eea12ac..0e78522 100644
--- a/includes/activitypub/transformer/class-the-events-calendar.php
+++ b/includes/activitypub/transformer/class-the-events-calendar.php
@@ -65,7 +65,7 @@ final class The_Events_Calendar extends Event {
$tags[] = $tag;
}
}
- $tags[] = parent::get_tag();
+ $tags = array_merge( $tags, parent::get_tag() );
return $tags;
}
@@ -119,23 +119,6 @@ final class The_Events_Calendar extends Event {
return false;
}
- /**
- * Returns the content for the ActivityPub Item with
- *
- * The content will be generated based on the user settings.
- *
- * @return string The content.
- */
- protected function get_content() {
- $content = parent::get_content();
- // /BeforeFirstRelease:
- // * remove link at the end of the content.
- // * add organizer.
- // * do add Cancelled reason in the content.s
-
- return $content;
- }
-
/**
* Get the event location.
*
@@ -196,17 +179,4 @@ final class The_Events_Calendar extends Event {
return $location;
}
-
- /**
- * Extend the default event transformers to_object function.
- *
- * This is the heart of the ActivityPub transformer.
- *
- * @return Event_Object
- */
- public function to_object(): Event_Object {
- $activitypub_object = parent::to_object();
-
- return $activitypub_object;
- }
}
diff --git a/includes/activitypub/transformer/class-vs-event-list.php b/includes/activitypub/transformer/class-vs-event-list.php
index aef6470..dc0ae7b 100644
--- a/includes/activitypub/transformer/class-vs-event-list.php
+++ b/includes/activitypub/transformer/class-vs-event-list.php
@@ -23,12 +23,6 @@ use Activitypub_Event_Extensions\Activitypub\Transformer\Event as Event_Transfor
* @since 1.0.0
*/
final class VS_Event_List extends Event_Transformer {
- /**
- * The target transformer ActivityPub Event object.
- *
- * @var Event
- */
- protected $ap_object;
/**
* Get the event location.
@@ -110,13 +104,11 @@ final class VS_Event_List extends Event_Transformer {
*
* @return ?string
*/
- protected function get_excerpt(): ?string {
+ protected function retrieve_excerpt(): ?string {
if ( get_post_meta( $this->wp_object->ID, 'event-summary', true ) ) {
return get_post_meta( $this->wp_object->ID, 'event-summary', true );
- } elseif ( $this->wp_object->excerpt ) {
- return $this->wp_object->post_excerpt;
} else {
- return null;
+ return parent::retrieve_excerpt();
}
}
}
diff --git a/includes/class-setup.php b/includes/class-setup.php
index 67877fb..a02076c 100644
--- a/includes/class-setup.php
+++ b/includes/class-setup.php
@@ -272,6 +272,7 @@ class Setup {
foreach ( $this->active_event_plugins as $event_plugin ) {
if ( ! in_array( $event_plugin->get_post_type(), $activitypub_supported_post_types, true ) ) {
$activitypub_supported_post_types[] = $event_plugin->get_post_type();
+ add_post_type_support( $event_plugin->get_post_type(), 'activitypub' );
}
}
update_option( 'activitypub_support_post_types', $activitypub_supported_post_types );
diff --git a/tests/test-class-plugin-events-manger.php b/tests/test-class-plugin-events-manger.php
index cf4bc46..3d3c7d2 100644
--- a/tests/test-class-plugin-events-manger.php
+++ b/tests/test-class-plugin-events-manger.php
@@ -47,7 +47,7 @@ class Test_Events_Manager extends WP_UnitTestCase {
$wp_post_id = wp_insert_post(
array(
'post_title' => 'Events Manager Test event',
- 'post_status' => 'published',
+ 'post_status' => 'publish',
'post_type' => EM_POST_TYPE_EVENT,
'meta_input' => array(
'event_start_time' => strtotime( '+10 days 15:00:00' ),
@@ -75,7 +75,7 @@ class Test_Events_Manager extends WP_UnitTestCase {
$event->event_start_date = gmdate( 'Y-m-d', strtotime( '+10 days 15:00:00' ) );
$event->event_start_time = '15:00:00';
$event->start = strtotime( $event->event_start_date . ' ' . $event->event_start_time );
- $event->force_status = 'published';
+ $event->force_status = 'publish';
$event->event_rsvp = false;
$this->assertTrue( $event->save() );
@@ -85,7 +85,7 @@ class Test_Events_Manager extends WP_UnitTestCase {
// Check that we got the right transformer.
$this->assertEquals( 'Event', $event_array['type'] );
$this->assertEquals( 'Events Manager Test event', $event_array['name'] );
- $this->assertEquals( '', $event_array['content'] );
+ $this->assertEquals( 'Event description', wp_strip_all_tags( $event_array['content'] ) );
$this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 15:00:00' ) ) . 'T15:00:00Z', $event_array['startTime'] );
$this->assertEquals( comments_open( $event->post_id ), $event_array['commentsEnabled'] );
$this->assertEquals( comments_open( $event->post_id ) ? 'allow_all' : 'closed', $event_array['repliesModerationOption'] );
@@ -121,7 +121,7 @@ class Test_Events_Manager extends WP_UnitTestCase {
$event->event_end_time = '16:00:00';
$event->start = strtotime( $event->event_start_date . ' ' . $event->event_start_time );
$event->end = strtotime( $event->event_end_date . ' ' . $event->event_end_time );
- $event->force_status = 'published';
+ $event->force_status = 'publish';
$event->event_rsvp = false;
$this->assertTrue( $event->save() );
@@ -131,7 +131,7 @@ class Test_Events_Manager extends WP_UnitTestCase {
// Check that we got the right transformer.
$this->assertEquals( 'Event', $event_array['type'] );
$this->assertEquals( 'Events Manager Test event', $event_array['name'] );
- $this->assertEquals( '', $event_array['content'] );
+ $this->assertEquals( 'Event description', wp_strip_all_tags( $event_array['content'] ) );
$this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 15:00:00' ) ) . 'T15:00:00Z', $event_array['startTime'] );
$this->assertEquals( 'external', $event_array['joinMode'] );
$this->assertEquals( 'MEETING', $event_array['category'] );
@@ -164,7 +164,7 @@ class Test_Events_Manager extends WP_UnitTestCase {
$event->event_end_time = '16:00:00';
$event->start = strtotime( $event->event_start_date . ' ' . $event->event_start_time );
$event->end = strtotime( $event->event_end_date . ' ' . $event->event_end_time );
- $event->force_status = 'published';
+ $event->force_status = 'publish';
$event->event_rsvp = false;
$this->assertTrue( $event->save() );
@@ -174,7 +174,7 @@ class Test_Events_Manager extends WP_UnitTestCase {
// Check that we got the right transformer.
$this->assertEquals( 'Event', $event_array['type'] );
$this->assertEquals( 'Events Manager Test event', $event_array['name'] );
- $this->assertEquals( '', $event_array['content'] );
+ $this->assertEquals( 'Event description', wp_strip_all_tags( $event_array['content'] ) );
$this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 15:00:00' ) ) . 'T15:00:00Z', $event_array['startTime'] );
$this->assertEquals( 'external', $event_array['joinMode'] );
$this->assertEquals( 'MEETING', $event_array['category'] );
diff --git a/tests/test-class-plugin-gatherpress.php b/tests/test-class-plugin-gatherpress.php
index 504dc9c..b2ac3eb 100644
--- a/tests/test-class-plugin-gatherpress.php
+++ b/tests/test-class-plugin-gatherpress.php
@@ -49,6 +49,7 @@ class Test_GatherPress extends WP_UnitTestCase {
'post_title' => 'Unit Test Event',
'post_type' => 'gatherpress_event',
'post_content' => 'Unit Test description.',
+ 'post_status' => 'publish',
)
);
$event = new \GatherPress\Core\Event( $post_id );
@@ -77,7 +78,7 @@ class Test_GatherPress extends WP_UnitTestCase {
'post_title' => 'Unit Test Event',
'post_type' => 'gatherpress_event',
'post_content' => 'Unit Test description.',
- 'post_status' => 'published',
+ 'post_status' => 'publish',
)
);
$event = new \GatherPress\Core\Event( $post_id );
@@ -94,7 +95,7 @@ class Test_GatherPress extends WP_UnitTestCase {
// Check that the event ActivityStreams representation contains everything as expected.
$this->assertEquals( 'Event', $event_array['type'] );
$this->assertEquals( 'Unit Test Event', $event_array['name'] );
- $this->assertEquals( 'Unit Test description.', $event_array['content'] );
+ $this->assertEquals( 'Unit Test description.', wp_strip_all_tags( $event_array['content'] ) );
$this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 15:00:00' ) ) . 'T15:00:00Z', $event_array['startTime'] );
$this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 16:00:00' ) ) . 'T16:00:00Z', $event_array['endTime'] );
$this->assertEquals( 'external', $event_array['joinMode'] );
diff --git a/tests/test-class-plugin-the-events-calendar.php b/tests/test-class-plugin-the-events-calendar.php
index c4f5f6d..fd589f7 100644
--- a/tests/test-class-plugin-the-events-calendar.php
+++ b/tests/test-class-plugin-the-events-calendar.php
@@ -37,14 +37,14 @@ class Test_The_Events_Calendar extends WP_UnitTestCase {
public const MOCKUP_EVENTS = array(
'minimal_event' => array(
'title' => 'My Event',
- 'content' => 'Come to my event. Let\'s connect!',
+ 'content' => 'Come to my event!',
'start_date' => '+10 days 15:00:00',
'duration' => HOUR_IN_SECONDS,
'status' => 'publish',
),
'complex_event' => array(
'title' => 'My Event',
- 'content' => 'Come to my event. Let\'s connect!',
+ 'content' => 'Come to my event!',
'start_date' => '+10 days 15:00:00',
'duration' => HOUR_IN_SECONDS,
'status' => 'publish',
@@ -109,7 +109,7 @@ class Test_The_Events_Calendar extends WP_UnitTestCase {
// Check that the event ActivityStreams representation contains everything as expected.
$this->assertEquals( 'Event', $event_array['type'] );
$this->assertEquals( 'My Event', $event_array['name'] );
- $this->assertEquals( '', $event_array['content'] );
+ $this->assertEquals( 'Come to my event!', wp_strip_all_tags( $event_array['content'] ) );
$this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 15:00:00' ) ) . 'T15:00:00Z', $event_array['startTime'] );
$this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 16:00:00' ) ) . 'T16:00:00Z', $event_array['endTime'] );
$this->assertTrue( $event_array['commentsEnabled'] );
@@ -170,7 +170,7 @@ class Test_The_Events_Calendar extends WP_UnitTestCase {
// Check that the event ActivityStreams representation contains everything as expected.
$this->assertEquals( 'Event', $event_array['type'] );
$this->assertEquals( 'My Event', $event_array['name'] );
- $this->assertEquals( '', $event_array['content'] );
+ $this->assertEquals( 'Come to my event!', wp_strip_all_tags( $event_array['content'] ) );
$this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 15:00:00' ) ) . 'T15:00:00Z', $event_array['startTime'] );
$this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 16:00:00' ) ) . 'T16:00:00Z', $event_array['endTime'] );
$this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 16:00:00' ) ) . 'T16:00:00Z', $event_array['commentsEnabled'] );
@@ -197,7 +197,7 @@ class Test_The_Events_Calendar extends WP_UnitTestCase {
// Check that the event ActivityStreams representation contains everything as expected.
$this->assertEquals( 'Event', $event_array['type'] );
$this->assertEquals( 'My Event', $event_array['name'] );
- $this->assertEquals( '', $event_array['content'] );
+ $this->assertEquals( 'Come to my event!', wp_strip_all_tags( $event_array['content'] ) );
$this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 15:00:00' ) ) . 'T15:00:00Z', $event_array['startTime'] );
$this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 16:00:00' ) ) . 'T16:00:00Z', $event_array['endTime'] );
$this->assertEquals( gmdate( 'Y-m-d', strtotime( '+10 days 16:00:00' ) ) . 'T16:00:00Z', $event_array['commentsEnabled'] );