wip
All checks were successful
PHP Code Checker / PHP Code Checker (pull_request) Successful in 49s
PHPUnit / PHPUnit – PHP 7.4 (pull_request) Successful in 1m29s
PHPUnit / PHPUnit – PHP 8.0 (pull_request) Successful in 1m2s
PHPUnit / PHPUnit – PHP 8.1 (pull_request) Successful in 1m9s
PHPUnit / PHPUnit – PHP 8.2 (pull_request) Successful in 1m3s
PHPUnit / PHPUnit – PHP 8.3 (pull_request) Successful in 57s
All checks were successful
PHP Code Checker / PHP Code Checker (pull_request) Successful in 49s
PHPUnit / PHPUnit – PHP 7.4 (pull_request) Successful in 1m29s
PHPUnit / PHPUnit – PHP 8.0 (pull_request) Successful in 1m2s
PHPUnit / PHPUnit – PHP 8.1 (pull_request) Successful in 1m9s
PHPUnit / PHPUnit – PHP 8.2 (pull_request) Successful in 1m3s
PHPUnit / PHPUnit – PHP 8.3 (pull_request) Successful in 57s
This commit is contained in:
parent
d625750a7e
commit
b7be4fc028
8 changed files with 270 additions and 4 deletions
|
@ -38,7 +38,7 @@ jobs:
|
||||||
path: |
|
path: |
|
||||||
${{ env.WP_CORE_DIR }}
|
${{ env.WP_CORE_DIR }}
|
||||||
${{ env.WP_TESTS_DIR }}
|
${{ env.WP_TESTS_DIR }}
|
||||||
key: cache-wordpress-67-3
|
key: cache-wordpress-67-4
|
||||||
|
|
||||||
- name: Cache Composer
|
- name: Cache Composer
|
||||||
id: cache-composer-phpunit
|
id: cache-composer-phpunit
|
||||||
|
@ -114,3 +114,8 @@ jobs:
|
||||||
run: cd /workspace/Event-Federation/wordpress-activitypub-event-bridge/ && ./vendor/bin/phpunit --filter=eventprime
|
run: cd /workspace/Event-Federation/wordpress-activitypub-event-bridge/ && ./vendor/bin/phpunit --filter=eventprime
|
||||||
env:
|
env:
|
||||||
PHP_VERSION: ${{ matrix.php-version }}
|
PHP_VERSION: ${{ matrix.php-version }}
|
||||||
|
|
||||||
|
- name: Run Integration tests for Event Organiser
|
||||||
|
run: cd /workspace/Event-Federation/wordpress-activitypub-event-bridge/ && ./vendor/bin/phpunit --filter=event_organiser
|
||||||
|
env:
|
||||||
|
PHP_VERSION: ${{ matrix.php-version }}
|
||||||
|
|
|
@ -261,6 +261,7 @@ install_wp_plugins() {
|
||||||
install_wp_plugin events-manager "6.6.3"
|
install_wp_plugin events-manager "6.6.3"
|
||||||
install_wp_plugin wp-event-manager "3.1.45.1"
|
install_wp_plugin wp-event-manager "3.1.45.1"
|
||||||
install_wp_plugin wp-event-solution "4.0.14"
|
install_wp_plugin wp-event-solution "4.0.14"
|
||||||
|
install_wp_plugin event-organiser "3.12.8"
|
||||||
# Mec is not installable via wordpress.org, we use our own mirror.
|
# Mec is not installable via wordpress.org, we use our own mirror.
|
||||||
install_wp_plugin_mec
|
install_wp_plugin_mec
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,11 +55,12 @@
|
||||||
"@test-wp-event-manager",
|
"@test-wp-event-manager",
|
||||||
"@test-eventin",
|
"@test-eventin",
|
||||||
"@test-modern-events-calendar-lite",
|
"@test-modern-events-calendar-lite",
|
||||||
"@test-eventprime"
|
"@test-eventprime",
|
||||||
|
"@test-event-organiser"
|
||||||
],
|
],
|
||||||
"test-debug": [
|
"test-debug": [
|
||||||
"@prepare-test",
|
"@prepare-test",
|
||||||
"@test-eventprime"
|
"@test-event-organiser"
|
||||||
],
|
],
|
||||||
"test-vs-event-list": "phpunit --filter=vs_event_list",
|
"test-vs-event-list": "phpunit --filter=vs_event_list",
|
||||||
"test-the-events-calendar": "phpunit --filter=the_events_calendar",
|
"test-the-events-calendar": "phpunit --filter=the_events_calendar",
|
||||||
|
@ -69,6 +70,7 @@
|
||||||
"test-eventin": "phpunit --filter=eventin",
|
"test-eventin": "phpunit --filter=eventin",
|
||||||
"test-modern-events-calendar-lite": "phpunit --filter=modern_events_calendar_lite",
|
"test-modern-events-calendar-lite": "phpunit --filter=modern_events_calendar_lite",
|
||||||
"test-eventprime": "phpunit --filter=eventprime",
|
"test-eventprime": "phpunit --filter=eventprime",
|
||||||
|
"test-event-organiser": "phpunit --filter=event_organiser",
|
||||||
"test-all": "phpunit"
|
"test-all": "phpunit"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
76
includes/activitypub/transformer/class-event-organiser.php
Normal file
76
includes/activitypub/transformer/class-event-organiser.php
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* ActivityPub Transformer for the plugin Event Organiser.
|
||||||
|
*
|
||||||
|
* @package ActivityPub_Event_Bridge
|
||||||
|
* @license AGPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace ActivityPub_Event_Bridge\Activitypub\Transformer;
|
||||||
|
|
||||||
|
// Exit if accessed directly.
|
||||||
|
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||||
|
|
||||||
|
use Activitypub\Activity\Extended_Object\Place;
|
||||||
|
use ActivityPub_Event_Bridge\Activitypub\Transformer\Event;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ActivityPub Transformer for Event Organiser.
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
final class Event_Organiser extends Event {
|
||||||
|
/**
|
||||||
|
* 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 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get location from the event object.
|
||||||
|
*/
|
||||||
|
protected function get_location(): ?Place {
|
||||||
|
$venue_id = eo_get_venue( $this->wp_object->ID );
|
||||||
|
|
||||||
|
if ( ! $venue_id ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$address = eo_get_venue_address( $venue_id );
|
||||||
|
|
||||||
|
$address['name'] = eo_get_venue_name( $this->wp_object->ID );
|
||||||
|
|
||||||
|
$address['streetAddress'] = $address['address'];
|
||||||
|
unset( $address['address'] );
|
||||||
|
|
||||||
|
$address['postalCode'] = $address['postcode'];
|
||||||
|
unset( $address['postcode'] );
|
||||||
|
|
||||||
|
$address['addressRegion'] = $address['state'];
|
||||||
|
unset( $address['state'] );
|
||||||
|
|
||||||
|
$address['addressLocality'] = $address['city'];
|
||||||
|
unset( $address['city'] );
|
||||||
|
|
||||||
|
$address['addressCountry'] = $address['country'];
|
||||||
|
unset( $address['country'] );
|
||||||
|
|
||||||
|
$address['type'] = 'PostalAddress';
|
||||||
|
|
||||||
|
$location = new Place();
|
||||||
|
$location->set_name( eo_get_venue_name( $this->wp_object->ID ) );
|
||||||
|
$location->set_latitude( eo_get_venue_lat( $this->wp_object->ID ) );
|
||||||
|
$location->set_longitude( eo_get_venue_lng( $this->wp_object->ID ) );
|
||||||
|
$location->set_address( $address );
|
||||||
|
|
||||||
|
return $address;
|
||||||
|
}
|
||||||
|
}
|
|
@ -133,6 +133,7 @@ class Setup {
|
||||||
'\ActivityPub_Event_Bridge\Plugins\Eventin',
|
'\ActivityPub_Event_Bridge\Plugins\Eventin',
|
||||||
'\ActivityPub_Event_Bridge\Plugins\Modern_Events_Calendar_Lite',
|
'\ActivityPub_Event_Bridge\Plugins\Modern_Events_Calendar_Lite',
|
||||||
'\ActivityPub_Event_Bridge\Plugins\EventPrime',
|
'\ActivityPub_Event_Bridge\Plugins\EventPrime',
|
||||||
|
'\ActivityPub_Event_Bridge\Plugins\Event_Organiser',
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
69
includes/plugins/class-event-organiser.php
Normal file
69
includes/plugins/class-event-organiser.php
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Event Organiser.
|
||||||
|
*
|
||||||
|
* Defines all the necessary meta information for the Event Organiser plugin.
|
||||||
|
*
|
||||||
|
* @link https://wordpress.org/plugins/event-organiser/
|
||||||
|
* @package ActivityPub_Event_Bridge
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace ActivityPub_Event_Bridge\Plugins;
|
||||||
|
|
||||||
|
// Exit if accessed directly.
|
||||||
|
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for a supported event plugin.
|
||||||
|
*
|
||||||
|
* This interface defines which information is necessary for a supported event plugin.
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
final class Event_Organiser extends Event_Plugin {
|
||||||
|
/**
|
||||||
|
* Returns the full plugin file.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function get_plugin_file(): string {
|
||||||
|
return 'event-organiser/event-organiser.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the event post type of the plugin.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function get_post_type(): string {
|
||||||
|
return 'event';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the IDs of the admin pages of the plugin.
|
||||||
|
*
|
||||||
|
* @return array The settings page urls.
|
||||||
|
*/
|
||||||
|
public static function get_settings_pages(): array {
|
||||||
|
return array( 'event-organiser' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the ActivityPub transformer class.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function get_activitypub_transformer_class_name(): string {
|
||||||
|
return 'Event_Organiser';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the taxonomy used for the plugin's event categories.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function get_event_category_taxonomy(): string {
|
||||||
|
return 'event-category';
|
||||||
|
}
|
||||||
|
}
|
|
@ -74,6 +74,9 @@ function _manually_load_plugin() {
|
||||||
case 'eventprime':
|
case 'eventprime':
|
||||||
$plugin_file = 'eventprime-event-calendar-management/event-prime.php';
|
$plugin_file = 'eventprime-event-calendar-management/event-prime.php';
|
||||||
break;
|
break;
|
||||||
|
case 'event-organiser':
|
||||||
|
$plugin_file = 'event-organiser/event-organiser.php';
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $plugin_file ) {
|
if ( $plugin_file ) {
|
||||||
|
@ -100,6 +103,11 @@ function _manually_load_plugin() {
|
||||||
$mec_factory->install();
|
$mec_factory->install();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( 'event-organiser' === $activitypub_event_bridge_integration_filter ) {
|
||||||
|
require_once $plugin_dir . 'event-organiser/includes/event-organiser-install.php';
|
||||||
|
eventorganiser_install();
|
||||||
|
}
|
||||||
|
|
||||||
// At last manually load our WordPress plugin.
|
// At last manually load our WordPress plugin.
|
||||||
require dirname( __DIR__ ) . '/activitypub-event-bridge.php';
|
require dirname( __DIR__ ) . '/activitypub-event-bridge.php';
|
||||||
}
|
}
|
||||||
|
|
104
tests/test-class-plugin-event-organiser.php
Normal file
104
tests/test-class-plugin-event-organiser.php
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Test class for the integration of the Event Organiser.
|
||||||
|
*
|
||||||
|
* @package ActivityPub_Event_Bridge
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sample test case.
|
||||||
|
*/
|
||||||
|
class Test_Event_Organiser extends WP_UnitTestCase {
|
||||||
|
/**
|
||||||
|
* 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( 'eo_get_events' ) ) {
|
||||||
|
self::markTestSkipped( 'Event Organiser plugin is not active.' );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mock the plugin activation.
|
||||||
|
GatherPress\Core\Setup::get_instance()->activate_gatherpress_plugin( false );
|
||||||
|
|
||||||
|
// 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( 'gatherpress_event', get_option( 'activitypub_support_post_types' ) );
|
||||||
|
|
||||||
|
// Mock GatherPress Event.
|
||||||
|
$post_id = wp_insert_post(
|
||||||
|
array(
|
||||||
|
'post_title' => 'Unit Test Event',
|
||||||
|
'post_type' => 'gatherpress_event',
|
||||||
|
'post_content' => 'Unit Test description.',
|
||||||
|
'post_status' => 'publish',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$event = new \GatherPress\Core\Event( $post_id );
|
||||||
|
$params = array(
|
||||||
|
'datetime_start' => '+10 days 15:00:00',
|
||||||
|
'datetime_end' => '+10 days 16:00:00',
|
||||||
|
'timezone' => 'America/New_York',
|
||||||
|
);
|
||||||
|
|
||||||
|
$event->save_datetimes( $params );
|
||||||
|
|
||||||
|
// Call the transformer Factory.
|
||||||
|
$transformer = \Activitypub\Transformer\Factory::get_transformer( $event->event );
|
||||||
|
|
||||||
|
// Check that we got the right transformer.
|
||||||
|
$this->assertInstanceOf( \ActivityPub_Event_Bridge\Activitypub\Transformer\GatherPress::class, $transformer );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test transformation to ActivityPUb for basic event.
|
||||||
|
*/
|
||||||
|
public function test_transform_of_basic_event() {
|
||||||
|
// Mock GatherPress Event.
|
||||||
|
$post_id = wp_insert_post(
|
||||||
|
array(
|
||||||
|
'post_title' => 'Unit Test Event',
|
||||||
|
'post_type' => 'gatherpress_event',
|
||||||
|
'post_content' => 'Unit Test description.',
|
||||||
|
'post_status' => 'publish',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$event = new \GatherPress\Core\Event( $post_id );
|
||||||
|
$params = array(
|
||||||
|
'datetime_start' => '+10 days 15:00:00',
|
||||||
|
'datetime_end' => '+10 days 16:00:00',
|
||||||
|
'timezone' => 'America/New_York',
|
||||||
|
);
|
||||||
|
$event->save_datetimes( $params );
|
||||||
|
|
||||||
|
// Call the transformer Factory.
|
||||||
|
$event_array = \Activitypub\Transformer\Factory::get_transformer( $event->event )->to_object()->to_array();
|
||||||
|
|
||||||
|
// 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.', 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'] );
|
||||||
|
$this->assertArrayNotHasKey( 'location', $event_array );
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue