1 | <?php |
---|
2 | |
---|
3 | $HOME = realpath(dirname(__FILE__)) . "/../../../.."; |
---|
4 | require_once($HOME . "/tests/class/Common_TestCase.php"); |
---|
5 | /* |
---|
6 | * This file is part of EC-CUBE |
---|
7 | * |
---|
8 | * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved. |
---|
9 | * |
---|
10 | * http://www.lockon.co.jp/ |
---|
11 | * |
---|
12 | * This program is free software; you can redistribute it and/or |
---|
13 | * modify it under the terms of the GNU General Public License |
---|
14 | * as published by the Free Software Foundation; either version 2 |
---|
15 | * of the License, or (at your option) any later version. |
---|
16 | * |
---|
17 | * This program is distributed in the hope that it will be useful, |
---|
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
20 | * GNU General Public License for more details. |
---|
21 | * |
---|
22 | * You should have received a copy of the GNU General Public License |
---|
23 | * along with this program; if not, write to the Free Software |
---|
24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
25 | */ |
---|
26 | |
---|
27 | /** |
---|
28 | * SC_Utils::sfGetProductClassId()のテストクラス. |
---|
29 | * TODO del_flgは使わなくて良い?? |
---|
30 | * TODO classcategory_id1とclasscategory_id2を使わないと一意に指定できない。 |
---|
31 | * @author Hiroko Tamagawa |
---|
32 | * @version $Id$ |
---|
33 | */ |
---|
34 | class SC_Utils_sfGetProductClassIdTest extends Common_TestCase { |
---|
35 | |
---|
36 | |
---|
37 | protected function setUp() { |
---|
38 | parent::setUp(); |
---|
39 | $this->setUpProductsClass(); |
---|
40 | } |
---|
41 | |
---|
42 | protected function tearDown() { |
---|
43 | parent::tearDown(); |
---|
44 | } |
---|
45 | |
---|
46 | ///////////////////////////////////////// |
---|
47 | public function testSfGetProductClassId_存在する製品IDのみを指定した場合_カテゴリ0の対応する製品クラスが取得できる() { |
---|
48 | |
---|
49 | $this->expected = '2001'; |
---|
50 | $this->actual = SC_Utils::sfGetProductClassId('2001'); |
---|
51 | |
---|
52 | $this->verify('取得した製品クラス'); |
---|
53 | } |
---|
54 | |
---|
55 | public function testSfGetProductClassId_存在する製品IDのみを指定してカテゴリ0の製品クラスが存在しなければ_nullが返る() { |
---|
56 | |
---|
57 | $this->expected = null; |
---|
58 | $this->actual = SC_Utils::sfGetProductClassId('1001'); |
---|
59 | |
---|
60 | $this->verify('取得結果が空'); |
---|
61 | } |
---|
62 | |
---|
63 | public function testSfGetProductClassId_存在する製品IDとカテゴリIDを指定した場合_対応する製品クラスが取得できる() { |
---|
64 | |
---|
65 | $this->expected = '1002'; |
---|
66 | $this->actual = SC_Utils::sfGetProductClassId('1001', '2'); |
---|
67 | |
---|
68 | $this->verify('取得した製品クラス'); |
---|
69 | } |
---|
70 | |
---|
71 | public function testSfGetProductClassId_存在する製品IDと存在しないカテゴリIDを指定した場合_nullが返る() { |
---|
72 | |
---|
73 | $this->expected = null; |
---|
74 | $this->actual = SC_Utils::sfGetProductClassId('1001', '999'); |
---|
75 | |
---|
76 | $this->verify('取得結果が空'); |
---|
77 | } |
---|
78 | |
---|
79 | public function testSfGetProductClassId_存在しない製品IDを指定した場合_nullが返る() { |
---|
80 | $this->expected = null; |
---|
81 | $this->actual = SC_Utils::sfGetProductClassId('9999'); |
---|
82 | |
---|
83 | $this->verify('取得結果が空'); |
---|
84 | } |
---|
85 | |
---|
86 | ////////////////////////////////////////// |
---|
87 | protected function setUpProductsClass() { |
---|
88 | $products_class = array( |
---|
89 | array( |
---|
90 | 'product_class_id' => '2001', |
---|
91 | 'product_id' => '2001', |
---|
92 | 'price02' => '1000', |
---|
93 | 'creator_id' => '1', |
---|
94 | 'update_date' => 'CURRENT_TIMESTAMP' |
---|
95 | ), |
---|
96 | array( |
---|
97 | 'product_class_id' => '1001', |
---|
98 | 'product_id' => '1001', |
---|
99 | 'price02' => '1000', |
---|
100 | 'classcategory_id1' => '1', |
---|
101 | 'creator_id' => '1', |
---|
102 | 'update_date' => 'CURRENT_TIMESTAMP' |
---|
103 | ), |
---|
104 | array( |
---|
105 | 'product_class_id' => '1002', |
---|
106 | 'product_id' => '1001', |
---|
107 | 'price02' => '1000', |
---|
108 | 'classcategory_id1' => '2', |
---|
109 | 'creator_id' => '1', |
---|
110 | 'update_date' => 'CURRENT_TIMESTAMP' |
---|
111 | ) |
---|
112 | ); |
---|
113 | |
---|
114 | $this->objQuery->delete('dtb_products_class'); |
---|
115 | foreach ($products_class as $item) { |
---|
116 | $this->objQuery->insert('dtb_products_class', $item); |
---|
117 | } |
---|
118 | } |
---|
119 | } |
---|
120 | |
---|