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

Revision 23398, 7.1 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/SC_CartSession/SC_CartSession_TestBase.php");
5
6/**
7 * SC_CartSession_getCartListTest
8 *
9 * @package
10 * @version $id$
11 * @copyright
12 * @author Nobuhiko Kimoto <info@nob-log.info>
13 * @license
14 */
15class SC_CartSession_getCartListTest extends SC_CartSession_TestBase
16{
17
18    protected function setUp()
19    {
20        parent::setUp();
21        $this->objCartSession = new SC_CartSession_Ex();
22    }
23
24    protected function tearDown()
25    {
26        parent::tearDown();
27    }
28
29    /////////////////////////////////////////
30
31    /**
32     * @test
33     */
34    public function getCartList_商品を追加していなければ空の配列を返す()
35    {
36        $this->setUpProductClass();
37        //$this->setUpProducts();
38        //$this->setUpClassCategory();
39
40        $this->expected = 0;
41
42        $this->actual = count($this->objCartSession->getCartList(1));
43
44        $this->verify('商品数');
45    }
46
47    /**
48     * @test
49     */
50    public function getCartList_商品を1つ追加した場合1つの配列を返す()
51    {
52        $this->setUpProductClass();
53        //$this->setUpProducts();
54        //$this->setUpClassCategory();
55
56        $this->expected = 1;
57        $this->objCartSession->addProduct('1001', 1);
58
59        $cartList = $this->objCartSession->getCartList(1);
60        $this->actual = count($cartList);
61
62        $this->verify('商品数');
63
64        return $cartList;
65    }
66
67    /**
68     * @test
69     * @depends getCartList_商品を1つ追加した場合1つの配列を返す
70     */
71    public function getCartList_商品を1つ追加した場合合計数は1($cartList)
72    {
73        $this->expected = 1;
74        $this->actual = $cartList[0]['quantity'];
75        $this->verify('商品追加数');
76    }
77
78    /**
79     * @test
80     * @depends getCartList_商品を1つ追加した場合1つの配列を返す
81     */
82    public function getCartList_商品を1つ追加した場合商品データを返す($cartList)
83    {
84        $this->expected = array(
85            'product_id' => '1001'
86            ,'product_code_min' => 'code1001'
87            ,'product_code_max' => 'code1001'
88            ,'name' => '製品名1001'
89            ,'comment1' => 'コメント10011'
90            ,'comment2' => 'コメント10012'
91            ,'comment3' => 'コメント10013'
92            ,'main_list_comment' => 'リストコメント1001'
93            ,'main_image' => '1001.jpg'
94            ,'main_list_image' => '1001-main.jpg'
95            ,'price01_min' => '1500'
96            ,'price01_max' => '1500'
97            ,'price02_min' => '1500'
98            ,'price02_max' => '1500'
99            ,'stock_min' => '99'
100            ,'stock_max' => '99'
101            ,'stock_unlimited_min' => '0'
102            ,'stock_unlimited_max' => '0'
103            ,'deliv_date_id' => '1'
104            ,'status' => '1'
105            ,'del_flg' => '0'
106            ,'price01_min_inctax' => SC_Helper_TaxRule_Ex::sfCalcIncTax('1500')
107            ,'price01_max_inctax' => SC_Helper_TaxRule_Ex::sfCalcIncTax('1500')
108            ,'price02_min_inctax' => SC_Helper_TaxRule_Ex::sfCalcIncTax('1500')
109            ,'price02_max_inctax' => SC_Helper_TaxRule_Ex::sfCalcIncTax('1500')
110            ,'maker_id' => null
111            ,'comment4' => null
112            ,'comment5' => null
113            ,'comment6' => null
114            ,'note' => null
115            ,'main_comment' => 'メインコメント1001'
116            ,'main_large_image' => null
117            ,'sub_title1' => null
118            ,'sub_comment1' => null
119            ,'sub_image1' => null
120            ,'sub_large_image1' => null
121            ,'sub_title2' => null
122            ,'sub_comment2' => null
123            ,'sub_image2' => null
124            ,'sub_large_image2' => null
125            ,'sub_title3' => null
126            ,'sub_comment3' => null
127            ,'sub_image3' => null
128            ,'sub_large_image3' => null
129            ,'sub_title4' => null
130            ,'sub_comment4' => null
131            ,'sub_image4' => null
132            ,'sub_large_image4' => null
133            ,'sub_title5' => null
134            ,'sub_comment5' => null
135            ,'sub_image5' => null
136            ,'sub_large_image5' => null
137            ,'sub_title6' => null
138            ,'sub_comment6' => null
139            ,'sub_image6' => null
140            ,'sub_large_image6' => null
141            ,'creator_id' => '1'
142            ,'point_rate' => '0'
143            ,'deliv_fee' => null
144            ,'class_count' => '1'
145            ,'maker_name' => null
146            ,'stock' => '99'
147            ,'stock_unlimited' => '0'
148            ,'sale_limit' => null
149            ,'price01' => '1500'
150            ,'price02' => '1500'
151            ,'product_code' => 'code1001'
152            ,'product_class_id' => '1001'
153            ,'product_type_id' => '1'
154            ,'down_filename' => null
155            ,'down_realfilename' => null
156            ,'classcategory_name1' => 'cat1001'
157            ,'rank1' => null
158            ,'class_name1' => '味'
159            ,'class_id1' => '1'
160            ,'classcategory_id1' => '1001'
161            ,'classcategory_id2' => '1002'
162            ,'classcategory_name2' => 'cat1002'
163            ,'rank2' => null
164            ,'class_name2' => '味'
165            ,'class_id2' => '1'
166            ,'price01_inctax' => 1575.0
167            ,'price02_inctax' => 1575.0
168            //,'create_date' => '2014-05-04 12:20:29'
169            //,'update_date' => '2014-05-04 12:20:29'
170        );
171
172        // 時間はずれるので配列から削除
173        unset($cartList[0]['productsClass']['update_date']);
174        unset($cartList[0]['productsClass']['create_date']);
175
176        $this->actual = $cartList[0]['productsClass'];
177        $this->verify('商品詳細');
178    }
179
180
181    /**
182     * @test
183     */
184    public function getCartList_削除済み商品を追加した場合はカートは空()
185    {
186        $this->setUpProductClass();
187        //$this->setUpProducts();
188        //$this->setUpClassCategory();
189
190        $this->expected = 0;
191        $this->objCartSession->addProduct('2001', 1);
192
193        $cartList = $this->objCartSession->getCartList(1);
194        $this->actual = count($cartList);
195        $this->verify('商品数');
196    }
197
198    /**
199     * @test
200     */
201    /* バグな気がする?
202    public function getCartList_非表示商品を追加した場合はカートは空()
203    {
204        $this->setUpProductClass();
205        $this->setUpProducts();
206        $this->setUpClassCategory();
207
208        $this->expected = 0;
209        $this->objCartSession->addProduct('1002', 1);
210        $cartList = $this->objCartSession->getCartList(2);
211        $this->actual = count($cartList);
212        $this->verify('商品数');
213    }*/
214
215    /**
216     * @test
217     */
218    public function getCartList_複数商品種別の30商品を追加した場合カートに30商品追加されている()
219    {
220        $this->setUpBigProductClass();
221        $this->expected = 30;
222        for ($i = 3000; $i < 3030; $i++) {
223            $this->objCartSession->addProduct($i, 1);
224        }
225        $cartList = count($this->objCartSession->getCartList(1)) + count($this->objCartSession->getCartList(2)) + count($this->objCartSession->getCartList(3));
226        $this->actual = $cartList;
227
228        $this->verify('商品数');
229    }
230}
Note: See TracBrowser for help on using the repository browser.