1 | <?php |
||
17 | class AgeCalculatorTest extends \PHPUnit\Framework\TestCase |
||
18 | { |
||
19 | /** |
||
20 | * @var string $today Timestamp that will be returned by date() |
||
21 | */ |
||
22 | public static $today; |
||
23 | |||
24 | private $yearsOld; |
||
25 | private $minDay = 1; |
||
26 | private $maxDay; |
||
27 | private $minMonth = 1; |
||
28 | private $maxMonth = 12; |
||
29 | private $actualMonth; |
||
30 | private $actualDay; |
||
31 | private $birthYear = 2000; |
||
32 | private $calculator; |
||
33 | |||
34 | function setUp() |
||
|
|||
35 | { |
||
36 | $this->yearsOld = date('Y') - $this->birthYear; |
||
37 | $this->actualMonth = date('n'); |
||
38 | $this->actualDay = date('d'); |
||
39 | $this->maxDay = date('t', strtotime($this->birthYear.'-'.$this->actualMonth.'-23')); |
||
40 | } |
||
41 | |||
42 | public function testEarlyYear() |
||
46 | |||
47 | public function testSameMonth() |
||
51 | |||
52 | public function testEndOfTheYear() |
||
56 | |||
57 | public function testSameMonthAndLastDay() |
||
61 | |||
62 | public function testFirstDayOfTheYear() |
||
66 | |||
67 | /** |
||
68 | * @param integer $month |
||
69 | * @param integer $day |
||
70 | */ |
||
71 | private function assertEqualsForAgeBeforeBirthday($month, $day) |
||
80 | |||
81 | /** |
||
82 | * @param integer $month |
||
83 | * @param integer $day |
||
84 | * @param integer $yearsOld |
||
85 | */ |
||
86 | private function assertEqualsForAge($month, $day, $yearsOld) |
||
94 | |||
95 | /** |
||
96 | * @expectedException InvalidArgumentException |
||
97 | */ |
||
98 | public function testBadFormat() |
||
102 | |||
103 | /** |
||
104 | * @expectedException InvalidArgumentException |
||
105 | */ |
||
106 | public function testBadDate() |
||
110 | } |
||
111 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.