| 1 | <?php |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | class Customerlevel_test extends TestCase |
| 12 | { |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | public function __construct() { |
| 20 | parent::__construct(); |
| 21 | $ci = &get_instance(); |
| 22 | $ci->load->database(); |
| 23 | $ci->load->helper('validator_helper'); |
| 24 | $this->code = substr(md5(uniqid(mt_rand(), true)), 0, 5); |
| 25 | $_SESSION =array ( |
| 26 | '__ci_last_regenerate' => 1674475513, |
| 27 | 'lang' => 'th', |
| 28 | 'tLangID' => 1, |
| 29 | 'tSesUserLogin' => '009', |
| 30 | 'tSesUsrRoleCodeMulti' => '\'00002\'', |
| 31 | 'nSesUsrRoleLevel' => 99, |
| 32 | 'tSesUsrAgnCode' => NULL, |
| 33 | 'tSesUsrAgnName' => NULL, |
| 34 | 'tSesUsrMerCode' => NULL, |
| 35 | 'tSesUsrMerName' => NULL, |
| 36 | 'tSesUsrBchCodeDefault' => '00001', |
| 37 | 'tSesUsrBchNameDefault' => 'AdaSoft00001', |
| 38 | 'tSesUsrBchCodeMulti' => '\'00001\'', |
| 39 | 'tSesUsrBchNameMulti' => '\'AdaSoft00001\'', |
| 40 | 'nSesUsrBchCount' => 0, |
| 41 | 'tSesUsrShpCodeDefault' => '00014', |
| 42 | 'tSesUsrShpNameDefault' => 'รันไทม์ช็อป', |
| 43 | 'tSesUsrShpCodeMulti' => '\'00014\'', |
| 44 | 'tSesUsrShpNameMulti' => '\'รันไทม์ช็อป\'', |
| 45 | 'nSesUsrShpCount' => 0, |
| 46 | 'tSesUsrWahCode' => '00001', |
| 47 | 'tSesUsrWahName' => 'คลังขาย', |
| 48 | 'tSesUsrLoginLevel' => 'HQ', |
| 49 | 'tSesUsrLoginAgency' => 0, |
| 50 | 'bSesLogIn' => 1, |
| 51 | 'tSesUserCode' => '00002', |
| 52 | 'tSesUsername' => '00002', |
| 53 | 'tSesUsrDptName' => NULL, |
| 54 | 'tSesUsrDptCode' => NULL, |
| 55 | 'tSesUsrUsername' => 'Adasoft', |
| 56 | 'tSesUsrImagePerson' => NULL, |
| 57 | 'tSesUsrInfo' => |
| 58 | array ( |
| 59 | 'FTUsrStaActive' => 1, |
| 60 | 'FTUsrLogType' => 1, |
| 61 | 'FTStaError' => 0, |
| 62 | 'FTUsrCode' => '00002', |
| 63 | 'FTUsrName' => 'Adasoft', |
| 64 | 'FTDptCode' => NULL, |
| 65 | 'FTDptName' => NULL, |
| 66 | 'FTImgObj' => NULL, |
| 67 | ), |
| 68 | 'tSesUsrGroup' => |
| 69 | array ( |
| 70 | 0 => |
| 71 | array ( |
| 72 | 'FTUsrCode' => '00002', |
| 73 | 'FTAgnCode' => NULL, |
| 74 | 'FTAgnName' => NULL, |
| 75 | 'FTBchCode' => NULL, |
| 76 | 'FTBchName' => NULL, |
| 77 | 'FTShpCode' => NULL, |
| 78 | 'FTShpName' => NULL, |
| 79 | 'FTMerCode' => NULL, |
| 80 | 'FTMerName' => NULL, |
| 81 | 'FTWahCode' => NULL, |
| 82 | 'FTWahName' => NULL, |
| 83 | 'FTLoginLevel' => 'HQ', |
| 84 | 'FTStaLoginAgn' => 0, |
| 85 | ), |
| 86 | ), |
| 87 | 'tSesSessionID' => '0000220230123185822', |
| 88 | 'tSesSessionDate' => '2023-01-23 18:58:22', |
| 89 | 'tLangEdit' => 1, |
| 90 | 'bIsHaveAgn' => NULL, |
| 91 | 'tSesUsrLevel' => 'HQ', |
| 92 | 'tSesUsrRoleSpcCodeMulti' => '\'00002\',\'00003\',\'00004\',\'00005\',\'00006\',\'00007\',\'00008\',\'00009\',\'00010\',\'00011\',\'00012\',\'00013\',\'00014\',\'00016\',\'00017\',\'00018\',\'00019\',\'00020\',\'00021\',\'00022\',\'00023\',\'00024\',\'00025\',\'00026\',\'00027\',\'00028\',\'00029\',\'00030\',\'00031\',\'00032\',\'00033\',\'00034\',\'00035\',\'00036\',\'00037\',\'00038\'', |
| 93 | 'bShpEnabled' => 1, |
| 94 | 'bAgnEnabled' => 1, |
| 95 | 'bLockerEnabled' => NULL, |
| 96 | 'bPdtFasionEnabled' => NULL, |
| 97 | 'tSesHQBchCode' => '00001', |
| 98 | 'bSesRegStaLicense' => 1, |
| 99 | 'tSesCstKey' => '52a8a4705e6c', |
| 100 | 'bSesRegStaBuyPackage' => 1, |
| 101 | ); |
| 102 | |
| 103 | |
| 104 | } |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | public function test_เข้าหน้า_index_สำเร็จ(){ |
| 120 | print " 1.เข้าหน้า index สำเร็จ\n"; |
| 121 | $oOutput = $this->request( |
| 122 | 'POST', |
| 123 | 'customer/customerLevel/cCustomerLevel/index/0/0' |
| 124 | ); |
| 125 | $this->assertStringContainsString('oetCstLevStaBrowse', $oOutput); |
| 126 | $this->assertResponseCode(200); |
| 127 | } |
| 128 | |
| 129 | |
| 130 | |
| 131 | public function test_โหลดข้อมูลหน้าจอตัวกรอง(){ |
| 132 | print " 2.เข้าหน้า list สำเร็จ\n"; |
| 133 | $oOutput = $this->request( |
| 134 | 'POST', |
| 135 | 'customer/customerLevel/cCustomerLevel/FSvCstLevListPage' |
| 136 | ); |
| 137 | $this->assertStringContainsString('oimSearchCstLev', $oOutput); |
| 138 | $this->assertResponseCode(200); |
| 139 | } |
| 140 | |
| 141 | |
| 142 | |
| 143 | public function test_โหลดข้อมูลตารางรายการระดับลูกค้า(){ |
| 144 | print " 3.เข้าหน้า list สำเร็จ\n"; |
| 145 | $aParam = array( |
| 146 | 'tSearchAll' => '', |
| 147 | 'nPageCurrent' => '1', |
| 148 | ); |
| 149 | $oOutput = $this->request( |
| 150 | 'POST', |
| 151 | 'customer/customerLevel/cCustomerLevel/FSvCstLevDataList', |
| 152 | $aParam |
| 153 | ); |
| 154 | $this->assertStringContainsString('otdCstLevName', $oOutput); |
| 155 | $this->assertResponseCode(200); |
| 156 | } |
| 157 | |
| 158 | |
| 159 | |
| 160 | public function test_กดหน้าเพิ่มใหม่(){ |
| 161 | print " 4.เข้าหน้า Add สำเร็จ\n"; |
| 162 | $oOutput = $this->request( |
| 163 | 'POST', |
| 164 | 'customer/customerLevel/cCustomerLevel/FSvCstLevAddPage' |
| 165 | ); |
| 166 | $this->assertStringContainsString('odvCstLevCodeForm', $oOutput); |
| 167 | $this->assertResponseCode(200); |
| 168 | } |
| 169 | |
| 170 | |
| 171 | |
| 172 | public function test_เพิ่มข้อมูลแบบระบุชื่อระดับและรหัสอัตโนมัติ_C1(){ |
| 173 | print " 5.เพิ่มข้อมูล โดยระบุชื่อระดับ และ รหัสสร้างอัตโนมัติ ต้องได้ผลลัพท์คือเพิ่มได้สำเร็จ\n"; |
| 174 | $aParam = array( |
| 175 | 'ohdLngIdLocal' => '4', |
| 176 | 'ocbCustomerLevelAutoGenCode' => '1', |
| 177 | 'ohdCheckDuplicateCstLevCode' => '1', |
| 178 | 'ohdTypeCode' => '1', |
| 179 | 'oetCstLevAgnCode' => '', |
| 180 | 'oetCstLevAgnName' => '', |
| 181 | 'ocmMemberTypes' => '1', |
| 182 | 'ocmCstShpType' => '1', |
| 183 | 'oetCstLevPplCode' => '00010', |
| 184 | 'oetCstLevPplName' => 'กลุ่มราคาสินค้า01ไทย', |
| 185 | 'oetCstLevName' => 'test', |
| 186 | 'otaCstLevRemark' => '', |
| 187 | 'oetCstLevName1' => 'ทดสอบ', |
| 188 | 'otaCstLevRemark1' => '', |
| 189 | 'oetCstLevName2' => '', |
| 190 | 'otaCstLevRemark2' => '', |
| 191 | 'oetCstLevName5' => '', |
| 192 | 'otaCstLevRemark5' => '', |
| 193 | ); |
| 194 | $oOutput = $this->ajaxRequest('POST', 'customer/customerLevel/cCustomerLevel/FSaCstLevAddEvent',$aParam); |
| 195 | $this->assertStringContainsString( |
| 196 | 'Success Add Event', $oOutput |
| 197 | ); |
| 198 | $this->assertResponseCode(200); |
| 199 | |
| 200 | } |
| 201 | |
| 202 | |
| 203 | |
| 204 | public function test_เพิ่มข้อมูลแบบระบุชื่อระดับและตั้งรหัสระดับเอง_C2(){ |
| 205 | print " 6.เพิ่มข้อมูล โดยระบุชื่อระดับ และ รหัสสร้างเองแบบคีย์ ต้องได้ผลลัพท์คือเพิ่มได้สำเร็จ\n"; |
| 206 | $aParam = array( |
| 207 | 'ohdLngIdLocal' => '4', |
| 208 | 'ohdCheckDuplicateCstLevCode' => '2', |
| 209 | 'oetCstLevCode' => 'NH001', |
| 210 | 'ohdTypeCode' => '1', |
| 211 | 'oetCstLevAgnCode' => '', |
| 212 | 'oetCstLevAgnName' => '', |
| 213 | 'ocmMemberTypes' => '1', |
| 214 | 'ocmCstShpType' => '1', |
| 215 | 'oetCstLevPplCode' => '', |
| 216 | 'oetCstLevPplName' => '', |
| 217 | 'oetCstLevName' => 'test', |
| 218 | 'otaCstLevRemark' => '', |
| 219 | 'oetCstLevName1' => 'test', |
| 220 | 'otaCstLevRemark1' => '', |
| 221 | 'oetCstLevName2' => '', |
| 222 | 'otaCstLevRemark2' => '', |
| 223 | 'oetCstLevName5' => '', |
| 224 | 'otaCstLevRemark5' => '', |
| 225 | ); |
| 226 | $oOutput = $this->ajaxRequest('POST', 'customer/customerLevel/cCustomerLevel/FSaCstLevAddEvent',$aParam); |
| 227 | $this->assertStringContainsString( |
| 228 | 'Success Add Event', $oOutput |
| 229 | ); |
| 230 | $this->assertResponseCode(200); |
| 231 | |
| 232 | } |
| 233 | |
| 234 | |
| 235 | |
| 236 | public function test_เพิ่มข้อมูลโดยระบุชื่อระดับและรหัสสร้างเองแบบคีย์และรหัสเคยมีอยู่แล้วต้องได้ผลลัพท์คือการอัพเดทแทนที่_C3(){ |
| 237 | print " 7.เพิ่มข้อมูล โดยระบุชื่อระดับ และ รหัสสร้างเองแบบคีย์ และ รหัสเคยมีอยู่แล้ว ต้องได้ผลลัพท์คือการอัพเดทแทนที่\n"; |
| 238 | $ci = &get_instance(); |
| 239 | $ci->load->database(); |
| 240 | $aResult = $ci->db->select(['FTClvCode','FTClvName'])->where('FNLngID',1)->where('FTClvCode!=','')->limit(1)->get('TCNMCstLev_L')->row_array(); |
| 241 | if(!empty($aResult)){ |
| 242 | $aParam = array( |
| 243 | 'ohdLngIdLocal' => '4', |
| 244 | 'ohdCheckDuplicateCstLevCode' => '2', |
| 245 | 'oetCstLevCode' => $aResult['FTClvCode'], |
| 246 | 'ohdTypeCode' => '1', |
| 247 | 'oetCstLevAgnCode' => '', |
| 248 | 'oetCstLevAgnName' => '', |
| 249 | 'ocmMemberTypes' => '1', |
| 250 | 'ocmCstShpType' => '1', |
| 251 | 'oetCstLevPplCode' => '', |
| 252 | 'oetCstLevPplName' => '', |
| 253 | 'oetCstLevName' => $aResult['FTClvName'], |
| 254 | 'otaCstLevRemark' => '', |
| 255 | 'oetCstLevName1' => $aResult['FTClvName'], |
| 256 | 'otaCstLevRemark1' => '', |
| 257 | 'oetCstLevName2' => '', |
| 258 | 'otaCstLevRemark2' => '', |
| 259 | 'oetCstLevName5' => '', |
| 260 | 'otaCstLevRemark5' => '', |
| 261 | ); |
| 262 | } |
| 263 | $oOutput = $this->ajaxRequest('POST', 'customer/customerLevel/cCustomerLevel/FSaCstLevAddEvent',$aParam); |
| 264 | $this->assertStringContainsString( |
| 265 | 'Data Code Duplicate', $oOutput |
| 266 | ); |
| 267 | $this->assertResponseCode(200); |
| 268 | |
| 269 | } |
| 270 | |
| 271 | |
| 272 | |
| 273 | |
| 274 | public function test_เข้าหน้าจอแก้ไขแบบมีข้อมูลจริงต้องได้ผลลัพท์สำเร็จ_C1(){ |
| 275 | print " 8.เข้าหน้าจอแก้ไขแบบมีข้อมูลจริง ต้องได้ผลลัพท์สำเร็จ\n"; |
| 276 | $ci = &get_instance(); |
| 277 | $ci->load->database(); |
| 278 | $aResult = $ci->db->select(['FTClvCode','FTClvName'])->where('FNLngID',1)->where('FTClvCode!=','')->limit(1)->get('TCNMCstLev_L')->row_array(); |
| 279 | if(!empty($aResult)){ |
| 280 | $oOutput = $this->request( |
| 281 | 'POST', |
| 282 | 'customer/customerLevel/cCustomerLevel/FSvCstLevEditPage', |
| 283 | ['tCstLevCode'=>$aResult['FTClvCode']] |
| 284 | ); |
| 285 | |
| 286 | } |
| 287 | |
| 288 | $this->assertStringContainsString('odvCstLevCodeForm', $oOutput); |
| 289 | $this->assertResponseCode(200); |
| 290 | } |
| 291 | |
| 292 | |
| 293 | |
| 294 | |
| 295 | public function test_อัพเดทข้อมูลระบุชื่อระดับใหม่ไปด้วยความยาวที่ไม่เกินผลลัพท์ต้องสำเร็จ_C1(){ |
| 296 | print " 9.อัพเดทข้อมูล ระบุชื่อชื่อระดับใหม่ไปด้วยความยาวที่ไม่เกิน ผลลัพท์ต้องสำเร็จ\n"; |
| 297 | $ci = &get_instance(); |
| 298 | $ci->load->database(); |
| 299 | $aResult = $ci->db->select(['FTClvCode','FTClvName'])->where('FNLngID',1)->where('FTClvCode!=','')->limit(1)->get('TCNMCstLev_L')->row_array(); |
| 300 | if(!empty($aResult)){ |
| 301 | $aParam = array( |
| 302 | 'ohdLngIdLocal' => '4', |
| 303 | 'ohdCheckDuplicateCstLevCode' => '1', |
| 304 | 'oetCstLevCode' => $aResult['FTClvCode'], |
| 305 | 'ohdTypeCode' => '1', |
| 306 | 'oetCstLevAgnCode' => '', |
| 307 | 'oetCstLevAgnName' => '', |
| 308 | 'ocmCstShpType' => '1', |
| 309 | 'oetCstLevPplCode' => '', |
| 310 | 'oetCstLevPplName' => '', |
| 311 | 'oetCstLevName' => $aResult['FTClvName'], |
| 312 | 'otaCstLevRemark' => '', |
| 313 | 'oetCstLevName1' => $aResult['FTClvName'], |
| 314 | 'otaCstLevRemark1' => '', |
| 315 | 'oetCstLevName2' => '', |
| 316 | 'otaCstLevRemark2' => '', |
| 317 | 'oetCstLevName5' => '', |
| 318 | 'otaCstLevRemark5' => '', |
| 319 | ); |
| 320 | } |
| 321 | $oOutput = $this->ajaxRequest('POST', 'customer/customerLevel/cCustomerLevel/FSaCstLevEditEvent',$aParam); |
| 322 | $this->assertStringContainsString( |
| 323 | 'Success Add Event', $oOutput |
| 324 | ); |
| 325 | $this->assertResponseCode(200); |
| 326 | |
| 327 | } |
| 328 | |
| 329 | |
| 330 | |
| 331 | public function test_ทดสอบลบข้อมูลแบบเดี่ยวส่งข้อมูลไปแบบมีอยู่จริงผลลัพท์ต้องได้สำเร็จ_C1(){ |
| 332 | print " 10.ทดสอบลบข้อมูลแบบเดี่ยว ส่งข้อมูลไปแบบมีอยู่จริง ผลลัพท์ต้องได้สำเร็จ\n"; |
| 333 | $aParam = array( |
| 334 | 'tIDCode' => $this->code, |
| 335 | ); |
| 336 | $oOutput = $this->ajaxRequest('POST', 'customer/customerLevel/cCustomerLevel/FSaCstLevDeleteEvent',$aParam); |
| 337 | $this->assertStringContainsString( |
| 338 | 'success', $oOutput |
| 339 | ); |
| 340 | $this->assertResponseCode(200); |
| 341 | |
| 342 | } |
| 343 | |
| 344 | |
| 345 | public function test_FSvRSNDataList_C1(){ |
| 346 | print " 11.ทดสอบค้นหาข้อมูลจากหน้าจอ ต้องสำเร็จ\n"; |
| 347 | $aParam = array( |
| 348 | 'nPageCurrent' => 1, |
| 349 | 'tSearchAll' => 'HN001' |
| 350 | ); |
| 351 | $oOutput = $this->ajaxRequest('POST', 'customer/customerLevel/cCustomerLevel/FSvCstLevDataList',$aParam); |
| 352 | $this->assertStringContainsString( |
| 353 | 'odvRGPList', $oOutput |
| 354 | ); |
| 355 | $this->assertResponseCode(200); |
| 356 | |
| 357 | } |
| 358 | |
| 359 | |
| 360 | |
| 361 | |
| 362 | public function test_FSvRSNDataList_C2(){ |
| 363 | print " 12.ทดสอบกดหน้าถัดไป\n"; |
| 364 | $aParam = array( |
| 365 | 'nPageCurrent' => 2, |
| 366 | 'tSearchAll' => '' |
| 367 | ); |
| 368 | $oOutput = $this->ajaxRequest('POST', 'customer/customerLevel/cCustomerLevel/FSvCstLevDataList',$aParam); |
| 369 | $this->assertStringContainsString( |
| 370 | 'odvRGPList', $oOutput |
| 371 | ); |
| 372 | $this->assertResponseCode(200); |
| 373 | |
| 374 | } |
| 375 | |
| 376 | |
| 377 | |
| 378 | |
| 379 | |
| 380 | |
| 381 | |
| 382 | |
| 383 | |
| 384 | |
| 385 | |
| 386 | |
| 387 | |
| 388 | |
| 389 | |
| 390 | |
| 391 | |
| 392 | |
| 393 | |
| 394 | |
| 395 | |
| 396 | |
| 397 | |
| 398 | |
| 399 | |
| 400 | |
| 401 | |
| 402 | |
| 403 | |
| 404 | |
| 405 | |
| 406 | |
| 407 | |
| 408 | |
| 409 | |
| 410 | |
| 411 | |
| 412 | |
| 413 | |
| 414 | |
| 415 | |
| 416 | |
| 417 | |
| 418 | |
| 419 | |
| 420 | |
| 421 | |
| 422 | |
| 423 | |
| 424 | |
| 425 | |
| 426 | |
| 427 | |
| 428 | |
| 429 | |
| 430 | |
| 431 | |
| 432 | |
| 433 | |
| 434 | |
| 435 | } |