source: branches/version-2_13-dev/tests/class/SC_CartSession/SC_CartSession_TestBase.php @ 23398

Revision 23398, 9.4 KB checked in by kimoto, 10 years ago (diff)

#2536 add SC_CartSession_getCartListTest
dtb_sessionのsess_dataのパフォーマンステストを含む

Line 
1<?php
2
3$HOME = realpath(dirname(__FILE__)) . "/../../..";
4require_once($HOME . "/tests/class/Common_TestCase.php");
5/**
6 *
7 */
8class SC_CartSession_TestBase extends Common_TestCase
9{
10    protected function setUp()
11    {
12        parent::setUp();
13    }
14
15    protected function tearDown()
16    {
17        parent::tearDown();
18    }
19
20    /**
21     * DBに商品クラス情報を設定します.
22     */
23    protected function setUpProductClass()
24    {
25        $product_class = array(
26            array(
27                'update_date' => 'CURRENT_TIMESTAMP',
28                'product_class_id' => '1001',
29                'product_id' => '1001',
30                'product_type_id' => '1',
31                'product_code' => 'code1001',
32                'classcategory_id1' => '1001',
33                'classcategory_id2' => '1002',
34                'price01' => '1500',
35                'price02' => '1500',
36                'stock' => '99',
37                'creator_id' => '1',
38                'del_flg' => '0'
39            ),
40            array(
41                'update_date' => 'CURRENT_TIMESTAMP',
42                'product_class_id' => '1002',
43                'product_id' => '1002',
44                'product_type_id' => '2',
45                'product_code' => 'code1002',
46                'price02' => '2500',
47                'creator_id' => '1',
48                'stock_unlimited' => '1',
49                'del_flg' => '0'
50            ),
51            array(
52                'update_date' => 'CURRENT_TIMESTAMP',
53                'product_class_id' => '2001',
54                'product_id' => '2001',
55                'product_type_id' => '1',
56                'product_code' => 'code2001',
57                'price02' => '2000',
58                'creator_id' => '1',
59                'stock_unlimited' => '1',
60                'del_flg' => '1'
61            )
62        );
63
64        $this->objQuery->delete('dtb_products_class');
65        foreach ($product_class as $key => $item) {
66            $this->objQuery->insert('dtb_products_class', $item);
67        }
68
69        // 1000商品一気に投入
70        for ($i = 3000; $i < 3100; $i++) {
71            $item = array(
72                'update_date' => 'CURRENT_TIMESTAMP',
73                'product_class_id' => $i,
74                'product_id' => $i,
75                'product_type_id' => '1',
76                'product_code' => 'code'.$i,
77                'classcategory_id1' => '1001',
78                'classcategory_id2' => '1002',
79                'price01' => $i,
80                'price02' => $i,
81                'stock' => '99',
82                'creator_id' => '1',
83                'del_flg' => '0'
84            );
85            $this->objQuery->insert('dtb_products_class', $item);
86        }
87
88        $this->setUpClassCategory();
89        $this->setUpProducts();
90    }
91
92    /**
93     * DBに製品カテゴリ情報を登録します.
94     */
95    protected function setUpClassCategory()
96    {
97        $class_category = array(
98            array(
99                'update_date' => 'CURRENT_TIMESTAMP',
100                'classcategory_id' => '1001',
101                'class_id' => '1',
102                'creator_id' => '1',
103                'name' => 'cat1001'
104            ),
105            array(
106                'update_date' => 'CURRENT_TIMESTAMP',
107                'classcategory_id' => '1002',
108                'class_id' => '1',
109                'creator_id' => '1',
110                'name' => 'cat1002'
111            )
112        );
113
114        $this->objQuery->delete('dtb_classcategory');
115        foreach ($class_category as $key => $item) {
116            $this->objQuery->insert('dtb_classcategory', $item);
117        }
118    }
119
120    /**
121     * DBに製品情報を登録します.
122     */
123    protected function setUpProducts()
124    {
125        $products = array(
126            array(
127                'update_date' => 'CURRENT_TIMESTAMP',
128                'product_id' => '1001',
129                'name' => '製品名1001',
130                'comment1' => 'コメント10011',
131                'comment2' => 'コメント10012',
132                'comment3' => 'コメント10013',
133                'main_list_comment' => 'リストコメント1001',
134                'main_comment' => 'メインコメント1001',
135                'main_image' => '1001.jpg',
136                'main_list_image' => '1001-main.jpg',
137                'deliv_date_id' => '1',
138                'del_flg' => '0',
139                'creator_id' => '1',
140                'status' => '1'
141            ),
142            array(
143                'update_date' => 'CURRENT_TIMESTAMP',
144                'product_id' => '1002',
145                'name' => '製品名1002',
146                'comment1' => 'コメント10021',
147                'comment2' => 'コメント10022',
148                'comment3' => 'コメント10023',
149                'main_list_comment' => 'リストコメント1002',
150                'main_image' => '1002.jpg',
151                'main_list_image' => '1002-main.jpg',
152                'deliv_date_id' => '2',
153                'del_flg' => '0',
154                'creator_id' => '1',
155                'status' => '2'
156            ),
157            array(
158                'update_date' => 'CURRENT_TIMESTAMP',
159                'product_id' => '2001',
160                'name' => '製品名2001',
161                'comment1' => 'コメント20011',
162                'comment2' => 'コメント20012',
163                'comment3' => 'コメント20013',
164                'main_list_comment' => 'リストコメント2001',
165                'main_comment' => 'メインコメント2001',
166                'main_image' => '2001.jpg',
167                'main_list_image' => '2001-main.jpg',
168                'deliv_date_id' => '1',
169                'del_flg' => '1',
170                'creator_id' => '1',
171                'status' => '1'
172            )
173        );
174
175        $this->objQuery->delete('dtb_products');
176        foreach ($products as $key => $item) {
177            $this->objQuery->insert('dtb_products', $item);
178        }
179
180        // 100商品一気に投入
181        for ($i = 3000; $i < 4000; $i++) {
182            $item = array(
183                'update_date' => 'CURRENT_TIMESTAMP',
184                'product_id' => $i,
185                'name' => '製品名'.$i,
186                'comment1' => 'コメント'.$i,
187                'comment2' => 'コメント'.$i,
188                'comment3' => 'コメント'.$i,
189                'main_list_comment' => 'リストコメント'.$i,
190                'main_comment' => 'メインコメント'.$i,
191                'main_image' => $i.'.jpg',
192                'main_list_image' => $i.'-main.jpg',
193                'deliv_date_id' => '1',
194                'del_flg' => '0',
195                'creator_id' => '1',
196                'status' => '1'
197            );
198            $this->objQuery->insert('dtb_products', $item);
199        }
200    }
201
202    /**
203     * DBに商品ステータス情報を登録します.
204     */
205    protected function setUpProductStatus()
206    {
207        $class_category = array(
208            array(
209                'update_date' => 'CURRENT_TIMESTAMP',
210                'product_status_id' => '1',
211                'product_id' => '1001',
212                'creator_id' => '1',
213                'del_flg' => '0'
214            ),
215            array(
216                'update_date' => 'CURRENT_TIMESTAMP',
217                'product_status_id' => '1',
218                'product_id' => '1002',
219                'creator_id' => '1',
220                'del_flg' => '0'
221            )
222        );
223
224        $this->objQuery->delete('dtb_product_status');
225        foreach ($class_category as $key => $item) {
226            $this->objQuery->insert('dtb_product_status', $item);
227        }
228    }
229
230
231    /**
232     * DBに商品クラス情報を大量に設定します.
233     */
234    protected function setUpBigProductClass()
235    {
236        $this->objQuery->delete('dtb_products_class');
237        // 商品を一気に投入
238        for ($i = 3000; $i < 3030; $i++) {
239            $item = array(
240                'update_date' => 'CURRENT_TIMESTAMP',
241                'product_class_id' => $i,
242                'product_id' => $i,
243                'product_type_id' => $i%3+1,
244                'product_code' => 'code'.$i,
245                'classcategory_id1' => '1001',
246                'classcategory_id2' => '1002',
247                'price01' => $i,
248                'price02' => $i,
249                'stock' => '99',
250                'creator_id' => '1',
251                'del_flg' => '0'
252            );
253            $this->objQuery->insert('dtb_products_class', $item);
254        }
255
256        $this->setUpClassCategory();
257        $this->setUpBigProducts();
258    }
259
260    /**
261     * DBに製品情報を大量に登録します.
262     */
263    protected function setUpBigProducts()
264    {
265        $this->objQuery->delete('dtb_products');
266        // 商品一気に投入
267        for ($i = 3000; $i < 3030; $i++) {
268            $item = array(
269                'update_date' => 'CURRENT_TIMESTAMP',
270                'product_id' => $i,
271                'name' => '製品名'.$i,
272                'comment1' => 'コメント'.$i,
273                'comment2' => 'コメント'.$i,
274                'comment3' => 'コメント'.$i,
275                'main_list_comment' => 'リストコメント'.$i,
276                'main_comment' => 'メインコメント'.$i,
277                'main_image' => $i.'.jpg',
278                'main_list_image' => $i.'-main.jpg',
279                'deliv_date_id' => '1',
280                'del_flg' => '0',
281                'creator_id' => '1',
282                'status' => '1'
283            );
284            $this->objQuery->insert('dtb_products', $item);
285        }
286    }
287}
Note: See TracBrowser for help on using the repository browser.