Skip to content

Commit 8c2bd81

Browse files
committed
WIP updating tests
1 parent 91960ca commit 8c2bd81

File tree

1 file changed

+57
-5
lines changed

1 file changed

+57
-5
lines changed

test/unit/php/includes/core/classes/class-test-event.php

+57-5
Original file line numberDiff line numberDiff line change
@@ -370,10 +370,6 @@ public function test_get_venue_information(): void {
370370
* Coverage for get_calendar_links method.
371371
*
372372
* @covers ::get_calendar_links
373-
* @covers Calendars::get_url
374-
* @covers Calendars::get_google_calendar_link
375-
* @covers Calendars::get_ical_file
376-
* @covers Calendars::get_yahoo_calendar_link
377373
* @covers ::get_calendar_description
378374
*
379375
* @return void
@@ -407,8 +403,8 @@ public function test_get_calendar_links(): void {
407403

408404
$event->save_datetimes( $params );
409405

410-
$output = $event->get_calendar_links();
411406

407+
/*
412408
$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';
413409
$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';
414410
@@ -429,10 +425,66 @@ public function test_get_calendar_links(): void {
429425
'name' => 'Yahoo Calendar',
430426
'link' => $expected_yahoo_link,
431427
),
428+
); */
429+
$output = $event->get_calendar_links();
430+
$expects = array(
431+
'google' => array(
432+
'name' => 'Google Calendar',
433+
'link' => home_url('/?gatherpress_event=unit-test-event&gatherpress_calendars=google-calendar'),
434+
),
435+
'ical' => array(
436+
'name' => 'iCal',
437+
'download' => home_url('/?gatherpress_event=unit-test-event&gatherpress_calendars=ical'),
438+
),
439+
'outlook' => array(
440+
'name' => 'Outlook',
441+
'download' => home_url('/?gatherpress_event=unit-test-event&gatherpress_calendars=outlook'),
442+
),
443+
'yahoo' => array(
444+
'name' => 'Yahoo Calendar',
445+
'link' => home_url('/?gatherpress_event=unit-test-event&gatherpress_calendars=yahoo-calendar'),
446+
),
432447
);
433448

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

451+
// update_option( 'permalink_structure', '/%postname%/');
452+
// flush_rewrite_rules();
453+
// global $wp_rewrite;
454+
// $wp_rewrite->set_permalink_structure('/%postname%/');
455+
// $wp_rewrite->generate_rewrite_rules( $wp_rewrite->permalink_structure, EP_PERMALINK );
456+
// Update permalink structure to '/%postname%/'.
457+
update_option( 'permalink_structure', '/%postname%/' );
458+
459+
// Reload the global rewrite rules object to ensure it reflects the changes.
460+
global $wp_rewrite;
461+
$wp_rewrite->init();
462+
flush_rewrite_rules();
463+
464+
// Simulate a frontend request to trigger the new rewrite rules.
465+
// $this->go_to( home_url( '/event/unit-test-event' ) );
466+
467+
$output = $event->get_calendar_links();
468+
$expects = array(
469+
'google' => array(
470+
'name' => 'Google Calendar',
471+
'link' => home_url('/event/unit-test-event/google-calendar'),
472+
),
473+
'ical' => array(
474+
'name' => 'iCal',
475+
'download' => home_url('/event/unit-test-event/ical'),
476+
),
477+
'outlook' => array(
478+
'name' => 'Outlook',
479+
'download' => home_url('/event/unit-test-event/outlook'),
480+
),
481+
'yahoo' => array(
482+
'name' => 'Yahoo Calendar',
483+
'link' => home_url('/event/unit-test-event/yahoo-calendar'),
484+
),
485+
);
486+
$this->assertSame( $expects, $output );
487+
436488
Utility::set_and_get_hidden_property( $event, 'event', null );
437489

438490
$this->assertEmpty(

0 commit comments

Comments
 (0)