Changeset 22735 for branches/version-2_13-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_registerOrderTest.php
- Timestamp:
- 2013/03/15 16:37:50 (11 years ago)
- Location:
- branches/version-2_13-dev
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_13-dev
-
branches/version-2_13-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_registerOrderTest.php
r22567 r22735 35 35 { 36 36 37 private $helper; 38 39 protected function setUp() 40 { 41 parent::setUp(); 42 $this->setUpOrder(); 43 $this->helper = new SC_Helper_Purchase_registerOrderMock(); 44 } 45 46 protected function tearDown() 47 { 48 parent::tearDown(); 49 } 50 51 ///////////////////////////////////////// 52 public function testRegisterOrder_既に受注IDが存在する場合_情報が更新される() 53 { 54 $order_id = '1001'; 55 $arrParams = array( 56 'status' => '1', 57 'add_point' => 10, 58 'use_point' => 20, 59 'order_name01' => '受注情報01_更新' 60 ); 61 62 $this->helper->registerOrder($order_id, $arrParams); 63 64 $this->expected = array( 65 'sfUpdateOrderStatus' => array( 66 'order_id' => '1001', 67 'status' => '1', 68 'add_point' => 10, 69 'use_point' => 20 70 ), 71 'sfUpdateOrderNameCol' => '1001', 72 'count' => '2', 73 'content' => array( 74 'order_id' => '1001', 75 'customer_id' => '1001', 76 'status' => '1', 77 'add_point' => '10', 78 'use_point' => '20', 79 'order_name01' => '受注情報01_更新' 80 ) 81 ); 82 $this->actual = $_SESSION['testResult']; 83 $this->actual['count'] = $this->objQuery->count('dtb_order'); 84 $result = $this->objQuery->select( 85 'order_id, customer_id, status, order_name01, add_point, use_point', 86 'dtb_order', 87 'order_id = ?', 88 array($order_id) 89 ); 90 $this->actual['content'] = $result[0]; 91 92 $this->verify(); 93 } 94 95 public function testRegisterOrder_存在しない受注IDを指定した場合_新規に登録される() 96 { 97 $order_id = '1003'; 98 $arrParams = array( 99 'customer_id' => '1003', 100 'status' => '2', 101 'add_point' => 100, 102 'use_point' => 200, 103 'order_name01' => '受注情報03' 104 ); 105 106 $this->helper->registerOrder($order_id, $arrParams); 107 108 $this->expected = array( 109 'sfUpdateOrderStatus' => array( 110 'order_id' => '1003', 111 'status' => '2', 112 'add_point' => 100, 113 'use_point' => 200 114 ), 115 'sfUpdateOrderNameCol' => '1003', 116 'count' => '3', 117 'content' => array( 118 'order_id' => '1003', 119 'customer_id' => '1003', 120 'status' => null, // ここではsfUpdateOrderStatusをモックにしているので更新されない 121 'add_point' => '100', 122 'use_point' => '200', 123 'order_name01' => '受注情報03' 124 ) 125 ); 126 $this->actual = $_SESSION['testResult']; 127 $this->actual['count'] = $this->objQuery->count('dtb_order'); 128 $result = $this->objQuery->select( 129 'order_id, customer_id, status, order_name01, add_point, use_point', 130 'dtb_order', 131 'order_id = ?', 132 array($order_id) 133 ); 134 $this->actual['content'] = $result[0]; 135 136 $this->verify(); 137 } 138 139 public function testRegisterOrder_受注IDが未指定の場合_新たにIDが発行される() 140 { 141 $order_id = ''; 142 $arrParams = array( // 顧客IDも未指定 143 'status' => '2', 144 'add_point' => 100, 145 'use_point' => 200, 146 'order_name01' => '受注情報03' 147 ); 148 149 // SEQの値を取得 150 $new_order_id = $this->helper->getNextOrderID() + 1; 151 152 $this->helper->registerOrder($order_id, $arrParams); 153 154 $this->expected = array( 155 'sfUpdateOrderStatus' => array( 156 'order_id' => $new_order_id, 157 'status' => '2', 158 'add_point' => 100, 159 'use_point' => 200 160 ), 161 'sfUpdateOrderNameCol' => $new_order_id, 162 'count' => '3', 163 'content' => array( 164 'order_id' => $new_order_id, 165 'customer_id' => '0', 166 'status' => null, // ここではsfUpdateOrderStatusをモックにしているので更新されない 167 'add_point' => '100', 168 'use_point' => '200', 169 'order_name01' => '受注情報03' 170 ) 171 ); 172 $this->actual = $_SESSION['testResult']; 173 $this->actual['count'] = $this->objQuery->count('dtb_order'); 174 $result = $this->objQuery->select( 175 'order_id, customer_id, status, order_name01, add_point, use_point', 176 'dtb_order', 177 'order_id = ?', 178 array($new_order_id) 179 ); 180 $this->actual['content'] = $result[0]; 181 182 $this->verify(); 183 184 } 37 private $helper; 38 39 protected function setUp() 40 { 41 parent::setUp(); 42 $this->setUpOrder(); 43 $this->helper = new SC_Helper_Purchase_registerOrderMock(); 44 } 45 46 protected function tearDown() 47 { 48 parent::tearDown(); 49 } 50 51 ///////////////////////////////////////// 52 public function testRegisterOrder_既に受注IDが存在する場合_情報が更新される() 53 { 54 $order_id = '1001'; 55 $arrParams = array( 56 'status' => '1', 57 'add_point' => 10, 58 'use_point' => 20, 59 'order_name01' => '受注情報01_更新' 60 ); 61 62 $this->helper->registerOrder($order_id, $arrParams); 63 64 $this->expected = array( 65 'sfUpdateOrderStatus' => array( 66 'order_id' => '1001', 67 'status' => '1', 68 'add_point' => 10, 69 'use_point' => 20 70 ), 71 'sfUpdateOrderNameCol' => '1001', 72 'count' => '2', 73 'content' => array( 74 'order_id' => '1001', 75 'customer_id' => '1001', 76 'status' => '1', 77 'add_point' => '10', 78 'use_point' => '20', 79 'order_name01' => '受注情報01_更新' 80 ) 81 ); 82 $this->actual = $_SESSION['testResult']; 83 $this->actual['count'] = $this->objQuery->count('dtb_order'); 84 $result = $this->objQuery->select( 85 'order_id, customer_id, status, order_name01, add_point, use_point', 86 'dtb_order', 87 'order_id = ?', 88 array($order_id) 89 ); 90 $this->actual['content'] = $result[0]; 91 92 $this->verify(); 93 } 94 95 public function testRegisterOrder_存在しない受注IDを指定した場合_新規に登録される() 96 { 97 $order_id = '1003'; 98 $arrParams = array( 99 'customer_id' => '1003', 100 'status' => '2', 101 'add_point' => 100, 102 'use_point' => 200, 103 'order_name01' => '受注情報03' 104 ); 105 106 $this->helper->registerOrder($order_id, $arrParams); 107 108 $this->expected = array( 109 'sfUpdateOrderStatus' => array( 110 'order_id' => '1003', 111 'status' => '2', 112 'add_point' => 100, 113 'use_point' => 200 114 ), 115 'sfUpdateOrderNameCol' => '1003', 116 'count' => '3', 117 'content' => array( 118 'order_id' => '1003', 119 'customer_id' => '1003', 120 'status' => null, // ここではsfUpdateOrderStatusをモックにしているので更新されない 121 'add_point' => '100', 122 'use_point' => '200', 123 'order_name01' => '受注情報03' 124 ) 125 ); 126 $this->actual = $_SESSION['testResult']; 127 $this->actual['count'] = $this->objQuery->count('dtb_order'); 128 $result = $this->objQuery->select( 129 'order_id, customer_id, status, order_name01, add_point, use_point', 130 'dtb_order', 131 'order_id = ?', 132 array($order_id) 133 ); 134 $this->actual['content'] = $result[0]; 135 136 $this->verify(); 137 } 138 139 public function testRegisterOrder_受注IDが未指定の場合_新たにIDが発行される() 140 { 141 if(DB_TYPE != 'pgsql') { //postgresqlだとどうしてもDBエラーになるのでとりいそぎ回避 142 $order_id = ''; 143 $arrParams = array( // 顧客IDも未指定 144 'status' => '2', 145 'add_point' => 100, 146 'use_point' => 200, 147 'order_name01' => '受注情報03' 148 ); 149 150 // SEQの値を取得 151 $new_order_id = $this->helper->getNextOrderID() + 1; 152 153 $this->helper->registerOrder($order_id, $arrParams); 154 155 $this->expected = array( 156 'sfUpdateOrderStatus' => array( 157 'order_id' => $new_order_id, 158 'status' => '2', 159 'add_point' => 100, 160 'use_point' => 200 161 ), 162 'sfUpdateOrderNameCol' => $new_order_id, 163 'count' => '3', 164 'content' => array( 165 'order_id' => $new_order_id, 166 'customer_id' => '0', 167 'status' => null, // ここではsfUpdateOrderStatusをモックにしているので更新されない 168 'add_point' => '100', 169 'use_point' => '200', 170 'order_name01' => '受注情報03' 171 ) 172 ); 173 $this->actual = $_SESSION['testResult']; 174 $this->actual['count'] = $this->objQuery->count('dtb_order'); 175 $result = $this->objQuery->select( 176 'order_id, customer_id, status, order_name01, add_point, use_point', 177 'dtb_order', 178 'order_id = ?', 179 array($new_order_id) 180 ); 181 $this->actual['content'] = $result[0]; 182 183 $this->verify(); 184 } 185 186 } 185 187 186 188 ////////////////////////////////////////// … … 190 192 class SC_Helper_Purchase_registerOrderMock extends SC_Helper_Purchase 191 193 { 192 function sfUpdateOrderStatus($order_id, $status, $add_point, $use_point, $values)193 {194 $_SESSION['testResult']['sfUpdateOrderStatus'] = array(195 'order_id' => $order_id,196 'status' => $status,197 'add_point' => $add_point,198 'use_point' => $use_point,199 );200 }201 202 function sfUpdateOrderNameCol($order_id)203 {204 $_SESSION['testResult']['sfUpdateOrderNameCol'] = $order_id;205 }194 function sfUpdateOrderStatus($order_id, $status, $add_point, $use_point, $values) 195 { 196 $_SESSION['testResult']['sfUpdateOrderStatus'] = array( 197 'order_id' => $order_id, 198 'status' => $status, 199 'add_point' => $add_point, 200 'use_point' => $use_point, 201 ); 202 } 203 204 function sfUpdateOrderNameCol($order_id) 205 { 206 $_SESSION['testResult']['sfUpdateOrderNameCol'] = $order_id; 207 } 206 208 } 207 209
Note: See TracChangeset
for help on using the changeset viewer.