1
0
mirror of https://github.com/rlanvin/php-rrule.git synced 2025-02-26 15:54:14 +01:00

Fix failing tests with ICU 72.1 because of NNBSP

This commit is contained in:
Rémi Lanvin 2024-06-23 08:18:06 +02:00
parent 0f48c3f93b
commit 747bc473d9

View File

@ -3207,13 +3207,13 @@ class RRuleTest extends TestCase
array( array(
"DTSTART:20170202T161500Z\nRRULE:FREQ=MONTHLY;BYMONTHDAY=2", "DTSTART:20170202T161500Z\nRRULE:FREQ=MONTHLY;BYMONTHDAY=2",
array('locale' => "en", 'start_time_only' => true, 'explicit_infinite' => false), 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" "monthly on the 2nd of the month at 16:15:00"
), ),
array( array(
"DTSTART:20170202T063000Z\nRRULE:FREQ=HOURLY;INTERVAL=7", "DTSTART:20170202T063000Z\nRRULE:FREQ=HOURLY;INTERVAL=7",
array('locale' => "en", 'start_time_only' => true, 'explicit_infinite' => false), 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" "every 7 hours starting at 06:30:00"
), ),
array( array(
@ -3259,14 +3259,38 @@ class RRuleTest extends TestCase
/** /**
* @dataProvider humanReadableStrings * @dataProvider humanReadableStrings
*/ */
public function testHumanReadable($rrule, $options, $withIntl, $withoutIntl, $dtstart = null) public function testHumanReadableWithoutIntl($rrule, $options, $withIntl, $withoutIntl, $dtstart = null)
{ {
if ($dtstart) { if ($dtstart) {
$dtstart = new DateTime($dtstart); $dtstart = new DateTime($dtstart);
} }
$rrule = new RRule($rrule, $dtstart); $rrule = new RRule($rrule, $dtstart);
$expected = extension_loaded('intl') ? $withIntl : $withoutIntl; $options['use_intl'] = false;
$this->assertEquals($expected, $rrule->humanReadable($options)); $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));
} }
/** /**