|
1
|
|
|
<?php |
|
2
|
|
|
namespace Stefanius\SpecialDates\Tests; |
|
3
|
|
|
|
|
4
|
|
|
use Stefanius\SpecialDates\SDK\SpecialDateInterface; |
|
5
|
|
|
|
|
6
|
|
|
abstract class AbstractDateTester extends \PHPUnit_Framework_TestCase |
|
7
|
|
|
{ |
|
8
|
|
|
/** |
|
9
|
|
|
* @param int $year |
|
10
|
|
|
* @param string $description |
|
11
|
|
|
* @param bool $isValid |
|
12
|
|
|
* @param bool $bankHoliday |
|
13
|
|
|
* @param int $totalLength |
|
14
|
|
|
* @param string $endDateString (yyyy-mm-dd) |
|
15
|
|
|
* @param string $startDateString (yyyy-mm-dd) |
|
16
|
|
|
* |
|
17
|
|
|
* @dataProvider provider |
|
18
|
|
|
*/ |
|
19
|
66 |
|
public function testSpecialDate($year, $description, $isValid, $bankHoliday, $totalLength, $startDateString, $endDateString) |
|
20
|
|
|
{ |
|
21
|
66 |
|
$specialDate = $this->createDateObject($year); |
|
22
|
|
|
|
|
23
|
63 |
|
$startDate = $specialDate->getStartDate(); |
|
24
|
63 |
|
$endDate = $specialDate->getEndDate(); |
|
25
|
|
|
|
|
26
|
63 |
|
$this->assertEquals($description, $specialDate->getDescription()); |
|
27
|
63 |
|
$this->assertEquals($isValid, $specialDate->isValid()); |
|
28
|
63 |
|
$this->assertEquals($bankHoliday, $specialDate->isBankHoliday()); |
|
29
|
63 |
|
$this->assertEquals($totalLength, $specialDate->getTotalLength()); |
|
30
|
|
|
|
|
31
|
63 |
|
$this->assertEquals($startDateString, $startDate->format('Y') . '-' . $startDate->format('m') . '-' . $startDate->format('d')); |
|
32
|
63 |
|
$this->assertEquals($endDateString, $endDate->format('Y') . '-' . $endDate->format('m') . '-' . $endDate->format('d')); |
|
33
|
|
|
|
|
34
|
63 |
|
if ($isValid) { |
|
35
|
38 |
|
$this->assertEquals($year, $startDate->format('Y')); |
|
36
|
38 |
|
$this->assertEquals($year, $endDate->format('Y')); |
|
37
|
38 |
|
} |
|
38
|
|
|
|
|
39
|
63 |
|
if ($totalLength === 1) { |
|
40
|
34 |
|
$this->assertEquals($startDateString, $endDateString); |
|
41
|
34 |
|
} |
|
42
|
63 |
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Dataprovider for the unittest. Extend this method in your concrete test. |
|
46
|
|
|
* |
|
47
|
|
|
* @return array |
|
48
|
|
|
*/ |
|
49
|
|
|
abstract public function provider(); |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Create and return the SpecialDateObject you want to test. |
|
53
|
|
|
* |
|
54
|
|
|
* @param $year |
|
55
|
|
|
* |
|
56
|
|
|
* @return SpecialDateInterface |
|
57
|
|
|
*/ |
|
58
|
|
|
abstract protected function createDateObject($year); |
|
59
|
|
|
} |
|
60
|
|
|
|