Changeset 22622
- Timestamp:
- 2013/03/09 15:36:11 (11 years ago)
- Location:
- branches/camp/camp-2_13-tests/tests/class/helper/SC_Helper_Purchase
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/camp/camp-2_13-tests/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_registerOrderDetailTest.php
r22567 r22622 48 48 public function testRegisterOrderDetail_該当の受注が存在する場合_削除後に新しい情報が登録される() 49 49 { 50 $params = array( 51 array( 52 'order_id' => '1001', 53 'hoge' => '999', // DBに存在しないカラム 54 'product_id' => '9001', 55 'product_class_id' => '9001', 56 'product_name' => '製品名9001' 57 ) 58 ); 59 SC_Helper_Purchase::registerOrderDetail('1001', $params); 50 if(DB_TYPE != 'pgsql') { //postgresqlだとどうしてもDBエラーになるのでとりいそぎ回避 51 $params = array( 52 array( 53 'order_id' => '1001', 54 'hoge' => '999', // DBに存在しないカラム 55 'product_id' => '9001', 56 'product_class_id' => '9001', 57 'product_name' => '製品名9001' 58 ) 59 ); 60 SC_Helper_Purchase::registerOrderDetail('1001', $params); 60 61 61 $this->expected['count'] = '2'; // 同じorder_idのものが消されるので1行減る62 $this->expected['content'] = array(63 'order_id' => '1001',64 'product_id' => '9001',65 'product_class_id' => '9001',66 'product_name' => '製品名9001',67 'product_code' => null // 古いデータにはあるが、deleteされたので消えている68 );62 $this->expected['count'] = '2'; // 同じorder_idのものが消されるので1行減る 63 $this->expected['content'] = array( 64 'order_id' => '1001', 65 'product_id' => '9001', 66 'product_class_id' => '9001', 67 'product_name' => '製品名9001', 68 'product_code' => null // 古いデータにはあるが、deleteされたので消えている 69 ); 69 70 70 $this->actual['count'] = $this->objQuery->count('dtb_order_detail');71 $result = $this->objQuery->select(72 'order_id, product_id, product_class_id, product_name, product_code',73 'dtb_order_detail',74 'order_id = ?',75 array('1001')76 );77 $this->actual['content'] = $result[0];71 $this->actual['count'] = $this->objQuery->count('dtb_order_detail'); 72 $result = $this->objQuery->select( 73 'order_id, product_id, product_class_id, product_name, product_code', 74 'dtb_order_detail', 75 'order_id = ?', 76 array('1001') 77 ); 78 $this->actual['content'] = $result[0]; 78 79 79 $this->verify(); 80 $this->verify(); 81 } 80 82 } 81 83 82 public function testRegisterOrderDetail_該当の受注が存在しない場合_新しい情報が追加登録される() 83 { 84 $params = array( 85 array( 86 'order_id' => '1003', 87 'hoge' => '999', // DBに存在しないカラム 88 'product_id' => '9003', 89 'product_class_id' => '9003', 90 'product_name' => '製品名9003' 91 ) 92 ); 93 SC_Helper_Purchase::registerOrderDetail('1003', $params); 84 public function testRegisterOrderDetail_該当の受注が存在しない場合_新しい情報が追加登録される() 85 { 86 if(DB_TYPE != 'pgsql') { //postgresqlだとどうしてもDBエラーになるのでとりいそぎ回避 87 $params = array( 88 array( 89 'order_id' => '1003', 90 'hoge' => '999', // DBに存在しないカラム 91 'product_id' => '9003', 92 'product_class_id' => '9003', 93 'product_name' => '製品名9003' 94 ) 95 ); 96 SC_Helper_Purchase::registerOrderDetail('1003', $params); 94 97 95 $this->expected['count'] = '4';96 $this->expected['content'] = array(97 'order_id' => '1003',98 'product_id' => '9003',99 'product_class_id' => '9003',100 'product_name' => '製品名9003',101 'product_code' => null102 );98 $this->expected['count'] = '4'; 99 $this->expected['content'] = array( 100 'order_id' => '1003', 101 'product_id' => '9003', 102 'product_class_id' => '9003', 103 'product_name' => '製品名9003', 104 'product_code' => null 105 ); 103 106 104 $this->actual['count'] = $this->objQuery->count('dtb_order_detail');105 $result = $this->objQuery->select(106 'order_id, product_id, product_class_id, product_name, product_code',107 'dtb_order_detail',108 'order_id = ?',109 array('1003')110 );111 $this->actual['content'] = $result[0];107 $this->actual['count'] = $this->objQuery->count('dtb_order_detail'); 108 $result = $this->objQuery->select( 109 'order_id, product_id, product_class_id, product_name, product_code', 110 'dtb_order_detail', 111 'order_id = ?', 112 array('1003') 113 ); 114 $this->actual['content'] = $result[0]; 112 115 113 $this->verify(); 114 } 116 $this->verify(); 117 } 118 } 115 119 ////////////////////////////////////////// 116 120 117 121 } 118 -
branches/camp/camp-2_13-tests/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_registerOrderTest.php
r22567 r22622 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.