| 1 | <?php |
| 2 | class Poschannel_test extends TestCase |
| 3 | { |
| 4 | |
| 5 | |
| 6 | |
| 7 | public function __construct() { |
| 8 | parent::__construct(); |
| 9 | $ci = &get_instance(); |
| 10 | |
| 11 | $ci->load->helper('validator_helper'); |
| 12 | |
| 13 | $_SESSION = array( |
| 14 | '__ci_last_regenerate' => 1679905774, |
| 15 | 'lang' => 'th', |
| 16 | 'tLangID' => 1, |
| 17 | 'tSesUserLogin' => '009', |
| 18 | 'tSesUsrRoleCodeMulti' => '00003', |
| 19 | 'nSesUsrRoleLevel' => 99, |
| 20 | 'tSesUsrAgnCode' => '', |
| 21 | 'tSesUsrAgnName' => '', |
| 22 | 'tSesUsrMerCode' => '', |
| 23 | 'tSesUsrMerName' =>'', |
| 24 | 'tSesUsrBchCodeDefault' => '00000', |
| 25 | 'tSesUsrBchNameDefault' => 'สำนักงานใหญ่', |
| 26 | 'tSesUsrBchCodeMulti' => '00000', |
| 27 | 'tSesUsrBchNameMulti' => 'สำนักงานใหญ่', |
| 28 | 'nSesUsrBchCount' => 0, |
| 29 | 'tSesUsrShpCodeDefault' => '00002', |
| 30 | 'tSesUsrShpNameDefault' => 'DNetwork', |
| 31 | 'tSesUsrShpCodeMulti' => '00002', |
| 32 | 'tSesUsrShpNameMulti' => 'DNetwork', |
| 33 | 'nSesUsrShpCount' => 0, |
| 34 | 'tSesUsrWahCode' => '00001', |
| 35 | 'tSesUsrWahName' => 'คลังขาย ออนไลน์(HQ) F1RISTER-KPCWH-ONLINE-SALES', |
| 36 | 'tSesUsrLoginLevel' => 'HQ', |
| 37 | 'tSesUsrLoginAgency' => '0', |
| 38 | 'bSesLogIn' => 1, |
| 39 | 'tSesUserCode' => '00003', |
| 40 | 'tSesUsername' => '00003', |
| 41 | 'tSesUsrDptName' => '', |
| 42 | 'tSesUsrDptCode' => '', |
| 43 | 'tSesUsrUsername' => 'ผู้ดูแลระบบ(แอดมิน)Adasoft', |
| 44 | 'tSesUsrImagePerson' => '', |
| 45 | 'tSesUsrInfo' => array( |
| 46 | 'FTUsrStaActive' => '1', |
| 47 | 'FTUsrLogType' => '1', |
| 48 | 'FTStaError' => '0', |
| 49 | 'FTUsrCode' => '00003', |
| 50 | 'FTUsrName' => 'ผู้ดูแลระบบ(แอดมิน)Adasoft', |
| 51 | 'FTDptCode' => '', |
| 52 | 'FTDptName' => '', |
| 53 | 'FTImgObj' => '', |
| 54 | ), |
| 55 | 'tSesUsrGroup' => array( |
| 56 | '0' => array( |
| 57 | 'FTUsrCode' => '00003', |
| 58 | 'FTAgnCode' => '', |
| 59 | 'FTAgnName' => '', |
| 60 | 'FTBchCode' => '', |
| 61 | 'FTBchName' => '', |
| 62 | 'FTShpCode' => '', |
| 63 | 'FTShpName' => '', |
| 64 | 'FTMerCode' => '', |
| 65 | 'FTMerName' => '', |
| 66 | 'FTWahCode' => '', |
| 67 | 'FTWahName' => '', |
| 68 | 'FTLoginLevel' => 'HQ', |
| 69 | 'FTStaLoginAgn' => '0', |
| 70 | ), |
| 71 | ), |
| 72 | 'tSesSessionID' => '0000320230327152942', |
| 73 | 'tSesSessionDate' => '2023-03-27 15:29:42', |
| 74 | 'tLangEdit' => '1', |
| 75 | 'bIsHaveAgn' => '', |
| 76 | 'tSesUsrLevel' => 'HQ', |
| 77 | 'tSesUsrRoleSpcCodeMulti' => "'00003','00004','00005','00006','00007','00008','00009','00010','00011','00012','00013','00014','00015','00016','00017'", |
| 78 | 'bShpEnabled' => '1', |
| 79 | 'bAgnEnabled' => '1', |
| 80 | 'bLockerEnabled' => '1', |
| 81 | 'bPdtFasionEnabled' => '1', |
| 82 | 'bCatLvl1Enabled' => '1', |
| 83 | 'bCatLvl2Enabled' => '1', |
| 84 | 'bCatLvl3Enabled' => '1', |
| 85 | 'bCatLvl4Enabled' => '1', |
| 86 | 'bCatLvl5Enabled' => '1', |
| 87 | ); |
| 88 | $_SERVER['SERVER_NAME'] = ''; |
| 89 | } |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | public function test_CHN01_เข้าหน้าจอช่องทางการขาย(){ |
| 107 | echo ' 1 : เข้าหน้าจอช่องทางการขาย'; |
| 108 | $oOutput = $this->request('POST', 'pos/chanel/Poschanel_controller/index/0/0'); |
| 109 | $this->assertStringContainsString('oetChnCallBackOption', $oOutput); |
| 110 | $this->assertResponseCode(200); |
| 111 | } |
| 112 | |
| 113 | |
| 114 | public function test_CHN02_โหลดหน้าจอการค้นหาช่องทางการขาย(){ |
| 115 | echo ' 2 : โหลดหน้าจอการค้นหาช่องทางการขาย'; |
| 116 | $oOutput = $this->request('POST', 'pos/chanel/Poschanel_controller/FSvCCHNListPage'); |
| 117 | $this->assertStringContainsString('oimSearchChanel', $oOutput); |
| 118 | $this->assertResponseCode(200); |
| 119 | } |
| 120 | |
| 121 | |
| 122 | public function test_CHN03_โหลดข้อมูลรายการมาสเตอร์(){ |
| 123 | print ' 3 : โหลดข้อมูลรายการมาสเตอร์'; |
| 124 | $aParam = array( |
| 125 | 'nPageCurrent' => 1, |
| 126 | 'tSearchAll' => '' |
| 127 | ); |
| 128 | $oOutput = $this->ajaxRequest('POST', 'pos/chanel/Poschanel_controller/FSvCCHNDataList', $aParam); |
| 129 | $this->assertStringContainsString('odvRGPList', $oOutput); |
| 130 | $this->assertResponseCode(200); |
| 131 | } |
| 132 | |
| 133 | |
| 134 | public function test_CHN04_โหลดข้อมูลรายการมาสเตอร์แบบมีเงื่อนไขตัวกรอง(){ |
| 135 | print ' 4 : โหลดข้อมูลรายการมาสเตอร์แบบมีเงื่อนไขตัวกรอง'; |
| 136 | $aParam = array( |
| 137 | 'nPageCurrent' => 1, |
| 138 | 'tSearchAll' => 'ทดสอบ' |
| 139 | ); |
| 140 | $oOutput = $this->ajaxRequest('POST', 'pos/chanel/Poschanel_controller/FSvCCHNDataList', $aParam); |
| 141 | $this->assertStringContainsString('odvRGPList', $oOutput); |
| 142 | $this->assertResponseCode(200); |
| 143 | } |
| 144 | |
| 145 | |
| 146 | public function test_CHN05_โหลดข้อมูลรายการมาสเตอร์แบบมีเงื่อนไขหน้า2(){ |
| 147 | print ' 5 : โหลดข้อมูลรายการมาสเตอร์แบบมีเงื่อนไขหน้า2'; |
| 148 | $aParam = array( |
| 149 | 'nPageCurrent' => 2, |
| 150 | 'tSearchAll' => '' |
| 151 | ); |
| 152 | $oOutput = $this->ajaxRequest('POST', 'pos/chanel/Poschanel_controller/FSvCCHNDataList', $aParam); |
| 153 | $this->assertStringContainsString('odvRGPList', $oOutput); |
| 154 | $this->assertResponseCode(200); |
| 155 | } |
| 156 | |
| 157 | |
| 158 | public function test_CHN06_โหลดข้อมูลรายการมาสเตอร์แบบมีเงื่อนไขหน้า2และมีตัวกรอง(){ |
| 159 | print ' 6 : โหลดข้อมูลรายการมาสเตอร์แบบมีเงื่อนไขหน้า2และมีตัวกรอง'; |
| 160 | $aParam = array( |
| 161 | 'nPageCurrent' => 2, |
| 162 | 'tSearchAll' => 'ทดสอบ' |
| 163 | ); |
| 164 | $oOutput = $this->ajaxRequest('POST', 'pos/chanel/Poschanel_controller/FSvCCHNDataList', $aParam); |
| 165 | $this->assertStringContainsString('odvRGPList', $oOutput); |
| 166 | $this->assertResponseCode(200); |
| 167 | } |
| 168 | |
| 169 | |
| 170 | public function test_CHN07_โหลดข้อมูลหน้าจอเพิ่มมาสเตอร์(){ |
| 171 | print ' 7 : โหลดข้อมูลหน้าจอเพิ่มมาสเตอร์'; |
| 172 | $oOutput = $this->request('POST','pos/chanel/Poschanel_controller/FSvCHNAddPage'); |
| 173 | $this->assertStringContainsString('chanelEventAdd', $oOutput); |
| 174 | $this->assertResponseCode(200); |
| 175 | } |
| 176 | |
| 177 | |
| 178 | public function test_CHN08_เพิ่มข้อมูลมาสเตอร์แบบสร้างรหัสอัตโนมัติ(){ |
| 179 | print ' 8 : เพิ่มข้อมูลมาสเตอร์แบบสร้างรหัสอัตโนมัติ'; |
| 180 | $aParam = array( |
| 181 | 'oetChnSeq' => '', |
| 182 | 'oetChnUsrLoginLevel' => 'AGN', |
| 183 | 'ocbSlipmessageAutoGenCode' => '1', |
| 184 | 'ohdCheckDuplicateChnCode' => '1', |
| 185 | 'oetChnName' => 'PHPUNIT-ทดสอบ', |
| 186 | 'oetChnAppCode' => 'PS', |
| 187 | 'oetChnAppName' => 'ระบบ ขาย', |
| 188 | 'oetChnAgnCode' => '00002', |
| 189 | 'oetChnAgnName' => 'Akin Akids', |
| 190 | 'oetWahBchCodeCreated' => '', |
| 191 | 'oetWahBchNameCreated' => '', |
| 192 | 'oetChnPplCode' => '', |
| 193 | 'oetChnPplName' => '', |
| 194 | 'oetChnRefCode' => '', |
| 195 | 'ocbChnStatusUse' => 'on', |
| 196 | ); |
| 197 | $oOutput = $this->ajaxRequest('POST', 'pos/chanel/Poschanel_controller/FSaCHNAddEvent',$aParam); |
| 198 | $this->assertStringContainsString('Success Add Event', $oOutput); |
| 199 | $this->assertResponseCode(200); |
| 200 | } |
| 201 | |
| 202 | |
| 203 | public function test_CHN09_เพิ่มข้อมูลมาสเตอร์แบบสร้างรหัสด้วยตัวเองด้วยข้อมูลรหัสยังไม่มีอยู่ในระบบ(){ |
| 204 | print ' 9 : เพิ่มข้อมูลมาสเตอร์แบบสร้างรหัสด้วยตัวเองด้วยข้อมูลรหัสยังไม่มีอยู่ในระบบ'; |
| 205 | $aParam = array( |
| 206 | 'oetChnSeq' => '', |
| 207 | 'oetChnUsrLoginLevel' => 'AGN', |
| 208 | 'ohdCheckDuplicateChnCode' => '2', |
| 209 | 'oetChnCode' => 'T'.date('ds'), |
| 210 | 'oetChnName' => 'PHPUNIT-ทดสอบสร้างรหัสเอง', |
| 211 | 'oetChnAppCode' => 'PS', |
| 212 | 'oetChnAppName' => 'ระบบ ขาย', |
| 213 | 'oetChnAgnCode' => '00002', |
| 214 | 'oetChnAgnName' => 'Akin Akids', |
| 215 | 'oetWahBchCodeCreated' => '', |
| 216 | 'oetWahBchNameCreated' => '', |
| 217 | 'oetChnPplCode' => '', |
| 218 | 'oetChnPplName' => '', |
| 219 | 'oetChnRefCode' => '', |
| 220 | 'ocbChnStatusUse' => 'on', |
| 221 | ); |
| 222 | $oOutput = $this->ajaxRequest('POST', 'pos/chanel/Poschanel_controller/FSaCHNAddEvent',$aParam); |
| 223 | $this->assertStringContainsString('Success Add Event', $oOutput); |
| 224 | |
| 225 | } |
| 226 | |
| 227 | |
| 228 | public function test_CHN10_เพิ่มข้อมูลมาสเตอร์แบบสร้างรหัสด้วยตัวเองแบบรหัสซ้ำกับในระบบอยุ่แล้ว(){ |
| 229 | print ' 10 : เพิ่มข้อมูลมาสเตอร์แบบสร้างรหัสด้วยตัวเองแบบรหัสซ้ำกับในระบบอยุ่แล้ว'; |
| 230 | $aParam = array( |
| 231 | 'oetChnSeq' => '', |
| 232 | 'oetChnUsrLoginLevel' => 'AGN', |
| 233 | 'ohdCheckDuplicateChnCode' => '2', |
| 234 | 'oetChnCode' => 'TEST1', |
| 235 | 'oetChnName' => 'PHPUNIT-ทดสอบสร้างรหัสเอง-รหัสซ้ำ', |
| 236 | 'oetChnAppCode' => 'PS', |
| 237 | 'oetChnAppName' => 'ระบบ ขาย', |
| 238 | 'oetChnAgnCode' => '00002', |
| 239 | 'oetChnAgnName' => 'Akin Akids', |
| 240 | 'oetWahBchCodeCreated' => '', |
| 241 | 'oetWahBchNameCreated' => '', |
| 242 | 'oetChnPplCode' => '', |
| 243 | 'oetChnPplName' => '', |
| 244 | 'oetChnRefCode' => '', |
| 245 | 'ocbChnStatusUse' => 'on', |
| 246 | ); |
| 247 | $oOutput = $this->ajaxRequest('POST', 'pos/chanel/Poschanel_controller/FSaCHNAddEvent',$aParam); |
| 248 | $this->assertStringContainsString('Data Code Duplicate', $oOutput); |
| 249 | $this->assertResponseCode(200); |
| 250 | } |
| 251 | |
| 252 | |
| 253 | public function test_CHN11_โหลดข้อมูลมาสเตอร์หน้าจอแก้ไข(){ |
| 254 | print ' 11 : โหลดข้อมูลมาสเตอร์หน้าจอแก้ไข'; |
| 255 | $aParam = array( |
| 256 | 'tChnCode' => 'TEST1', |
| 257 | 'tChnBchCode' => '', |
| 258 | ); |
| 259 | $oOutput = $this->ajaxRequest('POST', 'pos/chanel/Poschanel_controller/FSvCHNEditPage',$aParam); |
| 260 | $this->assertStringContainsString('chanelEventEdit', $oOutput); |
| 261 | $this->assertResponseCode(200); |
| 262 | } |
| 263 | |
| 264 | |
| 265 | public function test_CHN12_แก้ไขข้อมูลมาสเตอร์(){ |
| 266 | print ' 12 : แก้ไขข้อมูลมาสเตอร์'; |
| 267 | $aParam = array( |
| 268 | 'oetChnSeq' => '3', |
| 269 | 'oetChnUsrLoginLevel' => 'AGN', |
| 270 | 'ohdCheckDuplicateChnCode' => '1', |
| 271 | 'oetChnCode' => 'T'.date('ds'), |
| 272 | 'oetChnName' => 'PHPUNIT-ทดสอบสร้างรหัสเอง แก้ไขข้อมูลครั้งที่ 1 ', |
| 273 | 'oetChnAppCode' => 'PS', |
| 274 | 'oetChnAppName' => 'ระบบ ขาย', |
| 275 | 'oetChnAgnCode' => '00002', |
| 276 | 'oetChnAgnName' => 'Akin Akids', |
| 277 | 'oetWahBchCodeCreated' => '', |
| 278 | 'oetWahBchNameCreated' => '', |
| 279 | 'oetChnPplCode' => '', |
| 280 | 'oetChnPplName' => '', |
| 281 | 'oetChnRefCode' => '', |
| 282 | 'ocbChnStatusUse' => 'on', |
| 283 | ); |
| 284 | $oOutput = $this->ajaxRequest('POST', 'pos/chanel/Poschanel_controller/FSaCHNEditEvent',$aParam); |
| 285 | $this->assertStringContainsString('Success Update Event', $oOutput); |
| 286 | $this->assertResponseCode(200); |
| 287 | } |
| 288 | |
| 289 | |
| 290 | public function test_CHN13_ลบข้อมูลรายการเดียว(){ |
| 291 | print ' 13 : ลบข้อมูลรายการเดียว'; |
| 292 | $aParam = array( |
| 293 | 'tChnCode' => 'T'.date('ds'), |
| 294 | 'tChnBchCode' => '' |
| 295 | ); |
| 296 | $oOutput = $this->request('POST','pos/chanel/Poschanel_controller/FSoCHNDelete', $aParam); |
| 297 | $this->assertStringContainsString('Delete Success.', $oOutput); |
| 298 | $this->assertResponseCode(200); |
| 299 | } |
| 300 | |
| 301 | |
| 302 | public function test_CHN15_เพิ่มข้อมูลแบบรหัสอัตโนมัติและมีชื่อที่ยาวเกินขนาดฟิวด์(){ |
| 303 | print ' 15 : เพิ่มข้อมูลแบบรหัสอัตโนมัติและมีชื่อที่ยาวเกินขนาดฟิว'; |
| 304 | $aParam = array( |
| 305 | 'oetChnCode' => '', |
| 306 | 'oetChnName' => 'ทดสอบ', |
| 307 | 'oetChnAppCode' => '', |
| 308 | 'oetChnAppName' => 'ระบบขาย', |
| 309 | ); |
| 310 | |
| 311 | $afield = [ |
| 312 | 'oetChnCode' => 'required', |
| 313 | 'oetChnName' => 'required', |
| 314 | 'oetChnAppCode' => 'required', |
| 315 | 'oetChnAppName' => 'required', |
| 316 | ]; |
| 317 | $aResult = json_encode(validate($aParam,$afield)); |
| 318 | $this->assertStringContainsString('Please enter the oetChnCode', $aResult); |
| 319 | } |
| 320 | |
| 321 | public function test_CHN16_เพิ่มข้อมูลแบบผิดประเภทของฟิวด์(){ |
| 322 | print ' 16 : เพิ่มข้อมูลแบบผิดประเภทของฟิวด์'; |
| 323 | $aParam = array( |
| 324 | 'oetChnCode' => 00001, |
| 325 | 'oetChnName' => 'ทดสอบ', |
| 326 | 'oetChnAppCode' => 'PS', |
| 327 | 'oetChnAppName' => 'ระบบขาย', |
| 328 | ); |
| 329 | |
| 330 | $afield = [ |
| 331 | 'oetChnCode' => 'String', |
| 332 | 'oetChnName' => 'String', |
| 333 | 'oetChnAppCode' => 'String', |
| 334 | 'oetChnAppName' => 'String', |
| 335 | ]; |
| 336 | $aResult = json_encode(validate_type($aParam,$afield)); |
| 337 | $this->assertStringContainsString('Error type varible', $aResult); |
| 338 | } |
| 339 | } |