add test class for vs event llist
All checks were successful
All checks were successful
This commit is contained in:
parent
1764a7b03f
commit
5dfd6806eb
1 changed files with 63 additions and 0 deletions
63
tests/test-class-plugin-vs-event-list.php
Normal file
63
tests/test-class-plugin-vs-event-list.php
Normal file
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
/**
|
||||
* Class SampleTest
|
||||
*
|
||||
* @package Activitypub_Event_Extensions
|
||||
*/
|
||||
|
||||
/**
|
||||
* Sample test case.
|
||||
*/
|
||||
class Test_VS_Event_List 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( 'vsel_custom_post_type' ) ) {
|
||||
self::markTestSkipped( 'VS Event List plugin is not active.' );
|
||||
}
|
||||
|
||||
// Make sure that ActivityPub support is enabled for The Events Calendar.
|
||||
$aec = \Activitypub_Event_Extensions\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_Extensions\Setup::get_instance()->get_active_event_plugins();
|
||||
$this->assertEquals( 1, count( $active_event_plugins ) );
|
||||
|
||||
// Enable ActivityPub support for the event plugin.
|
||||
$this->assertContains( 'event', get_option( 'activitypub_support_post_types' ) );
|
||||
|
||||
// Insert a new Event.
|
||||
$wp_post_id = wp_insert_post(
|
||||
array(
|
||||
'post_title' => 'VSEL Test Event',
|
||||
'post_status' => 'published',
|
||||
'post_type' => 'event',
|
||||
'meta_input' => array(
|
||||
'event-start-time' => strtotime( '+10 days 15:00:00' ),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
$wp_object = get_post( $wp_post_id );
|
||||
|
||||
// Call the transformer Factory.
|
||||
$transformer = \Activitypub\Transformer\Factory::get_transformer( $wp_object );
|
||||
|
||||
// Check that we got the right transformer.
|
||||
$this->assertInstanceOf( \Activitypub_Event_Extensions\Activitypub\Transformer\VS_Event_List::class, $transformer );
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue