Compare commits

...

2 commits

Author SHA1 Message Date
e981827e0a basic tests for event organiser
Some checks failed
PHP Code Checker / PHP Code Checker (pull_request) Failing after 51s
PHPUnit / PHPUnit – PHP 7.4 (pull_request) Failing after 1m3s
PHPUnit / PHPUnit – PHP 8.1 (pull_request) Has been cancelled
PHPUnit / PHPUnit – PHP 8.2 (pull_request) Has been cancelled
PHPUnit / PHPUnit – PHP 8.3 (pull_request) Has been cancelled
PHPUnit / PHPUnit – PHP 8.0 (pull_request) Has been cancelled
2024-11-30 11:20:31 +01:00
9356476901 fix test initialization 2024-11-28 22:05:15 +01:00
3 changed files with 30 additions and 6 deletions

View file

@ -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 );
}
/**

View file

@ -74,7 +74,7 @@ function _manually_load_plugin() {
case 'eventprime':
$plugin_file = 'eventprime-event-calendar-management/event-prime.php';
break;
case 'event-organiser':
case 'event_organiser':
$plugin_file = 'event-organiser/event-organiser.php';
break;
}
@ -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.

View file

@ -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 );