1 | <?php |
---|
2 | |
---|
3 | $HOME = realpath(dirname(__FILE__)) . "/../../../.."; |
---|
4 | require_once($HOME . "/tests/class/helper/SC_Helper_BestProducts/SC_Helper_BestProducts_TestBase.php"); |
---|
5 | /* |
---|
6 | * This file is part of EC-CUBE |
---|
7 | * |
---|
8 | * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved. |
---|
9 | * |
---|
10 | * http://www.lockon.co.jp/ |
---|
11 | * |
---|
12 | * This program is free software; you can redistribute it and/or |
---|
13 | * modify it under the terms of the GNU General Public License |
---|
14 | * as published by the Free Software Foundation; either version 2 |
---|
15 | * of the License, or (at your option) any later version. |
---|
16 | * |
---|
17 | * This program is distributed in the hope that it will be useful, |
---|
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
20 | * GNU General Public License for more details. |
---|
21 | * |
---|
22 | * You should have received a copy of the GNU General Public License |
---|
23 | * along with this program; if not, write to the Free Software |
---|
24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
25 | */ |
---|
26 | |
---|
27 | /** |
---|
28 | * SC_Helper_BestProducts::getList()のテストクラス. |
---|
29 | * |
---|
30 | * @author hiroshi kakuta |
---|
31 | */ |
---|
32 | class SC_Helper_BestProducts_getListTest extends SC_Helper_BestProducts_TestBase |
---|
33 | { |
---|
34 | protected function setUp() |
---|
35 | { |
---|
36 | parent::setUp(); |
---|
37 | |
---|
38 | } |
---|
39 | |
---|
40 | protected function tearDown() |
---|
41 | { |
---|
42 | parent::tearDown(); |
---|
43 | } |
---|
44 | |
---|
45 | /** rankが存在しない場合、空を返す。 |
---|
46 | */ |
---|
47 | public function testGetList_存在しない場合空を返す() |
---|
48 | { |
---|
49 | |
---|
50 | $this->deleteAllBestProducts(); |
---|
51 | |
---|
52 | $this->expected = array(); |
---|
53 | $this->actual = SC_Helper_BestProducts_Ex::getList(); |
---|
54 | |
---|
55 | $this->verify(); |
---|
56 | } |
---|
57 | |
---|
58 | public function testGetList_データがある場合_想定した結果が返る(){ |
---|
59 | |
---|
60 | $this->setUpBestProducts(); |
---|
61 | |
---|
62 | |
---|
63 | $this->expected = array( |
---|
64 | 0=>array( |
---|
65 | 'best_id' => '1001', |
---|
66 | 'product_id'=>'2', |
---|
67 | 'category_id' => '0', |
---|
68 | 'rank' => '1', |
---|
69 | 'title' => 'タイトルですよ', |
---|
70 | 'comment' => 'コメントですよ', |
---|
71 | 'creator_id' => '1', |
---|
72 | 'create_date' => '2000-01-01 00:00:00', |
---|
73 | 'update_date' => '2000-01-01 00:00:00', |
---|
74 | 'del_flg' => '0' |
---|
75 | ), |
---|
76 | 1=>array( |
---|
77 | 'best_id' => '1003', |
---|
78 | 'product_id'=>'3', |
---|
79 | 'category_id' => '1', |
---|
80 | 'rank' => '3', |
---|
81 | 'title' => 'タイトルですよ3', |
---|
82 | 'comment' => 'コメントですよ3', |
---|
83 | 'creator_id' => '3', |
---|
84 | 'create_date' => '2000-01-01 00:00:00', |
---|
85 | 'update_date' => '2000-01-01 00:00:00', |
---|
86 | 'del_flg' => '0' |
---|
87 | |
---|
88 | ) |
---|
89 | ); |
---|
90 | |
---|
91 | |
---|
92 | $this->actual = SC_Helper_BestProducts_Ex::getList(); |
---|
93 | $this->verify(); |
---|
94 | |
---|
95 | } |
---|
96 | |
---|
97 | public function testGetList_一覧取得has_deleteをtrueにした場合削除済みデータも取得(){ |
---|
98 | |
---|
99 | $this->setUpBestProducts(); |
---|
100 | |
---|
101 | |
---|
102 | $this->expected = array( |
---|
103 | 0=>array( |
---|
104 | 'best_id' => '1001', |
---|
105 | 'product_id'=>'2', |
---|
106 | 'category_id' => '0', |
---|
107 | 'rank' => '1', |
---|
108 | 'title' => 'タイトルですよ', |
---|
109 | 'comment' => 'コメントですよ', |
---|
110 | 'creator_id' => '1', |
---|
111 | 'create_date' => '2000-01-01 00:00:00', |
---|
112 | 'update_date' => '2000-01-01 00:00:00', |
---|
113 | 'del_flg' => '0' |
---|
114 | ), |
---|
115 | 1=>array( |
---|
116 | 'best_id' => '1002', |
---|
117 | 'product_id'=>'1', |
---|
118 | 'category_id' => '0', |
---|
119 | 'rank' => '2', |
---|
120 | 'title' => 'タイトルですよ', |
---|
121 | 'comment' => 'コメントですよ', |
---|
122 | 'creator_id' => '1', |
---|
123 | 'create_date' => '2000-01-01 00:00:00', |
---|
124 | 'update_date' => '2000-01-01 00:00:00', |
---|
125 | 'del_flg' => '1' |
---|
126 | ), |
---|
127 | 2=>array( |
---|
128 | 'best_id' => '1003', |
---|
129 | 'product_id'=>'3', |
---|
130 | 'category_id' => '1', |
---|
131 | 'rank' => '3', |
---|
132 | 'title' => 'タイトルですよ3', |
---|
133 | 'comment' => 'コメントですよ3', |
---|
134 | 'creator_id' => '3', |
---|
135 | 'create_date' => '2000-01-01 00:00:00', |
---|
136 | 'update_date' => '2000-01-01 00:00:00', |
---|
137 | 'del_flg' => '0' |
---|
138 | |
---|
139 | ) |
---|
140 | ); |
---|
141 | |
---|
142 | |
---|
143 | $this->actual = SC_Helper_BestProducts_Ex::getList(0,0,true); |
---|
144 | $this->verify(); |
---|
145 | |
---|
146 | } |
---|
147 | |
---|
148 | |
---|
149 | |
---|
150 | public function testGetList_ページングが想定した結果が返る_表示件数1_ページ番号2(){ |
---|
151 | |
---|
152 | $this->setUpBestProducts(); |
---|
153 | |
---|
154 | $this->expected = array( |
---|
155 | 0=>array( |
---|
156 | 'best_id' => '1003', |
---|
157 | 'product_id'=>'3', |
---|
158 | 'category_id' => '1', |
---|
159 | 'rank' => '3', |
---|
160 | 'title' => 'タイトルですよ3', |
---|
161 | 'comment' => 'コメントですよ3', |
---|
162 | 'creator_id' => '3', |
---|
163 | 'create_date' => '2000-01-01 00:00:00', |
---|
164 | 'update_date' => '2000-01-01 00:00:00', |
---|
165 | 'del_flg' => '0' |
---|
166 | ) |
---|
167 | ); |
---|
168 | |
---|
169 | |
---|
170 | $this->actual = SC_Helper_BestProducts_Ex::getList(1,2); |
---|
171 | $this->verify(); |
---|
172 | |
---|
173 | } |
---|
174 | |
---|
175 | |
---|
176 | public function testGetList_ページングが想定した結果が返る_表示件数1_ページ番号0(){ |
---|
177 | |
---|
178 | $this->setUpBestProducts(); |
---|
179 | |
---|
180 | |
---|
181 | $this->expected = array( |
---|
182 | 0=>array( |
---|
183 | 'best_id' => '1001', |
---|
184 | 'product_id'=>'2', |
---|
185 | 'category_id' => '0', |
---|
186 | 'rank' => '1', |
---|
187 | 'title' => 'タイトルですよ', |
---|
188 | 'comment' => 'コメントですよ', |
---|
189 | 'creator_id' => '1', |
---|
190 | 'create_date' => '2000-01-01 00:00:00', |
---|
191 | 'update_date' => '2000-01-01 00:00:00', |
---|
192 | 'del_flg' => '0' |
---|
193 | ) |
---|
194 | ); |
---|
195 | |
---|
196 | $this->actual = SC_Helper_BestProducts_Ex::getList(1,0); |
---|
197 | $this->verify(); |
---|
198 | |
---|
199 | } |
---|
200 | |
---|
201 | } |
---|
202 | |
---|