Skip to content

Commit

Permalink
WIP updating tests
Browse files Browse the repository at this point in the history
  • Loading branch information
carstingaxion committed Sep 17, 2024
1 parent 91960ca commit 8c2bd81
Showing 1 changed file with 57 additions and 5 deletions.
62 changes: 57 additions & 5 deletions test/unit/php/includes/core/classes/class-test-event.php
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,6 @@ public function test_get_venue_information(): void {
* Coverage for get_calendar_links method.
*
* @covers ::get_calendar_links
* @covers Calendars::get_url
* @covers Calendars::get_google_calendar_link
* @covers Calendars::get_ical_file
* @covers Calendars::get_yahoo_calendar_link
* @covers ::get_calendar_description
*
* @return void
Expand Down Expand Up @@ -407,8 +403,8 @@ public function test_get_calendar_links(): void {

$event->save_datetimes( $params );

$output = $event->get_calendar_links();

/*
$expected_google_link = 'https://www.google.com/calendar/event?action=TEMPLATE&text=Unit%20Test%20Event&dates=20200511T150000Z%2F20200511T170000Z&details=' . rawurlencode( $description ) . '&location=Unit%20Test%20Venue%2C%20123%20Main%20Street%2C%20Montclair%2C%20NJ%2007042&sprop=name%3A';
$expected_yahoo_link = 'https://calendar.yahoo.com/?v=60&view=d&type=20&title=Unit%20Test%20Event&st=20200511T150000Z&dur=0200&desc=' . rawurlencode( $description ) . '&in_loc=Unit%20Test%20Venue%2C%20123%20Main%20Street%2C%20Montclair%2C%20NJ%2007042';
Expand All @@ -429,10 +425,66 @@ public function test_get_calendar_links(): void {
'name' => 'Yahoo Calendar',
'link' => $expected_yahoo_link,
),
); */
$output = $event->get_calendar_links();
$expects = array(
'google' => array(
'name' => 'Google Calendar',
'link' => home_url('/?gatherpress_event=unit-test-event&gatherpress_calendars=google-calendar'),
),
'ical' => array(
'name' => 'iCal',
'download' => home_url('/?gatherpress_event=unit-test-event&gatherpress_calendars=ical'),
),
'outlook' => array(
'name' => 'Outlook',
'download' => home_url('/?gatherpress_event=unit-test-event&gatherpress_calendars=outlook'),
),
'yahoo' => array(
'name' => 'Yahoo Calendar',
'link' => home_url('/?gatherpress_event=unit-test-event&gatherpress_calendars=yahoo-calendar'),
),
);

$this->assertSame( $expects, $output );

// update_option( 'permalink_structure', '/%postname%/');
// flush_rewrite_rules();
// global $wp_rewrite;
// $wp_rewrite->set_permalink_structure('/%postname%/');
// $wp_rewrite->generate_rewrite_rules( $wp_rewrite->permalink_structure, EP_PERMALINK );
// Update permalink structure to '/%postname%/'.
update_option( 'permalink_structure', '/%postname%/' );

// Reload the global rewrite rules object to ensure it reflects the changes.
global $wp_rewrite;
$wp_rewrite->init();
flush_rewrite_rules();

// Simulate a frontend request to trigger the new rewrite rules.
// $this->go_to( home_url( '/event/unit-test-event' ) );

$output = $event->get_calendar_links();
$expects = array(
'google' => array(
'name' => 'Google Calendar',
'link' => home_url('/event/unit-test-event/google-calendar'),
),
'ical' => array(
'name' => 'iCal',
'download' => home_url('/event/unit-test-event/ical'),
),
'outlook' => array(
'name' => 'Outlook',
'download' => home_url('/event/unit-test-event/outlook'),
),
'yahoo' => array(
'name' => 'Yahoo Calendar',
'link' => home_url('/event/unit-test-event/yahoo-calendar'),
),
);
$this->assertSame( $expects, $output );

Utility::set_and_get_hidden_property( $event, 'event', null );

$this->assertEmpty(
Expand Down

0 comments on commit 8c2bd81

Please sign in to comment.