[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 | * |
---|
| 8 | * Copyright(c) 2000-2012 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_Helper_Purchase::completeOrder()のテストクラス. |
---|
| 29 | * |
---|
| 30 | * |
---|
| 31 | * @author Hiroko Tamagawa |
---|
| 32 | * @version $Id$ |
---|
| 33 | */ |
---|
| 34 | class SC_Helper_Purchase_completeOrderTest extends SC_Helper_Purchase_TestBase { |
---|
| 35 | |
---|
| 36 | private $helper; |
---|
| 37 | |
---|
| 38 | protected function setUp() { |
---|
| 39 | parent::setUp(); |
---|
| 40 | $this->setUpOrderTemp(); // order_temp_id = '1001' |
---|
| 41 | $this->setUpShipping(); |
---|
| 42 | $this->setUpCustomer(); |
---|
| 43 | |
---|
| 44 | $_SESSION['cartKey'] = '1'; |
---|
| 45 | $_SESSION['site'] = array( |
---|
| 46 | 'pre_page' => 'pre', |
---|
| 47 | 'now_page' => 'now', |
---|
| 48 | 'regist_success' => TRUE, |
---|
| 49 | 'uniqid' => '1001' |
---|
| 50 | ); |
---|
| 51 | |
---|
| 52 | $this->helper = new SC_Helper_Purchase_completeOrderMock(); |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | protected function tearDown() { |
---|
| 56 | parent::tearDown(); |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | ///////////////////////////////////////// |
---|
| 60 | // 適切なfunctionが呼ばれていることのみ確認 |
---|
| 61 | public function testCompleteOrder_顧客IDが指定されている場合_購入日が更新される() { |
---|
| 62 | $_SESSION['customer']['customer_id'] = '1002'; // 顧客ID |
---|
| 63 | $this->helper->completeOrder(ORDER_DELIV); |
---|
| 64 | |
---|
| 65 | $this->expected = array( |
---|
| 66 | 'verifyChangeCart' => array( |
---|
| 67 | 'uniqId' => '1001' |
---|
| 68 | ), |
---|
| 69 | 'getOrderTemp' => array( |
---|
| 70 | 'uniqId' => '1001' |
---|
| 71 | ), |
---|
| 72 | 'registerOrderComplete' => array( |
---|
| 73 | 'order_temp_id' => '1001', |
---|
| 74 | 'status' => ORDER_DELIV, |
---|
| 75 | 'cartKey' => '1' |
---|
| 76 | ), |
---|
| 77 | 'registerShipmentItem' => array( |
---|
| 78 | array( |
---|
| 79 | 'order_id' => '1001', |
---|
| 80 | 'shipping_id' => '00001', |
---|
| 81 | 'shipment_item' => '商品1' |
---|
| 82 | ) |
---|
| 83 | ), |
---|
| 84 | 'registerShipping' => array( |
---|
| 85 | 'order_id' => '1001' |
---|
| 86 | ), |
---|
| 87 | 'cleanupSession' => array( |
---|
| 88 | 'order_id' => '1001', |
---|
| 89 | 'cartKey' => '1' |
---|
| 90 | ) |
---|
| 91 | ); |
---|
| 92 | $this->actual = $_SESSION['testResult']; |
---|
| 93 | $this->verify('適切なfunctionが呼ばれている'); |
---|
| 94 | $last_buy_date = $this->objQuery->get('last_buy_date', 'dtb_customer', 'customer_id = ?', '1002'); |
---|
| 95 | $this->assertNotNull($last_buy_date, '最終購入日'); |
---|
| 96 | } |
---|
| 97 | |
---|
| 98 | public function testCompleteOrder_顧客IDが指定されていない場合_特にエラーなく修了できる() { |
---|
| 99 | $this->helper->completeOrder(); // デフォルトのステータス(NEW) |
---|
| 100 | |
---|
| 101 | $this->expected = array( |
---|
| 102 | 'verifyChangeCart' => array( |
---|
| 103 | 'uniqId' => '1001' |
---|
| 104 | ), |
---|
| 105 | 'getOrderTemp' => array( |
---|
| 106 | 'uniqId' => '1001' |
---|
| 107 | ), |
---|
| 108 | 'registerOrderComplete' => array( |
---|
| 109 | 'order_temp_id' => '1001', |
---|
| 110 | 'status' => ORDER_NEW, |
---|
| 111 | 'cartKey' => '1' |
---|
| 112 | ), |
---|
| 113 | 'registerShipmentItem' => array( |
---|
| 114 | array( |
---|
| 115 | 'order_id' => '1001', |
---|
| 116 | 'shipping_id' => '00001', |
---|
| 117 | 'shipment_item' => '商品1' |
---|
| 118 | ) |
---|
| 119 | ), |
---|
| 120 | 'registerShipping' => array( |
---|
| 121 | 'order_id' => '1001' |
---|
| 122 | ), |
---|
| 123 | 'cleanupSession' => array( |
---|
| 124 | 'order_id' => '1001', |
---|
| 125 | 'cartKey' => '1' |
---|
| 126 | ) |
---|
| 127 | ); |
---|
| 128 | $this->actual = $_SESSION['testResult']; |
---|
| 129 | $this->verify('適切なfunctionが呼ばれている'); |
---|
| 130 | } |
---|
| 131 | |
---|
| 132 | ////////////////////////////////////////// |
---|
| 133 | |
---|
| 134 | } |
---|
| 135 | |
---|
| 136 | class SC_Helper_Purchase_completeOrderMock extends SC_Helper_Purchase{ |
---|
| 137 | |
---|
| 138 | function verifyChangeCart($uniqId, $objCartSession){ |
---|
| 139 | $_SESSION['testResult']['verifyChangeCart'] = array('uniqId'=>$uniqId); |
---|
| 140 | } |
---|
| 141 | |
---|
| 142 | function getOrderTemp($uniqId) { |
---|
| 143 | $_SESSION['testResult']['getOrderTemp'] = array('uniqId'=>$uniqId); |
---|
| 144 | return parent::getOrderTemp($uniqId); |
---|
| 145 | } |
---|
| 146 | |
---|
| 147 | function registerOrderComplete($orderTemp, $objCartSession, $cartKey) { |
---|
| 148 | $_SESSION['testResult']['registerOrderComplete'] = array( |
---|
| 149 | 'order_temp_id' => $orderTemp['order_temp_id'], |
---|
| 150 | 'status' => $orderTemp['status'], |
---|
| 151 | 'cartKey' => $cartKey |
---|
| 152 | ); |
---|
| 153 | return parent::registerOrderComplete($orderTemp, $objCartSession, $cartKey); |
---|
| 154 | } |
---|
| 155 | |
---|
| 156 | function registerShipmentItem($order_id, $shipping_id, $shipment_item) { |
---|
| 157 | $_SESSION['testResult']['registerShipmentItem'][] = array( |
---|
| 158 | 'order_id' => $order_id, |
---|
| 159 | 'shipping_id' => $shipping_id, |
---|
| 160 | 'shipment_item' => $shipment_item |
---|
| 161 | ); |
---|
| 162 | } |
---|
| 163 | |
---|
| 164 | function registerShipping($order_id, $shipping_temp) { |
---|
| 165 | $_SESSION['testResult']['registerShipping'] = array( |
---|
| 166 | 'order_id' => $order_id |
---|
| 167 | ); |
---|
| 168 | } |
---|
| 169 | |
---|
| 170 | function cleanupSession($order_id, $objCartSesion, $objCustomer, $cartKey) { |
---|
| 171 | $_SESSION['testResult']['cleanupSession'] = array( |
---|
| 172 | 'order_id' => $order_id, |
---|
| 173 | 'cartKey' => $cartKey |
---|
| 174 | ); |
---|
| 175 | } |
---|
| 176 | |
---|
| 177 | } |
---|
| 178 | |
---|
| 179 | ?> |
---|
| 180 | |
---|