Index: branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_registerOrderDetailTest.php
===================================================================
--- branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_registerOrderDetailTest.php	(revision 22206)
+++ branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_registerOrderDetailTest.php	(revision 22247)
@@ -27,5 +27,4 @@
 /**
  * SC_Helper_Purchase::registerOrderDetail()のテストクラス.
- * TODO 他のfunctionと、SC_Query_Exのインスタンスの受け取り方が異なっている。
  *
  * @author Hiroko Tamagawa
Index: branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_TestBase.php
===================================================================
--- branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_TestBase.php	(revision 22206)
+++ branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_TestBase.php	(revision 22247)
@@ -157,4 +157,5 @@
           'price02' => '1500',
           'creator_id' => '1',
+          'stock' => '100',
           'del_flg' => '0'
         ),
@@ -166,4 +167,5 @@
           'price02' => '2500',
           'creator_id' => '1',
+          'stock' => '50',
           'del_flg' => '0'
         )
Index: branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_cancelOrderTest.php
===================================================================
--- branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_cancelOrderTest.php	(revision 22247)
+++ branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_cancelOrderTest.php	(revision 22247)
@@ -0,0 +1,177 @@
+<?php
+
+$HOME = realpath(dirname(__FILE__)) . "/../../../..";
+require_once($HOME . "/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_TestBase.php");
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+/**
+ * SC_Helper_Purchase::cancelOrder()のテストクラス.
+ *
+ * @author Hiroko Tamagawa
+ * @version $Id$
+ */
+class SC_Helper_Purchase_cancelOrderTest extends SC_Helper_Purchase_TestBase {
+
+  private $helper;
+
+  protected function setUp() {
+    parent::setUp();
+
+    $this->helper = new SC_Helper_Purchase_cancelOrderMock();
+  }
+
+  protected function tearDown() {
+    parent::tearDown();
+  }
+
+  /////////////////////////////////////////
+  public function testCancelOrder_デフォルトの引数で呼び出した場合_製品クラスのデータが更新される(){
+    $order_id = '1001';
+    $this->objQuery->begin();
+
+    $this->helper->cancelOrder($order_id);
+
+    $this->actual['testResult'] = $_SESSION['testResult'];
+    $this->actual['productClass'] = $this->objQuery->select(
+      'stock', 'dtb_products_class',
+      'product_class_id = ?', array('1001')
+    );
+    $this->expected = array(
+      'testResult' => array(
+        'registerOrder' => array(
+          'order_id' => '1001',
+          'params' => array(
+            'status' => ORDER_CANCEL
+          )
+        ),
+        'getOrderDetail' => array(
+          'order_id' => '1001'
+        )
+      ),
+      'productClass' => array(
+        array('stock') => '105',
+        array('stock') => '51'
+      )
+    );
+
+    $this->verify();
+  }
+
+  // 実際にトランザクションを開始したかどうかはテストできないが、
+  // 問題なく処理が完了することのみ確認
+  public function testCancelOrder_トランザクションが開始していない場合_内部で開始する(){
+    $order_id = '1001';
+
+    $this->helper->cancelOrder($order_id, ORDER_NEW);
+
+    $this->actual['testResult'] = $_SESSION['testResult'];
+    $this->actual['productClass'] = $this->objQuery->select(
+      'stock', 'dtb_products_class',
+      'product_class_id = ?', array('1001')
+    );
+    $this->expected = array(
+      'testResult' => array(
+        'registerOrder' => array(
+          'order_id' => '1001',
+          'params' => array(
+            'status' => ORDER_NEW
+          )
+        ),
+        'getOrderDetail' => array(
+          'order_id' => '1001'
+        )
+      ),
+      'productClass' => array(
+        array('stock') => '105',
+        array('stock') => '51'
+      )
+    );
+
+    $this->verify();
+  }
+
+  public function testCancelOrder_削除フラグが立っている場合_DB更新時に削除フラグが立てられる(){
+    $order_id = '1001';
+    $this->objQuery->begin();
+
+    $this->helper->cancelOrder($order_id, ORDER_DELIV, true);
+
+    $this->actual['testResult'] = $_SESSION['testResult'];
+    $this->actual['productClass'] = $this->objQuery->select(
+      'stock', 'dtb_products_class',
+      'product_class_id = ?', array('1001')
+    );
+    $this->expected = array(
+      'testResult' => array(
+        'registerOrder' => array(
+          'order_id' => '1001',
+          'params' => array(
+            'status' => ORDER_DELIV,
+            'del_flg' => '1'
+          )
+        ),
+        'getOrderDetail' => array(
+          'order_id' => '1001'
+        )
+      ),
+      'productClass' => array(
+        array('stock') => '105',
+        array('stock') => '51'
+      )
+    );
+
+    $this->verify();
+  }
+
+  //////////////////////////////////////////
+
+}
+
+class SC_Helper_Purchase_cancelOrderMock extends SC_Helper_Purchase {
+
+  function registerOrder($order_id, $params) {
+    $_SESSION['testResult']['registerOrder'] = array(
+      'order_id' => $order_id,
+      'params' => $params
+    );
+  }
+
+  function getOrderDetail($order_id) {
+    $_SESSION['testResult']['getOrderDetail'] = array(
+      'order_id' => $order_id
+    );
+
+    return array(
+      array(
+        'product_class_id' => '1001',
+        'quantity' => '5'
+      ),
+      array(
+        'product_class_id' => '1002',
+        'quantity' => '1'
+      )
+    );
+  }
+}
+
+
Index: branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_rollbackOrderTest.php
===================================================================
--- branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_rollbackOrderTest.php	(revision 22247)
+++ branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_rollbackOrderTest.php	(revision 22247)
@@ -0,0 +1,155 @@
+<?php
+
+$HOME = realpath(dirname(__FILE__)) . "/../../../..";
+require_once($HOME . "/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_TestBase.php");
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+/**
+ * SC_Helper_Purchase::rollbackOrder()のテストクラス.
+ *
+ * @author Hiroko Tamagawa
+ * @version $Id$
+ */
+class SC_Helper_Purchase_rollbackOrderTest extends SC_Helper_Purchase_TestBase {
+
+  private $helper;
+
+  protected function setUp() {
+    parent::setUp();
+
+    $this->helper = new SC_Helper_Purchase_rollbackOrderMock();
+  }
+
+  protected function tearDown() {
+    parent::tearDown();
+  }
+
+  /////////////////////////////////////////
+  public function testRollbackOrder_デフォルトの引数で呼び出した場合_カートの状態をロールバックして元に戻る(){
+    $this->objQuery->begin();
+    $order_id = '1001';
+
+    $uniqid = $this->helper->rollbackOrder($order_id);
+
+    $this->actual['testResult'] = $this->helper->testResult;
+    $this->actual['siteRegist'] = $_SESSION['site']['regist_success'];
+    $this->expected = array(
+      'testResult' => array(
+        'cancelOrder' => array(
+          'order_id' => '1001',
+          'orderStatus' => ORDER_CANCEL,
+          'is_delete' => false
+        ),
+        'getOrderTempByOrderId' => array(
+          'order_id' => '1001'
+        ),
+        'saveOrderTemp' => array(
+          'uniqid' => $uniqid,
+          'arrOrderTemp' => array(
+            'customer_id' => '2001',
+            'del_flg' => '0'
+          )
+        ),
+        'verifyChangeCart' => array(
+          'uniqid' => $uniqid
+        )
+      ),
+      'siteRegist' => true
+    );
+    $this->verify();
+  }
+
+  /**
+   * 実際にトランザクションを開始したかどうかはテストできないが、
+   * 問題なく処理が完了することのみ確認
+   */
+  public function testRollbackOrder_トランザクションが開始していない場合_内部で開始する() {
+    $order_id = '1001';
+
+    $uniqid = $this->helper->rollbackOrder($order_id, ORDER_DELIV, true);
+
+    $this->actual['testResult'] = $this->helper->testResult;
+    $this->actual['siteRegist'] = $_SESSION['site']['regist_success'];
+    $this->expected = array(
+      'testResult' => array(
+        'cancelOrder' => array(
+          'order_id' => '1001',
+          'orderStatus' => ORDER_DELIV,
+          'is_delete' => true
+        ),
+        'getOrderTempByOrderId' => array(
+          'order_id' => '1001'
+        ),
+        'saveOrderTemp' => array(
+          'uniqid' => $uniqid,
+          'arrOrderTemp' => array(
+            'customer_id' => '2001',
+            'del_flg' => '0'
+          )
+        ),
+        'verifyChangeCart' => array(
+          'uniqid' => $uniqid
+        )
+      ),
+      'siteRegist' => true
+    );
+    $this->verify();
+  }
+  //////////////////////////////////////////
+
+}
+
+class SC_Helper_Purchase_rollbackOrderMock extends SC_Helper_Purchase {
+  public $testResult = array();
+
+  function cancelOrder($order_id, $orderStatus, $is_delete) {
+    $this->testResult['cancelOrder'] = array(
+      'order_id' => $order_id,
+      'orderStatus' => $orderStatus,
+      'is_delete' => $is_delete
+    );
+  }
+
+  function getOrderTempByOrderId($order_id) {
+    $this->testResult['getOrderTempByOrderId'] = array(
+      'order_id' => $order_id
+    );
+    return array(
+      'customer_id' => '2001'
+    );
+  }
+
+  function saveOrderTemp($uniqid, $arrOrderTemp, $objCustomer) {
+    $this->testResult['saveOrderTemp'] = array(
+      'uniqid' => $uniqid,
+      'arrOrderTemp' => $arrOrderTemp
+    );
+  }
+
+  function verifyChangeCart($uniqid, $objCartSession) {
+    $this->testResult['verifyChangeCart'] = array(
+      'uniqid' => $uniqid
+    );
+  }
+}
+
