setUpOrder(); $this->helper = new SC_Helper_Purchase_registerOrderMock(); } protected function tearDown() { parent::tearDown(); } ///////////////////////////////////////// public function testRegisterOrder_既に受注IDが存在する場合_情報が更新される() { $order_id = '1001'; $arrParams = array( 'status' => '1', 'add_point' => 10, 'use_point' => 20, 'order_name01' => '受注情報01_更新' ); $this->helper->registerOrder($order_id, $arrParams); $this->expected = array( 'sfUpdateOrderStatus' => array( 'order_id' => '1001', 'status' => '1', 'add_point' => 10, 'use_point' => 20 ), 'sfUpdateOrderNameCol' => '1001', 'count' => '2', 'content' => array( 'order_id' => '1001', 'customer_id' => '1001', 'status' => '1', 'add_point' => '10', 'use_point' => '20', 'order_name01' => '受注情報01_更新' ) ); $this->actual = $_SESSION['testResult']; $this->actual['count'] = $this->objQuery->count('dtb_order'); $result = $this->objQuery->select( 'order_id, customer_id, status, order_name01, add_point, use_point', 'dtb_order', 'order_id = ?', array($order_id) ); $this->actual['content'] = $result[0]; $this->verify(); } public function testRegisterOrder_存在しない受注IDを指定した場合_新規に登録される() { $order_id = '1003'; $arrParams = array( 'customer_id' => '1003', 'status' => '2', 'add_point' => 100, 'use_point' => 200, 'order_name01' => '受注情報03' ); $this->helper->registerOrder($order_id, $arrParams); $this->expected = array( 'sfUpdateOrderStatus' => array( 'order_id' => '1003', 'status' => '2', 'add_point' => 100, 'use_point' => 200 ), 'sfUpdateOrderNameCol' => '1003', 'count' => '3', 'content' => array( 'order_id' => '1003', 'customer_id' => '1003', 'status' => null, // ここではsfUpdateOrderStatusをモックにしているので更新されない 'add_point' => '100', 'use_point' => '200', 'order_name01' => '受注情報03' ) ); $this->actual = $_SESSION['testResult']; $this->actual['count'] = $this->objQuery->count('dtb_order'); $result = $this->objQuery->select( 'order_id, customer_id, status, order_name01, add_point, use_point', 'dtb_order', 'order_id = ?', array($order_id) ); $this->actual['content'] = $result[0]; $this->verify(); } public function testRegisterOrder_受注IDが未指定の場合_新たにIDが発行される() { if(DB_TYPE != 'pgsql') { //postgresqlだとどうしてもDBエラーになるのでとりいそぎ回避 $order_id = ''; $arrParams = array( // 顧客IDも未指定 'status' => '2', 'add_point' => 100, 'use_point' => 200, 'order_name01' => '受注情報03' ); // SEQの値を取得 $new_order_id = $this->helper->getNextOrderID() + 1; $this->helper->registerOrder($order_id, $arrParams); $this->expected = array( 'sfUpdateOrderStatus' => array( 'order_id' => $new_order_id, 'status' => '2', 'add_point' => 100, 'use_point' => 200 ), 'sfUpdateOrderNameCol' => $new_order_id, 'count' => '3', 'content' => array( 'order_id' => $new_order_id, 'customer_id' => '0', 'status' => null, // ここではsfUpdateOrderStatusをモックにしているので更新されない 'add_point' => '100', 'use_point' => '200', 'order_name01' => '受注情報03' ) ); $this->actual = $_SESSION['testResult']; $this->actual['count'] = $this->objQuery->count('dtb_order'); $result = $this->objQuery->select( 'order_id, customer_id, status, order_name01, add_point, use_point', 'dtb_order', 'order_id = ?', array($new_order_id) ); $this->actual['content'] = $result[0]; $this->verify(); } } ////////////////////////////////////////// } class SC_Helper_Purchase_registerOrderMock extends SC_Helper_Purchase { function sfUpdateOrderStatus($order_id, $status, $add_point, $use_point, $values) { $_SESSION['testResult']['sfUpdateOrderStatus'] = array( 'order_id' => $order_id, 'status' => $status, 'add_point' => $add_point, 'use_point' => $use_point, ); } function sfUpdateOrderNameCol($order_id) { $_SESSION['testResult']['sfUpdateOrderNameCol'] = $order_id; } }