Skip to content

Commit

Permalink
Merge branch 'keesiemeijer-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
donatj committed Jun 7, 2017
2 parents 840da95 + 8bc5fbd commit 260f1bd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/donatj/SimpleCalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,14 @@ public function show( $echo = true ) {

$out .= "</td>";

if( $count > 6 && $i < $no_days ) {
$out .= "</tr>\n" . ($i != $count ? '<tr>' : '');
if( $count > 6 ) {
$out .= "</tr>\n" . ($i < $no_days ? '<tr>' : '');
$count = 0;
}
$count++;
}
$out .= ($count != 1 ? str_repeat('<td class="SCsuffix">&nbsp;</td>', 8 - $count) : '') . "</tr>\n</tbody></table>\n";
$out .= ( $count != 1 ) ? str_repeat('<td class="SCsuffix">&nbsp;</td>', 8 - $count) . '</tr>' : '';
$out .= "\n</tbody></table>\n";
if( $echo ) {
echo $out;
}
Expand Down
19 changes: 19 additions & 0 deletions test/SimpleCalendarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,25 @@ public function testCurrentMonth_yearRegression() {
$this->assertNotContains('class="today"', $cal->show(false));
}

public function testTagOpenCloseMismatch_regression() {
$cal = new \donatj\SimpleCalendar();
$cal->setStartOfWeek(4);
$cal->setDate('September 2016');
$html = $cal->show(false);

$this->assertSame(substr_count($html, '<tr'), substr_count($html, '</tr'));
$this->assertSame(substr_count($html, '<td'), substr_count($html, '</td'));
}

public function testTagOpenCloseMismatch_regression2() {
$cal = new \donatj\SimpleCalendar();
$cal->setDate('January 2017');
$html = $cal->show(false);

$this->assertSame(substr_count($html, '<tr'), substr_count($html, '</tr'));
$this->assertSame(substr_count($html, '<td'), substr_count($html, '</td'));
}

public function testGenericGeneration() {
$cal = new \donatj\SimpleCalendar("June 5 2016");

Expand Down

0 comments on commit 260f1bd

Please sign in to comment.