Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JanGalek committed Dec 9, 2017
1 parent 5285816 commit 25d40d0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
17 changes: 2 additions & 15 deletions src/Galek/Utils/Calendar/Calendar.php
Expand Up @@ -430,8 +430,6 @@ public function timeBetween($firstHour, $firstMinute, $lastHour, $lastMinute)
} elseif ($this <= $lastDate) {
return TRUE;
}

return FALSE;
}

return ($this->timeBellow($lastHour, $lastMinute) ? $this->timeOver($firstHour, $firstMinute) : FALSE);
Expand Down Expand Up @@ -498,22 +496,11 @@ public function werbDif($werb = [], $date = NULL)
public function werbDif2($date = null, $date2 = null)
{
trigger_error('werbDif2 is deprecated, use werbDif($werb, $date).', E_USER_DEPRECATED);
$curDate = ($date ? $date : new \DateTime());
$date2 = ($date2 ? $date2 : $this->date);
$diff = $date2->diff($curDate)->days;

$werbs = (empty($werb) ? $this->difWerbs : $werb);
$werbs = $this->difWerbs;

if ($diff <= 2) {
$format = $werbs[$diff];
} elseif ($diff < 5) {
$format = $werbs['<5>'] . ' ' . $diff . ' ' . $werbs['<5'];
} elseif ($diff >= 5) {
$format = $werbs['<5>'] . ' ' . $diff . ' ' . $werbs['>=5'];
} else {
return FALSE;
}
return $format;
return $this->werbDif($werbs, $date2);
}

/**
Expand Down
14 changes: 14 additions & 0 deletions tests/CalendarTests/Calendar.phpt
Expand Up @@ -165,6 +165,20 @@ class CalendarTest extends \Tester\TestCase
Assert::equal('03.05.2016', $date2->format('d.m.Y'), 'dneska pracovni den 4');
Assert::equal(TRUE, $date2->isWorkDay());*/
}

public function testSklonovani()
{
$date = new Calendar('2017-12-09 00:00:00');

Assert::equal('sobota', $date->sklonovaniDays($date),'sklonovani');
}

public function testFormat()
{
$date = new Calendar('2017-12-09 1:02:01');

Assert::equal($date->format('d.m.Y H:i:s'), $date->getDateTimeFormat(),'dateFormat');
}
}

(new CalendarTest())->run();
8 changes: 8 additions & 0 deletions tests/CalendarTests/WorkTime.phpt
Expand Up @@ -178,6 +178,14 @@ class WorkTimeTest extends \Tester\TestCase
$date2 = new Calendar('25.03.2016');
Assert::equal(TRUE, $date2->isHoliday());
}


public function testNotWorkTIme()
{
$date = new Calendar('09.12.2017 18:00:00');
$date->setWorkTime(8,0,16,30);
Assert::equal(FALSE, $date->isWorkTime());
}
}

$testCase = new WorkTimeTest();
Expand Down

0 comments on commit 25d40d0

Please sign in to comment.