@@ 16-69 (lines=54) @@ | ||
13 | * @author Kristjan Siimson <[email protected]> |
|
14 | * @package Selector\Test |
|
15 | */ |
|
16 | class FirstOfTest extends \PHPUnit_Framework_TestCase |
|
17 | { |
|
18 | /** |
|
19 | * @var array |
|
20 | */ |
|
21 | private $holidays = array( |
|
22 | '2014-01-05', |
|
23 | '2014-01-15', |
|
24 | '2014-01-25', |
|
25 | '2014-02-05', |
|
26 | '2014-02-15', |
|
27 | '2014-02-25', |
|
28 | '2014-03-05', |
|
29 | '2014-03-15', |
|
30 | '2014-03-25' |
|
31 | ); |
|
32 | ||
33 | /** |
|
34 | * @var ArrayHolidayProvider |
|
35 | */ |
|
36 | private $holidayProvider; |
|
37 | ||
38 | public function setUp() |
|
39 | { |
|
40 | $this->holidayProvider = new ArrayHolidayProvider($this->holidays); |
|
41 | } |
|
42 | ||
43 | public function testIfUpcomingMatchFoundUseCurrentPeriod() |
|
44 | { |
|
45 | $selector = new FirstOf(new Increasing(), new Holiday($this->holidayProvider)); |
|
46 | ||
47 | $date = '2014-02-01'; |
|
48 | $period = new Month($date); |
|
49 | $this->assertEquals('2014-02-05', $selector->select($date, $period)); |
|
50 | } |
|
51 | ||
52 | public function testIfNoUpcomingMatchFoundUseNextPeriod() |
|
53 | { |
|
54 | $selector = new FirstOf(new Increasing(), new Holiday($this->holidayProvider)); |
|
55 | ||
56 | $date = '2014-02-05'; |
|
57 | $period = new Month($date); |
|
58 | $this->assertEquals('2014-03-05', $selector->select($date, $period)); |
|
59 | } |
|
60 | ||
61 | public function testIfNoUpcomingMatchFoundUsePreviousPeriod() |
|
62 | { |
|
63 | $selector = new FirstOf(new Decreasing(), new Holiday($this->holidayProvider)); |
|
64 | ||
65 | $date = '2014-02-05'; |
|
66 | $period = new Month($date); |
|
67 | $this->assertEquals('2014-01-05', $selector->select($date, $period)); |
|
68 | } |
|
69 | } |
|
70 |
@@ 16-69 (lines=54) @@ | ||
13 | * @author Kristjan Siimson <[email protected]> |
|
14 | * @package Selector\Test |
|
15 | */ |
|
16 | class LastOfTest extends \PHPUnit_Framework_TestCase |
|
17 | { |
|
18 | /** |
|
19 | * @var array |
|
20 | */ |
|
21 | private $holidays = array( |
|
22 | '2014-01-05', |
|
23 | '2014-01-15', |
|
24 | '2014-01-25', |
|
25 | '2014-02-05', |
|
26 | '2014-02-15', |
|
27 | '2014-02-25', |
|
28 | '2014-03-05', |
|
29 | '2014-03-15', |
|
30 | '2014-03-25' |
|
31 | ); |
|
32 | ||
33 | /** |
|
34 | * @var ArrayHolidayProvider |
|
35 | */ |
|
36 | private $holidayProvider; |
|
37 | ||
38 | public function setUp() |
|
39 | { |
|
40 | $this->holidayProvider = new ArrayHolidayProvider($this->holidays); |
|
41 | } |
|
42 | ||
43 | public function testIfUpcomingMatchFoundUseCurrentPeriod() |
|
44 | { |
|
45 | $selector = new LastOf(new Increasing(), new Holiday($this->holidayProvider)); |
|
46 | ||
47 | $date = '2014-02-01'; |
|
48 | $period = new Month($date); |
|
49 | $this->assertEquals('2014-02-25', $selector->select($date, $period)); |
|
50 | } |
|
51 | ||
52 | public function testIfNoUpcomingMatchFoundUseNextPeriod() |
|
53 | { |
|
54 | $selector = new LastOf(new Increasing(), new Holiday($this->holidayProvider)); |
|
55 | ||
56 | $date = '2014-02-25'; |
|
57 | $period = new Month($date); |
|
58 | $this->assertEquals('2014-03-25', $selector->select($date, $period)); |
|
59 | } |
|
60 | ||
61 | public function testIfNoUpcomingMatchFoundUsePreviousPeriod() |
|
62 | { |
|
63 | $selector = new LastOf(new Decreasing(), new Holiday($this->holidayProvider)); |
|
64 | ||
65 | $date = '2014-02-25'; |
|
66 | $period = new Month($date); |
|
67 | $this->assertEquals('2014-01-25', $selector->select($date, $period)); |
|
68 | } |
|
69 | } |
|
70 |