Skip to content

Commit

Permalink
Fix failing tests with ICU 72.1 because of NNBSP
Browse files Browse the repository at this point in the history
  • Loading branch information
rlanvin committed Jun 23, 2024
1 parent 0f48c3f commit 747bc47
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions tests/RRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3207,13 +3207,13 @@ public function humanReadableStrings()
array(
"DTSTART:20170202T161500Z\nRRULE:FREQ=MONTHLY;BYMONTHDAY=2",
array('locale' => "en", 'start_time_only' => true, 'explicit_infinite' => false),
"monthly on the 2nd of the month at 4:15 PM",
"monthly on the 2nd of the month at 4:15PM",
"monthly on the 2nd of the month at 16:15:00"
),
array(
"DTSTART:20170202T063000Z\nRRULE:FREQ=HOURLY;INTERVAL=7",
array('locale' => "en", 'start_time_only' => true, 'explicit_infinite' => false),
"every 7 hours starting at 6:30 AM",
"every 7 hours starting at 6:30AM",
"every 7 hours starting at 06:30:00"
),
array(
Expand Down Expand Up @@ -3259,14 +3259,38 @@ public function humanReadableStrings()
/**
* @dataProvider humanReadableStrings
*/
public function testHumanReadable($rrule, $options, $withIntl, $withoutIntl, $dtstart = null)
public function testHumanReadableWithoutIntl($rrule, $options, $withIntl, $withoutIntl, $dtstart = null)
{
if ($dtstart) {
$dtstart = new DateTime($dtstart);
}
$rrule = new RRule($rrule, $dtstart);
$expected = extension_loaded('intl') ? $withIntl : $withoutIntl;
$this->assertEquals($expected, $rrule->humanReadable($options));
$options['use_intl'] = false;
$this->assertEquals($withoutIntl, $rrule->humanReadable($options));
}

/**
* @dataProvider humanReadableStrings
*/
public function testHumanReadableWithIntl($rrule, $options, $withIntl, $withoutIntl, $dtstart = null)
{
if (!extension_loaded('intl')) {
$this->markTestSkipped('intl not loaded');
}

if ($dtstart) {
$dtstart = new DateTime($dtstart);
}
$rrule = new RRule($rrule, $dtstart);

// Narrow No-Break Space (NNBSP) was added in ICU72.1 before the meridian
// as a workaround we replace unicode 0x202f char with a regular space for backwards compatibility
if (version_compare(INTL_ICU_VERSION, '72.1') < 0) {
// if you don't see the difference, use an editor that displays unicode
$withIntl = str_replace('', ' ', $withIntl);
}

$this->assertEquals($withIntl, $rrule->humanReadable($options));
}

/**
Expand Down

0 comments on commit 747bc47

Please sign in to comment.