source: branches/version-2_13-dev/tests/class/SC_Product/SC_Product_TestBase.php @ 23555

Revision 23555, 6.8 KB checked in by shutta, 10 years ago (diff)

#1993 [共通クラス]SC_Product
dtb_classテーブルのデータ初期化が漏れていたので追加。(必要なデータはクラス内で用意させる)
setUp周りの冗長な処理を改善。

Line 
1<?php
2
3$HOME = realpath(dirname(__FILE__)) . "/../../..";
4require_once($HOME . "/tests/class/Common_TestCase.php");
5/**
6 *
7 */
8class SC_Product_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{
67            $this->objQuery->insert('dtb_products_class', $item);
68        }
69
70        $this->setUpClass();
71        $this->setUpClassCategory();
72        $this->setUpProducts();
73    }
74
75    /**
76     * DBに規格分類情報を登録します.
77     */
78    protected function setUpClass()
79    {
80        $table = 'dtb_class';
81
82        $data = array(
83            array(
84                'class_id' => 1,
85                'name' => '味',
86                'rank' => 1,
87                'creator_id' => 1,
88                'update_date' => 'CURRENT_TIMESTAMP',
89            ),
90        );
91
92        $this->objQuery->delete($table);
93        foreach ($data as $item) {
94            $this->objQuery->insert($table, $item);
95        }
96    }
97
98    /**
99     * DBに製品カテゴリ情報を登録します.
100     */
101    protected function setUpClassCategory()
102    {
103        $class_category = array(
104            array(
105                'update_date' => 'CURRENT_TIMESTAMP',
106                'classcategory_id' => '1001',
107                'class_id' => '1',
108                'creator_id' => '1',
109                'name' => 'cat1001',
110                'rank' => 1,
111                  ),
112            array(
113                'update_date' => 'CURRENT_TIMESTAMP',
114                'classcategory_id' => '1002',
115                'class_id' => '1',
116                'creator_id' => '1',
117                'name' => 'cat1002',
118                'rank' => 2,
119                  )
120                                );
121
122        // classcategory_id=0のものは削除しない
123        $this->objQuery->delete('dtb_classcategory', 'classcategory_id <> 0');
124        foreach ($class_category as $key => $item) {
125            $this->objQuery->insert('dtb_classcategory', $item);
126        }
127    }
128
129    /**
130     * DBに製品情報を登録します.
131     */
132    protected function setUpProducts()
133    {
134        $products = array(
135            array(
136                'update_date' => 'CURRENT_TIMESTAMP',
137                'product_id' => '1001',
138                'name' => '製品名1001',
139                'comment1' => 'コメント10011',
140                'comment2' => 'コメント10012',
141                'comment3' => 'コメント10013',
142                'main_list_comment' => 'リストコメント1001',
143                'main_comment' => 'メインコメント1001',
144                'main_image' => '1001.jpg',
145                'main_list_image' => '1001-main.jpg',
146                'deliv_date_id' => '1',
147                'del_flg' => '0',
148                'creator_id' => '1',
149                'status' => '1'
150                  ),
151            array(
152                'update_date' => 'CURRENT_TIMESTAMP',
153                'product_id' => '1002',
154                'name' => '製品名1002',
155                'comment1' => 'コメント10021',
156                'comment2' => 'コメント10022',
157                'comment3' => 'コメント10023',
158                'main_list_comment' => 'リストコメント1002',
159                'main_image' => '1002.jpg',
160                'main_list_image' => '1002-main.jpg',
161                'deliv_date_id' => '2',
162                'del_flg' => '0',
163                'creator_id' => '1',
164                'status' => '2'
165                  ),
166            array(
167                'update_date' => 'CURRENT_TIMESTAMP',
168                'product_id' => '2001',
169                'name' => '製品名2001',
170                'comment1' => 'コメント20011',
171                'comment2' => 'コメント20012',
172                'comment3' => 'コメント20013',
173                'main_list_comment' => 'リストコメント2001',
174                'main_comment' => 'メインコメント2001',
175                'main_image' => '2001.jpg',
176                'main_list_image' => '2001-main.jpg',
177                'deliv_date_id' => '1',
178                'del_flg' => '1',
179                'creator_id' => '1',
180                'status' => '1'
181                  )
182                          );
183
184        $this->objQuery->delete('dtb_products');
185        foreach ($products as $key => $item) {
186            $this->objQuery->insert('dtb_products', $item);
187        }
188    }
189   
190    /**
191     * DBに商品ステータス情報を登録します.
192     */
193    protected function setUpProductStatus()
194    {
195        $class_category = array(
196            array(
197                'update_date' => 'CURRENT_TIMESTAMP',
198                'product_status_id' => '1',
199                'product_id' => '1001',
200                'creator_id' => '1',
201                'del_flg' => '0'
202                  ),
203            array(
204                'update_date' => 'CURRENT_TIMESTAMP',
205                'product_status_id' => '1',
206                'product_id' => '1002',
207                'creator_id' => '1',
208                'del_flg' => '0'
209                  )
210                                );
211
212        $this->objQuery->delete('dtb_product_status');
213        foreach ($class_category as $key => $item) {
214            $this->objQuery->insert('dtb_product_status', $item);
215        }
216    }
217}
Note: See TracBrowser for help on using the repository browser.