[22632] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | * This file is part of EC-CUBE |
---|
| 4 | * |
---|
| 5 | * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved. |
---|
| 6 | * |
---|
| 7 | * http://www.lockon.co.jp/ |
---|
| 8 | * |
---|
| 9 | * This program is free software; you can redistribute it and/or |
---|
| 10 | * modify it under the terms of the GNU General Public License |
---|
| 11 | * as published by the Free Software Foundation; either version 2 |
---|
| 12 | * of the License, or (at your option) any later version. |
---|
| 13 | * |
---|
| 14 | * This program is distributed in the hope that it will be useful, |
---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 17 | * GNU General Public License for more details. |
---|
| 18 | * |
---|
| 19 | * You should have received a copy of the GNU General Public License |
---|
| 20 | * along with this program; if not, write to the Free Software |
---|
| 21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
| 22 | */ |
---|
| 23 | |
---|
| 24 | $HOME = realpath(dirname(__FILE__)) . "/../../.."; |
---|
| 25 | require_once($HOME . "/tests/class/Common_TestCase.php"); |
---|
| 26 | |
---|
| 27 | class SC_Date_isHolidayTest extends Common_TestCase |
---|
| 28 | { |
---|
| 29 | |
---|
| 30 | protected function setUp() |
---|
| 31 | { |
---|
| 32 | parent::setUp(); |
---|
| 33 | $this->objDate = new SC_Date_Ex(); |
---|
| 34 | $objQuery = SC_Query_Ex::getSingletonInstance(); |
---|
| 35 | //休日を登録 |
---|
| 36 | $holiday = array( |
---|
| 37 | array( |
---|
| 38 | 'holiday_id' => '1', |
---|
| 39 | 'title' => 'TEST HOLIDAY1', |
---|
| 40 | 'month' => '2', |
---|
| 41 | 'day' => '14', |
---|
| 42 | 'rank' => '1', |
---|
| 43 | 'creator_id' => '1', |
---|
| 44 | 'create_date' => '2013-02-14 11:22:33', |
---|
| 45 | 'update_date' => '2013-02-14 22:11:33', |
---|
| 46 | 'del_flg' => '0' |
---|
| 47 | ), |
---|
| 48 | array( |
---|
| 49 | 'holiday_id' => '2', |
---|
| 50 | 'title' => 'TEST HOLIDAY2', |
---|
| 51 | 'month' => '3', |
---|
| 52 | 'day' => '26', |
---|
| 53 | 'rank' => '2', |
---|
| 54 | 'creator_id' => '1', |
---|
| 55 | 'create_date' => '2013-02-15 11:22:33', |
---|
| 56 | 'update_date' => '2013-02-16 22:11:33', |
---|
| 57 | 'del_flg' => '0' |
---|
| 58 | ) |
---|
| 59 | ); |
---|
| 60 | //休みの曜日を登録 |
---|
| 61 | $baseInfo = array( |
---|
| 62 | 'id' => '1', |
---|
| 63 | 'regular_holiday_ids' => '0|6', // 土日を休みに登録 |
---|
| 64 | 'update_date' => '2013-02-14 22:11:33' |
---|
| 65 | ); |
---|
| 66 | |
---|
| 67 | $objQuery->delete('dtb_holiday'); |
---|
| 68 | $objQuery->delete('dtb_baseinfo'); |
---|
| 69 | foreach ($holiday as $key => $item) { |
---|
| 70 | $objQuery->insert('dtb_holiday', $item); |
---|
| 71 | } |
---|
| 72 | $objQuery->insert('dtb_baseinfo', $baseInfo); |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | protected function tearDown() |
---|
| 76 | { |
---|
| 77 | parent::tearDown(); |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | ///////////////////////////////////////// |
---|
| 81 | |
---|
| 82 | public function testIsHoliday_日付が登録されている休日の場合_TRUEを返す() |
---|
| 83 | { |
---|
| 84 | |
---|
| 85 | $this->expected = true; |
---|
| 86 | $year = 2013; |
---|
| 87 | $month = 2; |
---|
| 88 | $day = 14; |
---|
| 89 | $this->actual = $this->objDate->isHoliday($year, $month, $day); |
---|
| 90 | |
---|
| 91 | $this->verify("登録された休日"); |
---|
| 92 | } |
---|
| 93 | |
---|
| 94 | public function testIsHoliday_日付が休日ではない場合_FALSEを返す() |
---|
| 95 | { |
---|
| 96 | |
---|
| 97 | $this->expected = false; |
---|
| 98 | $year = 2013; |
---|
| 99 | $month = 1; |
---|
| 100 | $day = 23; |
---|
| 101 | $this->actual = $this->objDate->isHoliday($year, $month, $day); |
---|
| 102 | |
---|
| 103 | $this->verify("休日ではない"); |
---|
| 104 | } |
---|
| 105 | |
---|
| 106 | public function testIsHoliday_休みの曜日の場合_trueを返す() |
---|
| 107 | { |
---|
| 108 | |
---|
| 109 | $this->expected = true; |
---|
| 110 | $year = 2013; |
---|
| 111 | $month = 3; |
---|
| 112 | $day = 10; |
---|
| 113 | $this->actual = $this->objDate->isHoliday($year, $month, $day); |
---|
| 114 | |
---|
| 115 | $this->verify("休みの曜日"); |
---|
| 116 | } |
---|
| 117 | |
---|
| 118 | public function testIsHoliday_休みの曜日でない場合_falseを返す() |
---|
| 119 | { |
---|
| 120 | |
---|
| 121 | $this->expected = false; |
---|
| 122 | $year = 2013; |
---|
| 123 | $month = 3; |
---|
| 124 | $day = 11; |
---|
| 125 | $this->actual = $this->objDate->isHoliday($year, $month, $day); |
---|
| 126 | |
---|
| 127 | $this->verify("休みの曜日"); |
---|
| 128 | } |
---|
| 129 | |
---|
| 130 | } |
---|
| 131 | |
---|