setUpOrderTemp(); // order_temp_id = '1001' $this->setUpShipping(); $this->setUpCustomer(); $_SESSION['cartKey'] = '1'; $_SESSION['site'] = array( 'pre_page' => 'pre', 'now_page' => 'now', 'regist_success' => TRUE, 'uniqid' => '1001' ); $this->helper = new SC_Helper_Purchase_completeOrderMock(); } protected function tearDown() { parent::tearDown(); } ///////////////////////////////////////// // 適切なfunctionが呼ばれていることのみ確認 public function testCompleteOrder_顧客IDが指定されている場合_購入日が更新される() { $_SESSION['customer']['customer_id'] = '1002'; // 顧客ID $this->helper->completeOrder(ORDER_DELIV); $this->expected = array( 'verifyChangeCart' => array( 'uniqId' => '1001' ), 'getOrderTemp' => array( 'uniqId' => '1001' ), 'registerOrderComplete' => array( 'order_temp_id' => '1001', 'status' => ORDER_DELIV, 'cartKey' => '1' ), 'registerShipmentItem' => array( array( 'order_id' => '1001', 'shipping_id' => '00001', 'shipment_item' => '商品1' ) ), 'registerShipping' => array( 'order_id' => '1001' ), 'cleanupSession' => array( 'order_id' => '1001', 'cartKey' => '1' ) ); $this->actual = $_SESSION['testResult']; $this->verify('適切なfunctionが呼ばれている'); $last_buy_date = $this->objQuery->get('last_buy_date', 'dtb_customer', 'customer_id = ?', '1002'); $this->assertNotNull($last_buy_date, '最終購入日'); } public function testCompleteOrder_顧客IDが指定されていない場合_特にエラーなく修了できる() { $this->helper->completeOrder(); // デフォルトのステータス(NEW) $this->expected = array( 'verifyChangeCart' => array( 'uniqId' => '1001' ), 'getOrderTemp' => array( 'uniqId' => '1001' ), 'registerOrderComplete' => array( 'order_temp_id' => '1001', 'status' => ORDER_NEW, 'cartKey' => '1' ), 'registerShipmentItem' => array( array( 'order_id' => '1001', 'shipping_id' => '00001', 'shipment_item' => '商品1' ) ), 'registerShipping' => array( 'order_id' => '1001' ), 'cleanupSession' => array( 'order_id' => '1001', 'cartKey' => '1' ) ); $this->actual = $_SESSION['testResult']; $this->verify('適切なfunctionが呼ばれている'); } ////////////////////////////////////////// } class SC_Helper_Purchase_completeOrderMock extends SC_Helper_Purchase{ function verifyChangeCart($uniqId, $objCartSession){ $_SESSION['testResult']['verifyChangeCart'] = array('uniqId'=>$uniqId); } function getOrderTemp($uniqId) { $_SESSION['testResult']['getOrderTemp'] = array('uniqId'=>$uniqId); return parent::getOrderTemp($uniqId); } function registerOrderComplete($orderTemp, $objCartSession, $cartKey) { $_SESSION['testResult']['registerOrderComplete'] = array( 'order_temp_id' => $orderTemp['order_temp_id'], 'status' => $orderTemp['status'], 'cartKey' => $cartKey ); return parent::registerOrderComplete($orderTemp, $objCartSession, $cartKey); } function registerShipmentItem($order_id, $shipping_id, $shipment_item) { $_SESSION['testResult']['registerShipmentItem'][] = array( 'order_id' => $order_id, 'shipping_id' => $shipping_id, 'shipment_item' => $shipment_item ); } function registerShipping($order_id, $shipping_temp) { $_SESSION['testResult']['registerShipping'] = array( 'order_id' => $order_id ); } function cleanupSession($order_id, $objCartSesion, $objCustomer, $cartKey) { $_SESSION['testResult']['cleanupSession'] = array( 'order_id' => $order_id, 'cartKey' => $cartKey ); } } ?>