Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
yunosh committed Jun 2, 2014
1 parent a4bc4cc commit dcf5746
Showing 1 changed file with 31 additions and 21 deletions.
52 changes: 31 additions & 21 deletions framework/Icalendar/test/Horde/Icalendar/TimezonesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,39 @@ public function setUp()
date_default_timezone_set('UTC');
}

public function testFiles()
/**
* @dataProvider timezones
*/
public function testFile($file)
{
$test_files = glob(__DIR__ . '/fixtures/vTimezone/*.ics');
foreach ($test_files as $file) {
$result = '';
$ical = new Horde_Icalendar();
$ical->parsevCalendar(file_get_contents($file));
foreach ($ical->getComponents() as $component) {
if ($component->getType() != 'vEvent') {
continue;
}
$date = $component->getAttribute('DTSTART');
if (is_array($date)) {
continue;
}
$result .= str_replace("\r", '', $component->getAttribute('SUMMARY')) . "\n";
$d = new Horde_Date($date);
$result .= $d->format('H:i') . "\n";
$result = '';
$ical = new Horde_Icalendar();
$ical->parsevCalendar(file_get_contents($file));
foreach ($ical->getComponents() as $component) {
if ($component->getType() != 'vEvent') {
continue;
}
$this->assertStringEqualsFile(
__DIR__ . '/fixtures/vTimezone/' . basename($file, 'ics') . 'txt',
$result,
'Failed parsing file ' . basename($file));
$date = $component->getAttribute('DTSTART');
if (is_array($date)) {
continue;
}
$result .= str_replace("\r", '', $component->getAttribute('SUMMARY')) . "\n";
$d = new Horde_Date($date);
$result .= $d->format('H:i') . "\n";
}
$this->assertStringEqualsFile(
__DIR__ . '/fixtures/vTimezone/' . basename($file, 'ics') . 'txt',
$result,
'Failed parsing file ' . basename($file));
}

public function timezones()
{
return array_map(
function($a) {
return array($a);
},
glob(__DIR__ . '/fixtures/vTimezone/*.ics')
);
}
}

0 comments on commit dcf5746

Please sign in to comment.