todo: fix timezones
Some checks failed
Some checks failed
This commit is contained in:
parent
a70c188922
commit
aaa0ffc026
1 changed files with 44 additions and 1 deletions
|
@ -51,7 +51,7 @@ class Test_Eventin extends WP_UnitTestCase {
|
|||
'etn_end_date' => \gmdate( 'Y-m-d', strtotime( '+10 days 16:00:00' ) ),
|
||||
'etn_start_time' => \gmdate( 'H:i', strtotime( '+10 days 15:00:00' ) ),
|
||||
'etn_end_time' => \gmdate( 'H:i', strtotime( '+10 days 15:00:00' ) ),
|
||||
'etn_timezone' => 'Europe/Vienna',
|
||||
'event_timezone' => 'Europe/Vienna',
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -61,4 +61,47 @@ class Test_Eventin extends WP_UnitTestCase {
|
|||
// Check that we got the right transformer.
|
||||
$this->assertInstanceOf( \ActivityPub_Event_Bridge\Activitypub\Transformer\Eventin::class, $transformer );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the right transformer gets applied.
|
||||
*/
|
||||
public function test_eventin_test_minimal_event() {
|
||||
// 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( 'etn', get_option( 'activitypub_support_post_types' ) );
|
||||
|
||||
// Create a Eventin Event without content.
|
||||
$event = new \Etn\Core\Event\Event_Model();
|
||||
$event->create(
|
||||
array(
|
||||
'post_status' => 'publish',
|
||||
'post_title' => 'Eventin Test Event Title',
|
||||
'post_content' => 'Eventin Test Event Description',
|
||||
'etn_start_date' => \gmdate( 'Y-m-d', strtotime( '+10 days 15:00:00' ) ),
|
||||
'etn_end_date' => \gmdate( 'Y-m-d', strtotime( '+10 days 16:00:00' ) ),
|
||||
'etn_start_time' => '03:00 PM',
|
||||
'etn_end_time' => '04:00 PM',
|
||||
'event_timezone' => 'Europe/Vienna',
|
||||
)
|
||||
);
|
||||
|
||||
// Call the transformer Factory.
|
||||
$event_array = \Activitypub\Transformer\Factory::get_transformer( get_post( $event->id ) )->to_object()->to_array();
|
||||
|
||||
$this->assertEquals( 'Event', $event_array['type'] );
|
||||
$this->assertEquals( 'Eventin Test Event Title', $event_array['name'] );
|
||||
$this->assertEquals( 'Eventin Test Event 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( comments_open( $event->id ), $event_array['commentsEnabled'] );
|
||||
$this->assertEquals( comments_open( $event->id ) ? 'allow_all' : 'closed', $event_array['repliesModerationOption'] );
|
||||
$this->assertEquals( 'external', $event_array['joinMode'] );
|
||||
$this->assertArrayNotHasKey( 'location', $event_array );
|
||||
$this->assertArrayNotHasKey( 'endTime', $event_array );
|
||||
$this->assertEquals( 'MEETING', $event_array['category'] );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue