Skip to content

Commit

Permalink
III-1789: Prevent unnecessary line break when formatting period list
Browse files Browse the repository at this point in the history
  • Loading branch information
bramcordie committed Jan 24, 2017
1 parent 0b6f3ed commit ea5aed4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Period/LargePeriodPlainTextFormatter.php
Expand Up @@ -34,7 +34,7 @@ public function format(
$period = $periodList->current();
$output = $this->generateDates($period->getDateFrom(), $period->getDateTo());
if (!is_null($period->getWeekScheme())) {
$output .= $this->generateWeekscheme($period->getWeekScheme());
$output .= PHP_EOL . $this->generateWeekscheme($period->getWeekScheme());
}

return $output;
Expand Down Expand Up @@ -103,7 +103,7 @@ protected function generateDates($date_from, $date_to)
$dateTo = strtotime($dateToString);
$intlDateTo = $fmt->format($dateTo);

$output_dates = 'Van ' . $intlDateFrom . ' tot ' . $intlDateTo . PHP_EOL;
$output_dates = 'Van ' . $intlDateFrom . ' tot ' . $intlDateTo;
return $output_dates;
}

Expand Down
14 changes: 14 additions & 0 deletions tests/Period/LargePeriodPlainTextFormatterTest.php
Expand Up @@ -90,4 +90,18 @@ public function testFormatsAPeriod()
$this->formatter->format($periodList)
);
}

public function testFormatsAPeriodListWithoutUnnecessaryLineBreak()
{
$period_list = new CultureFeed_Cdb_Data_Calendar_PeriodList();
$period = new CultureFeed_Cdb_Data_Calendar_Period('2020-09-20', '2020-09-21');
$period_list->add($period);

$expectedResult = 'Van 20 september 2020 tot 21 september 2020';

$this->assertEquals(
$expectedResult,
$this->formatter->format($period_list)
);
}
}

0 comments on commit ea5aed4

Please sign in to comment.