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

Revision 23399, 7.9 KB checked in by kimoto, 10 years ago (diff)

#2536 add SC_CartSession_getAllCartList
getAllCartListのパフォーマンス向上が目的なのでテストは適当

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        $this->setUpClassCategory();
70        $this->setUpProducts();
71    }
72
73    /**
74     * DBに製品カテゴリ情報を登録します.
75     */
76    protected function setUpClassCategory()
77    {
78        $class_category = array(
79            array(
80                'update_date' => 'CURRENT_TIMESTAMP',
81                'classcategory_id' => '1001',
82                'class_id' => '1',
83                'creator_id' => '1',
84                'name' => 'cat1001'
85            ),
86            array(
87                'update_date' => 'CURRENT_TIMESTAMP',
88                'classcategory_id' => '1002',
89                'class_id' => '1',
90                'creator_id' => '1',
91                'name' => 'cat1002'
92            )
93        );
94
95        $this->objQuery->delete('dtb_classcategory');
96        foreach ($class_category as $key => $item) {
97            $this->objQuery->insert('dtb_classcategory', $item);
98        }
99    }
100
101    /**
102     * DBに製品情報を登録します.
103     */
104    protected function setUpProducts()
105    {
106        $products = array(
107            array(
108                'update_date' => 'CURRENT_TIMESTAMP',
109                'product_id' => '1001',
110                'name' => '製品名1001',
111                'comment1' => 'コメント10011',
112                'comment2' => 'コメント10012',
113                'comment3' => 'コメント10013',
114                'main_list_comment' => 'リストコメント1001',
115                'main_comment' => 'メインコメント1001',
116                'main_image' => '1001.jpg',
117                'main_list_image' => '1001-main.jpg',
118                'deliv_date_id' => '1',
119                'del_flg' => '0',
120                'creator_id' => '1',
121                'status' => '1'
122            ),
123            array(
124                'update_date' => 'CURRENT_TIMESTAMP',
125                'product_id' => '1002',
126                'name' => '製品名1002',
127                'comment1' => 'コメント10021',
128                'comment2' => 'コメント10022',
129                'comment3' => 'コメント10023',
130                'main_list_comment' => 'リストコメント1002',
131                'main_image' => '1002.jpg',
132                'main_list_image' => '1002-main.jpg',
133                'deliv_date_id' => '2',
134                'del_flg' => '0',
135                'creator_id' => '1',
136                'status' => '2'
137            ),
138            array(
139                'update_date' => 'CURRENT_TIMESTAMP',
140                'product_id' => '2001',
141                'name' => '製品名2001',
142                'comment1' => 'コメント20011',
143                'comment2' => 'コメント20012',
144                'comment3' => 'コメント20013',
145                'main_list_comment' => 'リストコメント2001',
146                'main_comment' => 'メインコメント2001',
147                'main_image' => '2001.jpg',
148                'main_list_image' => '2001-main.jpg',
149                'deliv_date_id' => '1',
150                'del_flg' => '1',
151                'creator_id' => '1',
152                'status' => '1'
153            )
154        );
155
156        $this->objQuery->delete('dtb_products');
157        foreach ($products as $key => $item) {
158            $this->objQuery->insert('dtb_products', $item);
159        }
160    }
161
162    /**
163     * DBに商品ステータス情報を登録します.
164     */
165    protected function setUpProductStatus()
166    {
167        $class_category = array(
168            array(
169                'update_date' => 'CURRENT_TIMESTAMP',
170                'product_status_id' => '1',
171                'product_id' => '1001',
172                'creator_id' => '1',
173                'del_flg' => '0'
174            ),
175            array(
176                'update_date' => 'CURRENT_TIMESTAMP',
177                'product_status_id' => '1',
178                'product_id' => '1002',
179                'creator_id' => '1',
180                'del_flg' => '0'
181            )
182        );
183
184        $this->objQuery->delete('dtb_product_status');
185        foreach ($class_category as $key => $item) {
186            $this->objQuery->insert('dtb_product_status', $item);
187        }
188    }
189
190
191    /**
192     * DBに商品クラス情報を大量に設定します.
193     */
194    protected function setUpBigProductClass()
195    {
196        $this->objQuery->delete('dtb_products_class');
197        // 商品を一気に投入
198        for ($i = 3000; $i < 3030; $i++) {
199            $item = array(
200                'update_date' => 'CURRENT_TIMESTAMP',
201                'product_class_id' => $i,
202                'product_id' => $i,
203                'product_type_id' => $i%3+1,
204                'product_code' => 'code'.$i,
205                'classcategory_id1' => '1001',
206                'classcategory_id2' => '1002',
207                'price01' => $i,
208                'price02' => $i,
209                'stock' => '99',
210                'creator_id' => '1',
211                'del_flg' => '0'
212            );
213            $this->objQuery->insert('dtb_products_class', $item);
214        }
215
216        $this->setUpClassCategory();
217        $this->setUpBigProducts();
218    }
219
220    /**
221     * DBに製品情報を大量に登録します.
222     */
223    protected function setUpBigProducts()
224    {
225        $this->objQuery->delete('dtb_products');
226        // 商品一気に投入
227        for ($i = 3000; $i < 3030; $i++) {
228            $item = array(
229                'update_date' => 'CURRENT_TIMESTAMP',
230                'product_id' => $i,
231                'name' => '製品名'.$i,
232                'comment1' => 'コメント'.$i,
233                'comment2' => 'コメント'.$i,
234                'comment3' => 'コメント'.$i,
235                'main_list_comment' => 'リストコメント'.$i,
236                'main_comment' => 'メインコメント'.$i,
237                'main_image' => $i.'.jpg',
238                'main_list_image' => $i.'-main.jpg',
239                'deliv_date_id' => '1',
240                'del_flg' => '0',
241                'creator_id' => '1',
242                'status' => '1'
243            );
244            $this->objQuery->insert('dtb_products', $item);
245        }
246    }
247}
Note: See TracBrowser for help on using the repository browser.