[22204] | 1 | <?php |
---|
| 2 | |
---|
| 3 | $HOME = realpath(dirname(__FILE__)) . "/../../../.."; |
---|
| 4 | require_once($HOME . "/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_TestBase.php"); |
---|
| 5 | /* |
---|
| 6 | * This file is part of EC-CUBE |
---|
| 7 | * |
---|
[22206] | 8 | * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved. |
---|
[22204] | 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_Helper_Purchase::registerOrderComplete()のテストクラス. |
---|
| 29 | * TODO 在庫の減少処理はエラー表示⇒exit呼び出しとなるためテスト不可. |
---|
| 30 | * |
---|
| 31 | * @author Hiroko Tamagawa |
---|
| 32 | * @version $Id$ |
---|
| 33 | */ |
---|
| 34 | |
---|
[22796] | 35 | class SC_Helper_Purchase_registerOrderCompleteTest extends SC_Helper_Purchase_TestBase { |
---|
[22204] | 36 | private $helper; |
---|
| 37 | |
---|
[22796] | 38 | protected function setUp() { |
---|
[22204] | 39 | parent::setUp(); |
---|
| 40 | $this->setUpOrderTemp(); |
---|
| 41 | $this->helper = new SC_Helper_Purchase_registerOrderCompleteMock(); |
---|
| 42 | } |
---|
| 43 | |
---|
[22796] | 44 | protected function tearDown() { |
---|
[22204] | 45 | parent::tearDown(); |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | ///////////////////////////////////////// |
---|
[22796] | 49 | public function testRegisterOrderComplete_不要な変数が含まれている場合_登録前に除外される() { |
---|
[22204] | 50 | // 引数の準備 |
---|
| 51 | $orderParams = array( |
---|
| 52 | 'order_id' => '1001', |
---|
| 53 | 'status' => ORDER_PAY_WAIT, |
---|
| 54 | 'mail_maga_flg' => '1', |
---|
| 55 | 'order_tax_rate' => '5', |
---|
| 56 | 'order_tax_rule' => '1' |
---|
| 57 | ); |
---|
| 58 | $cartSession = new SC_CartSession_registerOrderCompleteMock(); |
---|
| 59 | $_SESSION['site']['uniqid'] = '1001'; |
---|
| 60 | |
---|
| 61 | $this->helper->registerOrderComplete($orderParams, $cartSession, '1'); |
---|
| 62 | |
---|
| 63 | $this->expected = array( |
---|
| 64 | 'registerOrder' => array( |
---|
| 65 | 'order_id' => '1001', |
---|
| 66 | 'status' => ORDER_PAY_WAIT, |
---|
| 67 | 'mailmaga_flg' => null |
---|
| 68 | ), |
---|
| 69 | 'registerOrderDetail' => array( |
---|
| 70 | 'order_id' => '1001', |
---|
| 71 | 'params' => array( |
---|
| 72 | array( |
---|
| 73 | 'order_id' => '1001', |
---|
| 74 | 'product_id' => '1002', |
---|
| 75 | 'product_class_id' => '1002', |
---|
| 76 | 'product_name' => '製品02', |
---|
| 77 | 'product_code' => 'cd1002', |
---|
| 78 | 'classcategory_name1' => 'cat01', |
---|
| 79 | 'classcategory_name2' => 'cat02', |
---|
| 80 | 'point_rate' => '5', |
---|
| 81 | 'price' => '1000', |
---|
| 82 | 'quantity' => '10', |
---|
| 83 | 'tax_rate' => '5', |
---|
| 84 | 'tax_rule' => '1' |
---|
| 85 | ) |
---|
| 86 | ) |
---|
| 87 | ), |
---|
| 88 | 'del_flg' => '1' |
---|
| 89 | ); |
---|
| 90 | |
---|
| 91 | $this->actual = $_SESSION['testResult']; |
---|
| 92 | $this->actual['del_flg'] = $this->objQuery->get('del_flg', 'dtb_order_temp', 'order_temp_id = ?', '1001'); |
---|
| 93 | $this->verify(); |
---|
| 94 | } |
---|
| 95 | |
---|
[22796] | 96 | public function testRegisterOrderComplete_ステータスの指定がない場合_新規受付扱いとなる() { |
---|
[22204] | 97 | // 引数の準備 |
---|
| 98 | $orderParams = array( |
---|
| 99 | 'order_id' => '1001', |
---|
| 100 | // 'status' => ORDER_PAY_WAIT, |
---|
| 101 | 'order_tax_rate' => '5', |
---|
| 102 | 'order_tax_rule' => '1' |
---|
| 103 | ); |
---|
| 104 | $cartSession = new SC_CartSession_registerOrderCompleteMock(); |
---|
| 105 | $_SESSION['site']['uniqid'] = '1001'; |
---|
| 106 | |
---|
| 107 | $this->helper->registerOrderComplete($orderParams, $cartSession, '1'); |
---|
| 108 | |
---|
| 109 | // 上の条件と重複する部分は確認を省略 |
---|
| 110 | $this->expected = array( |
---|
| 111 | 'registerOrder' => array( |
---|
| 112 | 'order_id' => '1001', |
---|
| 113 | 'status' => ORDER_NEW, |
---|
| 114 | 'mailmaga_flg' => null |
---|
| 115 | ) |
---|
| 116 | ); |
---|
| 117 | |
---|
| 118 | $this->actual['registerOrder'] = $_SESSION['testResult']['registerOrder']; |
---|
| 119 | $this->verify(); |
---|
| 120 | } |
---|
| 121 | |
---|
| 122 | ////////////////////////////////////////// |
---|
| 123 | |
---|
| 124 | } |
---|
| 125 | |
---|
[22796] | 126 | class SC_Helper_Purchase_registerOrderCompleteMock extends SC_Helper_Purchase { |
---|
[22204] | 127 | |
---|
[22796] | 128 | function registerOrder($order_id, $params) { |
---|
[22204] | 129 | $_SESSION['testResult']['registerOrder'] = array( |
---|
| 130 | 'order_id' => $order_id, |
---|
| 131 | 'status' => $params['status'], |
---|
| 132 | 'mailmaga_flg' => $params['mailmaga_flg'] |
---|
| 133 | ); |
---|
| 134 | } |
---|
| 135 | |
---|
[22796] | 136 | function registerOrderDetail($order_id, $params) { |
---|
[22204] | 137 | $_SESSION['testResult']['registerOrderDetail'] = array( |
---|
| 138 | 'order_id' => $order_id, |
---|
| 139 | 'params' => $params |
---|
| 140 | ); |
---|
| 141 | } |
---|
| 142 | |
---|
[22796] | 143 | function setUniqId() {} |
---|
[22204] | 144 | } |
---|
| 145 | |
---|
[22796] | 146 | class SC_CartSession_registerOrderCompleteMock extends SC_CartSession { |
---|
[22204] | 147 | |
---|
| 148 | // カートの内容を取得 |
---|
[22796] | 149 | function getCartList($cartKey) { |
---|
[22204] | 150 | return array( |
---|
| 151 | array( |
---|
| 152 | 'productsClass' => array( |
---|
| 153 | 'product_id' => '1002', |
---|
| 154 | 'product_class_id' => '1002', |
---|
| 155 | 'name' => '製品02', |
---|
| 156 | 'product_code' => 'cd1002', |
---|
| 157 | 'classcategory_name1' => 'cat01', |
---|
| 158 | 'classcategory_name2' => 'cat02' |
---|
| 159 | ), |
---|
| 160 | 'point_rate' => '5', |
---|
| 161 | 'price' => '1000', |
---|
| 162 | 'quantity' => '10' |
---|
| 163 | ) |
---|
| 164 | ); |
---|
| 165 | } |
---|
| 166 | } |
---|
| 167 | ?> |
---|
| 168 | |
---|