Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 131 |
|
0.00% |
0 / 8 |
CRAP | |
0.00% |
0 / 1 |
| Salemonitor_test | |
0.00% |
0 / 131 |
|
0.00% |
0 / 8 |
90 | |
0.00% |
0 / 1 |
| __construct | n/a |
0 / 0 |
n/a |
0 / 0 |
1 | |||||
| test_เข้าหน้าแรก | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
| test_โหลดข้อมูลตัวกรอง | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
| test_แส้งข้อมูลรอบจุดขาย | |
0.00% |
0 / 15 |
|
0.00% |
0 / 1 |
2 | |||
| test_โหลดโมดอลข้อมูลตัวกรอง | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
2 | |||
| test_แสดงตารางข้อมูลรอบขายและกรองข้อมูลด้วยสาขา | |
0.00% |
0 / 25 |
|
0.00% |
0 / 1 |
2 | |||
| test_แสดงตารางข้อมูลรอบขายและกรองข้อมูลด้วยสาขาและจุดขาย | |
0.00% |
0 / 25 |
|
0.00% |
0 / 1 |
2 | |||
| test_แสดงตารางข้อมูลรอบขายและกรองข้อมูลด้วยสาขาและจุดขายและเรียงตามสาขาจากมากไปน้อย | |
0.00% |
0 / 25 |
|
0.00% |
0 / 1 |
2 | |||
| test_แสดงตารางข้อมูลรอบขายและเรียงตามวันที่จากมากไปน้อย | |
0.00% |
0 / 15 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Part of ci-phpunit-test |
| 4 | * |
| 5 | * @author Kenji Suzuki <https://github.com/kenjis> |
| 6 | * @license MIT License |
| 7 | * @copyright 2015 Kenji Suzuki |
| 8 | * @link https://github.com/kenjis/ci-phpunit-test |
| 9 | */ |
| 10 | |
| 11 | class Salemonitor_test extends TestCase |
| 12 | { |
| 13 | /** |
| 14 | *@codeCoverageIgnore |
| 15 | */ |
| 16 | public function __construct() { |
| 17 | parent::__construct(); |
| 18 | $ci = &get_instance(); |
| 19 | $ci->load->database(); |
| 20 | $ci->load->helper('validator_helper'); |
| 21 | $_SESSION['tSesUsername'] = ''; |
| 22 | $_SESSION['tLangID'] = 1; |
| 23 | $this->code = substr(md5(uniqid(mt_rand(), true)), 0, 5); |
| 24 | $ci->load->model('authen/login/Login_model'); |
| 25 | $tSQL = "SELECT |
| 26 | FTUsrCode, |
| 27 | COUNT (FTBchCode) AS nBch |
| 28 | FROM |
| 29 | TCNTUsrGroup |
| 30 | GROUP BY |
| 31 | FTUsrCode |
| 32 | HAVING |
| 33 | COUNT (FTBchCode) > 1"; |
| 34 | $aResult = $ci->db->query($tSQL);//หาผู้ใช้ที่มีสาขามากกว่า 1 สาขา |
| 35 | $aUsrData = $aResult->row_array(); |
| 36 | |
| 37 | $aDataUsrGroup = $ci->Login_model->FSaMLOGGetDataUserLoginGroup($aUsrData['FTUsrCode']); |
| 38 | $tUsrBchCodeMulti = $ci->Login_model->FStMLOGMakeArrayToString($aDataUsrGroup,'FTBchCode','value'); |
| 39 | $tUsrBchNameMulti = $ci->Login_model->FStMLOGMakeArrayToString($aDataUsrGroup,'FTBchName','value'); |
| 40 | $tUsrShpCodeMulti = $ci->Login_model->FStMLOGMakeArrayToString($aDataUsrGroup,'FTShpCode','value'); |
| 41 | $tUsrShpNameMulti = $ci->Login_model->FStMLOGMakeArrayToString($aDataUsrGroup,'FTShpName','value'); |
| 42 | $_SESSION =array ( |
| 43 | '__ci_last_regenerate' => 1674475513, |
| 44 | 'lang' => 'th', |
| 45 | 'tLangID' => 1, |
| 46 | 'tSesUserLogin' => '009', |
| 47 | 'tSesUsrRoleCodeMulti' => '\'00002\'', |
| 48 | 'nSesUsrRoleLevel' => 99, |
| 49 | 'tSesUsrAgnCode' => NULL, |
| 50 | 'tSesUsrAgnName' => NULL, |
| 51 | 'tSesUsrMerCode' => NULL, |
| 52 | 'tSesUsrMerName' => NULL, |
| 53 | 'tSesUsrBchCodeDefault' => '00001', |
| 54 | 'tSesUsrBchNameDefault' => 'AdaSoft00001', |
| 55 | 'tSesUsrBchCodeMulti' => $tUsrBchCodeMulti, |
| 56 | 'tSesUsrBchNameMulti' => $tUsrBchNameMulti, |
| 57 | 'nSesUsrBchCount' => 0, |
| 58 | 'tSesUsrShpCodeDefault' => '00014', |
| 59 | 'tSesUsrShpNameDefault' => 'รันไทม์ช็อป', |
| 60 | 'tSesUsrShpCodeMulti' => $tUsrShpCodeMulti, |
| 61 | 'tSesUsrShpNameMulti' => $tUsrShpNameMulti, |
| 62 | 'nSesUsrShpCount' => 0, |
| 63 | 'tSesUsrWahCode' => '00001', |
| 64 | 'tSesUsrWahName' => 'คลังขาย', |
| 65 | 'tSesUsrLoginLevel' => 'BCH', |
| 66 | 'tSesUsrLoginAgency' => 0, |
| 67 | 'bSesLogIn' => 1, |
| 68 | 'tSesUserCode' => $aUsrData['FTUsrCode'], |
| 69 | 'tSesUsername' => $aUsrData['FTUsrCode'], |
| 70 | 'tSesUsrDptName' => NULL, |
| 71 | 'tSesUsrDptCode' => NULL, |
| 72 | 'tSesUsrUsername' => 'Adasoft', |
| 73 | 'tSesUsrImagePerson' => NULL, |
| 74 | 'tSesUsrInfo' => |
| 75 | array ( |
| 76 | 'FTUsrStaActive' => 1, |
| 77 | 'FTUsrLogType' => 1, |
| 78 | 'FTStaError' => 0, |
| 79 | 'FTUsrCode' => $aUsrData['FTUsrCode'], |
| 80 | 'FTUsrName' => 'Adasoft', |
| 81 | 'FTDptCode' => NULL, |
| 82 | 'FTDptName' => NULL, |
| 83 | 'FTImgObj' => NULL, |
| 84 | ), |
| 85 | 'tSesUsrGroup' => |
| 86 | array ( |
| 87 | 0 => |
| 88 | array ( |
| 89 | 'FTUsrCode' => '00002', |
| 90 | 'FTAgnCode' => NULL, |
| 91 | 'FTAgnName' => NULL, |
| 92 | 'FTBchCode' => NULL, |
| 93 | 'FTBchName' => NULL, |
| 94 | 'FTShpCode' => NULL, |
| 95 | 'FTShpName' => NULL, |
| 96 | 'FTMerCode' => NULL, |
| 97 | 'FTMerName' => NULL, |
| 98 | 'FTWahCode' => NULL, |
| 99 | 'FTWahName' => NULL, |
| 100 | 'FTLoginLevel' => 'BCH', |
| 101 | 'FTStaLoginAgn' => 0, |
| 102 | ), |
| 103 | ), |
| 104 | 'tSesSessionID' => '0000220230123185822', |
| 105 | 'tSesSessionDate' => '2023-01-23 18:58:22', |
| 106 | 'tLangEdit' => 1, |
| 107 | 'bIsHaveAgn' => NULL, |
| 108 | 'tSesUsrLevel' => 'BCH', |
| 109 | '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\'', |
| 110 | 'bShpEnabled' => 1, |
| 111 | 'bAgnEnabled' => 1, |
| 112 | 'bLockerEnabled' => NULL, |
| 113 | 'bPdtFasionEnabled' => NULL, |
| 114 | 'tSesHQBchCode' => '00001', |
| 115 | 'bSesRegStaLicense' => 1, |
| 116 | 'tSesCstKey' => '52a8a4705e6c', |
| 117 | 'bSesRegStaBuyPackage' => 1, |
| 118 | ); |
| 119 | |
| 120 | |
| 121 | } |
| 122 | |
| 123 | // $route['salemonitor/(:any)/(:any)'] = 'sale/salemonitor/Salemonitor_controller/index/$1/$2'; |
| 124 | // $route['salemonitorMainPage'] = 'sale/salemonitor/Salemonitor_controller/FSvCSMTSALMainPage'; |
| 125 | // $route['salemonitorCallModalFilter'] = 'sale/salemonitor/Salemonitor_controller/FSvCSMTSALCallModalFilter'; |
| 126 | // $route['salemonitorConfirmFilter'] = 'sale/salemonitor/Salemonitor_controller/FSvCSMTSALConfirmFilter'; |
| 127 | // $route['salemonitorCallSaleDataTable'] = 'sale/salemonitor/Salemonitor_controller/FSvCSMTCallSaleDataTable'; |
| 128 | // $route['salemonitorCallApiDataTable'] = 'sale/salemonitor/Salemonitor_controller/FSvCSMTCallApiDataTable'; |
| 129 | // $route['salemonitorCallMQRequestSaleData'] = 'sale/salemonitor/Salemonitor_controller/FSvCSMTCallMQRequestSaleData'; |
| 130 | // $route['salemonitorCallMQRequestApiData'] = 'sale/salemonitor/Salemonitor_controller/FSvCSMTCallMQRequestApiData'; |
| 131 | // $route['salemonitorRequestAPIInOnLine'] = 'sale/salemonitor/Salemonitor_controller/FSaCSMTRequestAPIIsOnLine'; |
| 132 | |
| 133 | public function test_เข้าหน้าแรก(){ |
| 134 | print "1.test_เข้าหน้าแรก\n"; |
| 135 | |
| 136 | |
| 137 | $oOutput = $this->request( |
| 138 | 'POST', |
| 139 | 'sale/salemonitor/Salemonitor_controller/index/0/0', |
| 140 | ); |
| 141 | $this->assertStringContainsString('ohdSMTSALBrowseType', $oOutput); |
| 142 | $this->assertResponseCode(200); |
| 143 | } |
| 144 | |
| 145 | |
| 146 | public function test_โหลดข้อมูลตัวกรอง(){ |
| 147 | print "2.test_โหลดข้อมูลตัวกรอง\n"; |
| 148 | |
| 149 | |
| 150 | $oOutput = $this->request( |
| 151 | 'POST', |
| 152 | 'sale/salemonitor/Salemonitor_controller/FSvCSMTSALMainPage', |
| 153 | ); |
| 154 | $this->assertStringContainsString('oetDSHSALSort', $oOutput); |
| 155 | $this->assertResponseCode(200); |
| 156 | } |
| 157 | |
| 158 | |
| 159 | public function test_แส้งข้อมูลรอบจุดขาย(){ |
| 160 | print "3.test_แส้งข้อมูลรอบจุดขาย\n"; |
| 161 | |
| 162 | $aParam = array( |
| 163 | 'oetSMTSALDateDataForm' => '2023-07-21', |
| 164 | 'oetSMTSALDateDataTo' => '2023-07-21', |
| 165 | 'oetDSHSALSort' => '', |
| 166 | 'oetDSHSALFild' => 'FTBchName,FTPosCode', |
| 167 | 'nPageCurrent' => '1', |
| 168 | ); |
| 169 | $oOutput = $this->request( |
| 170 | 'POST', |
| 171 | 'sale/salemonitor/Salemonitor_controller/FSvCSMTCallSaleDataTable', |
| 172 | $aParam |
| 173 | ); |
| 174 | $this->assertStringContainsString('otbSplDataList', $oOutput); |
| 175 | $this->assertResponseCode(200); |
| 176 | } |
| 177 | |
| 178 | |
| 179 | public function test_โหลดโมดอลข้อมูลตัวกรอง(){ |
| 180 | print "4.test_โหลดโมดอลข้อมูลตัวกรอง\n"; |
| 181 | |
| 182 | $aParam = array( |
| 183 | 'ptFilterDataKey' => 'FSD', |
| 184 | 'ptFilterDataGrp' => 'BCH,SHP,POS', |
| 185 | ); |
| 186 | |
| 187 | $oOutput = $this->request( |
| 188 | 'POST', |
| 189 | 'sale/salemonitor/Salemonitor_controller/FSvCSMTSALCallModalFilter', |
| 190 | $aParam |
| 191 | ); |
| 192 | $this->assertStringContainsString('ofmSMTSALFormFilter', $oOutput); |
| 193 | $this->assertResponseCode(200); |
| 194 | } |
| 195 | |
| 196 | |
| 197 | |
| 198 | public function test_แสดงตารางข้อมูลรอบขายและกรองข้อมูลด้วยสาขา(){ |
| 199 | print "5.test_แสดงตารางข้อมูลรอบขายและกรองข้อมูลด้วยสาขา\n"; |
| 200 | |
| 201 | $aParam = array( |
| 202 | 'ohdSMTSALFilterKey' => 'FSD', |
| 203 | 'oetSMTSALFilterBchStaAll' => '', |
| 204 | 'oetSMTSALFilterBchCode' => '00001,00003,00004', |
| 205 | 'oetSMTSALFilterBchName' => 'AdaSoft00001,M&M Group (HQ),ทดสอบส่งเมล00004', |
| 206 | 'oetSMTSALFilterShpStaAll' => '', |
| 207 | 'oetSMTSALFilterShpCode' => '', |
| 208 | 'oetSMTSALFilterShpName' => '', |
| 209 | 'oetSMTSALFilterPosStaAll' => '', |
| 210 | 'oetSMTSALFilterPosCode' => '', |
| 211 | 'oetSMTSALFilterPosName' => '', |
| 212 | 'oetSMTSALDateDataForm' => '2023-07-01', |
| 213 | 'oetSMTSALDateDataTo' => '2023-07-21', |
| 214 | 'oetDSHSALSort' => 'ASC', |
| 215 | 'oetDSHSALFild' => 'FTShfCode', |
| 216 | 'nPageCurrent' => '1', |
| 217 | ); |
| 218 | |
| 219 | $oOutput = $this->request( |
| 220 | 'POST', |
| 221 | 'sale/salemonitor/Salemonitor_controller/FSvCSMTCallSaleDataTable', |
| 222 | $aParam |
| 223 | ); |
| 224 | $this->assertStringContainsString('otbSplDataList', $oOutput); |
| 225 | $this->assertResponseCode(200); |
| 226 | } |
| 227 | |
| 228 | public function test_แสดงตารางข้อมูลรอบขายและกรองข้อมูลด้วยสาขาและจุดขาย(){ |
| 229 | print "6.test_แสดงตารางข้อมูลรอบขายและกรองข้อมูลด้วยสาขาและจุดขาย\n"; |
| 230 | |
| 231 | $aParam = array( |
| 232 | 'ohdSMTSALFilterKey' => 'FSD', |
| 233 | 'oetSMTSALFilterBchStaAll' => '', |
| 234 | 'oetSMTSALFilterBchCode' => '00001', |
| 235 | 'oetSMTSALFilterBchName' => 'AdaSoft00001', |
| 236 | 'oetSMTSALFilterShpStaAll' => '', |
| 237 | 'oetSMTSALFilterShpCode' => '', |
| 238 | 'oetSMTSALFilterShpName' => '', |
| 239 | 'oetSMTSALFilterPosStaAll' => '', |
| 240 | 'oetSMTSALFilterPosCode' => '00026', |
| 241 | 'oetSMTSALFilterPosName' => 'จุดขาย00026', |
| 242 | 'oetSMTSALDateDataForm' => '2023-07-01', |
| 243 | 'oetSMTSALDateDataTo' => '2023-07-21', |
| 244 | 'oetDSHSALSort' => 'ASC', |
| 245 | 'oetDSHSALFild' => 'FTShfCode', |
| 246 | 'nPageCurrent' => '1', |
| 247 | ); |
| 248 | |
| 249 | $oOutput = $this->request( |
| 250 | 'POST', |
| 251 | 'sale/salemonitor/Salemonitor_controller/FSvCSMTCallSaleDataTable', |
| 252 | $aParam |
| 253 | ); |
| 254 | $this->assertStringContainsString('otbSplDataList', $oOutput); |
| 255 | $this->assertResponseCode(200); |
| 256 | } |
| 257 | |
| 258 | |
| 259 | public function test_แสดงตารางข้อมูลรอบขายและกรองข้อมูลด้วยสาขาและจุดขายและเรียงตามสาขาจากมากไปน้อย(){ |
| 260 | print "7.test_แสดงตารางข้อมูลรอบขายและกรองข้อมูลด้วยสาขาและจุดขายและเรียงตามสาขาจากมากไปน้อย\n"; |
| 261 | |
| 262 | $aParam = array( |
| 263 | 'ohdSMTSALFilterKey' => 'FSD', |
| 264 | 'oetSMTSALFilterBchStaAll' => '', |
| 265 | 'oetSMTSALFilterBchCode' => '00001', |
| 266 | 'oetSMTSALFilterBchName' => 'AdaSoft00001', |
| 267 | 'oetSMTSALFilterShpStaAll' => '', |
| 268 | 'oetSMTSALFilterShpCode' => '', |
| 269 | 'oetSMTSALFilterShpName' => '', |
| 270 | 'oetSMTSALFilterPosStaAll' => '', |
| 271 | 'oetSMTSALFilterPosCode' => '00026', |
| 272 | 'oetSMTSALFilterPosName' => 'จุดขาย00026', |
| 273 | 'oetSMTSALDateDataForm' => '2023-07-01', |
| 274 | 'oetSMTSALDateDataTo' => '2023-07-21', |
| 275 | 'oetDSHSALSort' => 'DESC', |
| 276 | 'oetDSHSALFild' => 'FTBchName', |
| 277 | 'nPageCurrent' => '1', |
| 278 | ); |
| 279 | |
| 280 | $oOutput = $this->request( |
| 281 | 'POST', |
| 282 | 'sale/salemonitor/Salemonitor_controller/FSvCSMTCallSaleDataTable', |
| 283 | $aParam |
| 284 | ); |
| 285 | $this->assertStringContainsString('otbSplDataList', $oOutput); |
| 286 | $this->assertResponseCode(200); |
| 287 | } |
| 288 | |
| 289 | |
| 290 | public function test_แสดงตารางข้อมูลรอบขายและเรียงตามวันที่จากมากไปน้อย(){ |
| 291 | print "8.test_แสดงตารางข้อมูลรอบขายและเรียงตามวันที่จากมากไปน้อย\n"; |
| 292 | |
| 293 | $aParam = array( |
| 294 | 'oetSMTSALDateDataForm' => '2023-07-01', |
| 295 | 'oetSMTSALDateDataTo' => '2023-07-21', |
| 296 | 'oetDSHSALSort' => 'DESC', |
| 297 | 'oetDSHSALFild' => 'FDShdSaleDate', |
| 298 | 'nPageCurrent' => '1', |
| 299 | ); |
| 300 | |
| 301 | $oOutput = $this->request( |
| 302 | 'POST', |
| 303 | 'sale/salemonitor/Salemonitor_controller/FSvCSMTCallSaleDataTable', |
| 304 | $aParam |
| 305 | ); |
| 306 | $this->assertStringContainsString('otbSplDataList', $oOutput); |
| 307 | $this->assertResponseCode(200); |
| 308 | } |
| 309 | |
| 310 | |
| 311 | |
| 312 | |
| 313 | } |