Skip to content

Commit

Permalink
Merge pull request #24 from cultuurnet/feature/III-1489
Browse files Browse the repository at this point in the history
III-1489: Support opening time with empty from string.
  • Loading branch information
bramcordie committed Oct 17, 2016
2 parents 2828777 + 198881f commit e9942f3
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/CultureFeed/Cdb/Data/Calendar/OpeningTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public static function parseFromCdbXml(SimpleXMLElement $xmlElement)
{

$attributes = $xmlElement->attributes();
if (!isset($attributes['from'])) {
if (!isset($attributes['from']) || empty($attributes['from'])) {
$openFrom = '00:00:00';
} else {
$openFrom = (string) $attributes['from'];
Expand Down
20 changes: 20 additions & 0 deletions tests/CultureFeed/Cdb/Data/Calendar/OpeningTimeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

class OpeningTimeTest extends PHPUnit_Framework_TestCase
{
public function testOpeningHoursWithEmptyFrom()
{
$xml = new SimpleXMLElement(
file_get_contents(__DIR__ . '/samples/openingTime.xml')
);

$ws = CultureFeed_Cdb_Data_Calendar_Weekscheme::parseFromCdbXml(
$xml
);

/** @var CultureFeed_Cdb_Data_Calendar_OpeningTime[] $tuesdayOpeningTimes */
$tuesdayOpeningTimes = $ws->tuesday()->getOpeningTimes();

$this->assertEquals("00:00:00", $tuesdayOpeningTimes[0]->getOpenFrom());
}
}
14 changes: 14 additions & 0 deletions tests/CultureFeed/Cdb/Data/Calendar/samples/openingTime.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf8"?>
<weekscheme>
<monday opentype="closed"/>
<tuesday opentype="open">
<openingtime from="" to="20:00:00"/>
</tuesday>
<wednesday opentype="open">
<openingtime from="08:00:00" to="20:00:00"/>
</wednesday>
<thursday opentype="closed"/>
<friday opentype="open"/>
<saturday opentype="open"/>
<sunday opentype="closed"/>
</weekscheme>

0 comments on commit e9942f3

Please sign in to comment.