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

Revision 23540, 8.0 KB checked in by shutta, 10 years ago (diff)

#2588 商品管理>商品登録(商品規格) dtb_classcategory.del_flg を関知していない
テストケースで失敗するようになっているものが出ていたので修正。

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