fix test bootstrap
Some checks failed
PHP Code Checker / PHP Code Checker (pull_request) Successful in 43s
PHPUnit / PHPUnit – PHP 7.4 (pull_request) Failing after 54s
PHPUnit / PHPUnit – PHP 8.0 (pull_request) Failing after 51s
PHPUnit / PHPUnit – PHP 8.1 (pull_request) Failing after 52s
PHPUnit / PHPUnit – PHP 8.2 (pull_request) Failing after 54s
PHPUnit / PHPUnit – PHP 8.3 (pull_request) Failing after 54s
PHPUnit / PHPUnit – PHP 8.4 (pull_request) Failing after 50s

This commit is contained in:
André Menrath 2024-12-21 12:31:59 +01:00
parent d5c14ae03a
commit 26a2a6fce8
5 changed files with 58 additions and 19 deletions

View file

@ -61,7 +61,7 @@
], ],
"test-debug": [ "test-debug": [
"@prepare-test", "@prepare-test",
"@test-gatherpress" "@test-general"
], ],
"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",
@ -74,6 +74,6 @@
"test-event-organiser": "phpunit --filter=event_organiser", "test-event-organiser": "phpunit --filter=event_organiser",
"test-event-bridge-for-activitypub-shortcodes": "phpunit --filter=shortcodes", "test-event-bridge-for-activitypub-shortcodes": "phpunit --filter=shortcodes",
"test-event-sources": "phpunit --filter=event_sources", "test-event-sources": "phpunit --filter=event_sources",
"test-all": "phpunit" "test-general": "phpunit"
} }
} }

View file

@ -72,6 +72,12 @@ function _manually_load_plugin() {
switch ( $event_bridge_for_activitypub_integration_filter ) { switch ( $event_bridge_for_activitypub_integration_filter ) {
case 'the_events_calendar': case 'the_events_calendar':
$plugin_file = 'the-events-calendar/the-events-calendar.php'; $plugin_file = 'the-events-calendar/the-events-calendar.php';
\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\The_Events_Calendar::class
);
\update_option( 'activitypub_actor_mode', ACTIVITYPUB_BLOG_MODE );
break; break;
case 'vs_event_list': case 'vs_event_list':
$plugin_file = 'very-simple-event-list/vsel.php'; $plugin_file = 'very-simple-event-list/vsel.php';
@ -88,7 +94,10 @@ function _manually_load_plugin() {
case 'gatherpress': case 'gatherpress':
$plugin_file = 'gatherpress/gatherpress.php'; $plugin_file = 'gatherpress/gatherpress.php';
\update_option( 'event_bridge_for_activitypub_event_sources_active', true ); \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(
'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 ); \update_option( 'activitypub_actor_mode', ACTIVITYPUB_BLOG_MODE );
break; break;
case 'wp_event_manager': case 'wp_event_manager':
@ -106,6 +115,12 @@ function _manually_load_plugin() {
_manually_load_event_plugin( $plugin_file ); _manually_load_event_plugin( $plugin_file );
} else { } else {
// For all other tests we mainly use the Events Calendar and GatherPress as reference. // For all other tests we mainly use the Events Calendar and GatherPress as reference.
\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 );
_manually_load_event_plugin( 'the-events-calendar/the-events-calendar.php' ); _manually_load_event_plugin( 'the-events-calendar/the-events-calendar.php' );
_manually_load_event_plugin( 'gatherpress/gatherpress.php' ); _manually_load_event_plugin( 'gatherpress/gatherpress.php' );
} }

View file

@ -36,9 +36,11 @@ class Test_Event extends \WP_UnitTestCase {
* Test the shortcode for rendering the events start time. * Test the shortcode for rendering the events start time.
*/ */
public function test_start_time() { public function test_start_time() {
$event = Test_The_Events_Calendar::MOCKUP_EVENTS['minimal_event'];
// Create a The Events Calendar Event without content. // Create a The Events Calendar Event without content.
$wp_object = tribe_events() $wp_object = tribe_events()
->set_args( Test_The_Events_Calendar::MOCKUP_EVENTS['minimal_event'] ) ->set_args( $event )
->create(); ->create();
// Call the transformer Factory. // Call the transformer Factory.
@ -48,19 +50,22 @@ class Test_Event extends \WP_UnitTestCase {
return; return;
} }
$datetime_format = \get_option( 'date_format' ) . ' ' . \get_option( 'time_format' );
$time_string = \wp_date( $datetime_format, \strtotime( $event['start_date'] ) );
$transformer->register_shortcodes(); $transformer->register_shortcodes();
$summary = '[ap_start_time]'; $summary = '[ap_start_time]';
$summary = \do_shortcode( $summary ); $summary = \do_shortcode( $summary );
$this->assertEquals( '🗓️ Start: December 1, 2024 3:00 pm', $summary ); $this->assertEquals( "🗓️ Start: {$time_string}", $summary );
$summary = '[ap_start_time icon="false"]'; $summary = '[ap_start_time icon="false"]';
$summary = \do_shortcode( $summary ); $summary = \do_shortcode( $summary );
$this->assertEquals( 'Start: December 1, 2024 3:00 pm', $summary ); $this->assertEquals( "Start: {$time_string}", $summary );
$summary = '[ap_start_time icon="false" label="false"]'; $summary = '[ap_start_time icon="false" label="false"]';
$summary = \do_shortcode( $summary ); $summary = \do_shortcode( $summary );
$this->assertEquals( 'December 1, 2024 3:00 pm', $summary ); $this->assertEquals( $time_string, $summary );
$transformer->unregister_shortcodes(); $transformer->unregister_shortcodes();
} }
@ -69,9 +74,11 @@ class Test_Event extends \WP_UnitTestCase {
* Test the shortcode for rendering the events end time. * Test the shortcode for rendering the events end time.
*/ */
public function test_end_time() { public function test_end_time() {
$event = Test_The_Events_Calendar::MOCKUP_EVENTS['minimal_event'];
// Create a The Events Calendar Event without content. // Create a The Events Calendar Event without content.
$wp_object = tribe_events() $wp_object = tribe_events()
->set_args( Test_The_Events_Calendar::MOCKUP_EVENTS['minimal_event'] ) ->set_args( $event )
->create(); ->create();
// Call the transformer Factory. // Call the transformer Factory.
@ -81,19 +88,22 @@ class Test_Event extends \WP_UnitTestCase {
return; return;
} }
$datetime_format = \get_option( 'date_format' ) . ' ' . \get_option( 'time_format' );
$time_string = \wp_date( $datetime_format, \strtotime( $event['start_date'] ) + $event['duration'] );
$transformer->register_shortcodes(); $transformer->register_shortcodes();
$summary = '[ap_end_time]'; $summary = '[ap_end_time]';
$summary = \do_shortcode( $summary ); $summary = \do_shortcode( $summary );
$this->assertEquals( '⏳ End: December 1, 2024 4:00 pm', $summary ); $this->assertEquals( "⏳ End: {$time_string}", $summary );
$summary = '[ap_end_time icon="false"]'; $summary = '[ap_end_time icon="false"]';
$summary = \do_shortcode( $summary ); $summary = \do_shortcode( $summary );
$this->assertEquals( 'End: December 1, 2024 4:00 pm', $summary ); $this->assertEquals( "End: {$time_string}", $summary );
$summary = '[ap_end_time icon="false" label="false"]'; $summary = '[ap_end_time icon="false" label="false"]';
$summary = \do_shortcode( $summary ); $summary = \do_shortcode( $summary );
$this->assertEquals( 'December 1, 2024 4:00 pm', $summary ); $this->assertEquals( $time_string, $summary );
$transformer->unregister_shortcodes(); $transformer->unregister_shortcodes();
} }

View file

@ -82,7 +82,10 @@ class Test_GatherPress extends \WP_UnitTestCase {
$aec->activate_activitypub_support_for_active_event_plugins(); $aec->activate_activitypub_support_for_active_event_plugins();
\update_option( 'event_bridge_for_activitypub_event_sources_active', true ); \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(
'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 ); \update_option( 'activitypub_actor_mode', ACTIVITYPUB_BLOG_MODE );
} }

View file

@ -54,18 +54,15 @@ class Test_Event_Sources extends \WP_UnitTestCase {
self::$event_source_post_id = $post_id; self::$event_source_post_id = $post_id;
} }
/** /**
* Set up the test. * Set up the test.
*/ */
public function set_up() { public function set_up() {
\add_option( 'permalink_structure', '/%postname%/' ); if ( ! defined( 'GATHERPRESS_CORE_FILE' ) ) {
self::markTestSkipped( 'GatherPress plugin is not active.' );
}
\update_option( 'event_bridge_for_activitypub_event_sources_active', true ); \add_option( 'permalink_structure', '/%postname%/' );
\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; global $wp_rest_server;
$wp_rest_server = new WP_REST_Server(); $wp_rest_server = new WP_REST_Server();
@ -74,6 +71,20 @@ class Test_Event_Sources extends \WP_UnitTestCase {
do_action( 'rest_api_init' ); do_action( 'rest_api_init' );
\Activitypub\Rest\Server::add_hooks(); \Activitypub\Rest\Server::add_hooks();
// Mock the plugin activation.
\GatherPress\Core\Setup::get_instance()->activate_gatherpress_plugin( false );
// Make sure that ActivityPub support is enabled for GatherPress.
$aec = \Event_Bridge_For_ActivityPub\Setup::get_instance();
$aec->activate_activitypub_support_for_active_event_plugins();
\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 );
} }
/** /**