fix test bootstrap
Some checks failed
PHP Code Checker / PHP Code Checker (pull_request) Failing after 44s
PHPUnit / PHPUnit – PHP 7.4 (pull_request) Failing after 55s
PHPUnit / PHPUnit – PHP 8.0 (pull_request) Failing after 51s
PHPUnit / PHPUnit – PHP 8.1 (pull_request) Failing after 52s
PHPUnit / PHPUnit – PHP 8.3 (pull_request) Has been cancelled
PHPUnit / PHPUnit – PHP 8.4 (pull_request) Has been cancelled
PHPUnit / PHPUnit – PHP 8.2 (pull_request) Has been cancelled

This commit is contained in:
André Menrath 2024-12-21 11:31:57 +01:00
parent ba222a4a9a
commit d5c14ae03a
5 changed files with 34 additions and 10 deletions

View file

@ -40,6 +40,28 @@ class The_Events_Calendar extends Base {
return $results;
}
/**
* Add venue.
*
* @param int $post_id The post ID.
*/
private function add_venue( $post_id ) {
$location = $this->activitypub_event->get_location();
if ( ! $location ) {
return;
}
if ( ! isset( $location['name'] ) ) {
return;
}
// Fallback for Gancio instances.
if ( 'online' === $location['name'] ) {
return;
}
}
/**
* Save the ActivityPub event object as GatherPress Event.
*
@ -77,6 +99,8 @@ class The_Events_Calendar extends Base {
return false;
}
$this->add_venue( $post->ID );
// Limit this as a safety measure.
remove_filter( 'wp_revisions_to_keep', array( self::class, 'revisions_to_keep' ) );

View file

@ -104,16 +104,10 @@ function _manually_load_plugin() {
if ( $plugin_file ) {
_manually_load_event_plugin( $plugin_file );
} elseif ( 'event_sources' === $event_bridge_for_activitypub_integration_filter ) {
// For the Event Sources feature we currently only test with GatherPress.
_manually_load_event_plugin( 'gatherpress/gatherpress.php' );
\update_option( 'event_bridge_for_activitypub_event_sources_active', true );
\update_option( 'event_bridge_for_activitypub_integration_used_for_event_sources_feature', 'GatherPress' );
\update_option( 'activitypub_actor_mode', ACTIVITYPUB_BLOG_MODE );
} else {
// For all other tests we mainly use the Events Calendar as a reference.
// For all other tests we mainly use the Events Calendar and GatherPress as reference.
_manually_load_event_plugin( 'the-events-calendar/the-events-calendar.php' );
_manually_load_event_plugin( 'very-simple-event-list/vsel.php' );
_manually_load_event_plugin( 'gatherpress/gatherpress.php' );
}
// Hot fix that allows using Events Manager within unit tests, because the em_init() is later not run as admin.

View file

@ -40,7 +40,7 @@ class Test_GatherPress extends \WP_UnitTestCase {
// even though we support multiple onces in theory.
// But testing all combinations is beyond scope.
$active_event_plugins = \Event_Bridge_For_ActivityPub\Setup::get_instance()->get_active_event_plugins();
$this->assertEquals( 1, count( $active_event_plugins ) );
$this->assertArrayHasKey( 'gatherpress/gatherpress.php', $active_event_plugins );
// Enable ActivityPub support for the event plugin.
$this->assertContains( 'gatherpress_event', get_option( 'activitypub_support_post_types' ) );

View file

@ -79,7 +79,7 @@ class Test_The_Events_Calendar extends \WP_UnitTestCase {
// even though we support multiple onces in theory.
// But testing all combinations is beyond scope.
$active_event_plugins = \Event_Bridge_For_ActivityPub\Setup::get_instance()->get_active_event_plugins();
$this->assertEquals( 1, count( $active_event_plugins ) );
$this->assertArrayHasKey( 'the-events-calendar/the-events-calendar.php', $active_event_plugins );
// Enable ActivityPub support for the event plugin.
$this->assertContains( 'tribe_events', get_option( 'activitypub_support_post_types' ) );

View file

@ -61,6 +61,12 @@ class Test_Event_Sources extends \WP_UnitTestCase {
public function set_up() {
\add_option( 'permalink_structure', '/%postname%/' );
\update_option( 'event_bridge_for_activitypub_event_sources_active', true );
\update_option(
'event_bridge_for_activitypub_integration_used_for_event_sources_feature',
\Event_Bridge_For_ActivityPub\Integrations\GatherPress::class );
\update_option( 'activitypub_actor_mode', ACTIVITYPUB_BLOG_MODE );
global $wp_rest_server;
$wp_rest_server = new WP_REST_Server();
$this->server = $wp_rest_server;