/** * * @dataProvider data4TestCartListException * */ public function testCartListException($userid, $type, $expect1, $expect2) { global $objSnakeAccountloginEnvConf; global $objSnakeAccountloginV4Conf; $arrCartListConf = $objSnakeAccountloginV4Conf->cart_list; $param = $arrCartListConf['args']; $param['userid'] = $userid; $param['type'] = $type; $ret = null; if ($arrCartListConf['isPost']) { $ret = Curl_class::curl_post($arrCartListConf['url'], $param, $arrCartListConf['host']); } else { $ret = Curl_class::curl_get($arrCartListConf['url'], $param, $arrCartListConf['host']); } //print_r($arrCartListConf); // print_r($ret); //校验http_code $this->assertEquals($expect1, $ret['http_code']); $arrBody = json_decode($ret['body'], true); //$this->assertEquals($expect2, $ret['http_code']); //判断data不为空 //$this->assertNotEmpty($arrBody['data']); //校验返回结果内容,购物车里面只有1个商品 //$this->assertEquals(1, count($arrBody['data']['info'])); //校验code }
/** * * @dataProvider data4TestCartListException * */ public function testCartListException($isHaiTao, $expect) { global $objSnakeCartV4Conf; global $objSnakeCartV4Conf; $arrCartListConf = $objSnakeCartV4Conf->cart_list; $param = $arrCartListConf['args']; $param['is_haitao'] = $isHaiTao; $ret = null; if ($arrCartListConf['isPost']) { $ret = Curl_class::curl_post($arrCartListConf['url'], $param, $arrCartListConf['host']); } else { $ret = Curl_class::curl_get($arrCartListConf['url'], $param, $arrCartListConf['host']); } //校验http_code $this->assertEquals(200, $ret['http_code']); $arrBody = json_decode($ret['body'], true); #print_r($arrCartListConf); #print_r($ret); #print_r($arrBody); //校验返回结果内容,购物车里面只有1个商品 $this->assertEquals(1, count($arrBody['data']['info'])); //校验code $this->assertEquals(0, $arrBody['data']['code']); $this->assertEquals(101277, $arrBody['data']['info'][0]['shop_id']); }
/** * * @dataProvider data4TestCartListException * */ public function testCartListException($isHaiTao, $expect) { // global $objSnakeCartV4Conf; // global $objSnakeCartV4Conf; global $objSnakeSharemainEnvConf; global $objSnakeSharemainV4Conf; $arrCartListConf = $objSnakeSharemainV4Conf->cart_list; //print_r($arrCartListConf); //echo "\n"; $param = $arrCartListConf['args']; //print_r($param); //echo "\n"; $param['twitter_id'] = $isHaiTao; $ret = null; // echo $arrCartListConf['url'];echo "\n"; if ($arrCartListConf['isPost']) { $ret = Curl_class::curl_post($arrCartListConf['url'], $param, $arrCartListConf['host']); } else { $ret = Curl_class::curl_get($arrCartListConf['url'], $param, $arrCartListConf['host']); } //校验http_code $this->assertEquals(200, $ret['http_code']); $arrBody = json_decode($ret['body'], true); #print_r($arrCartListConf); // print_r($ret); #print_r($arrBody); //echo $isHaiTao; //echo $arrBody['data']['twitter_id']; //校验返回结果的内容是否是传进去的twitter_id $this->assertEquals($isHaiTao, $arrBody['data']['twitter_id']); //检查是否有pic_url $this->assertNotEmpty($arrBody['data']['pic_url']); //校验code //$this->assertEquals(0, $arrBody['data']['code']); //$this->assertEquals(101277, $arrBody['data']['info'][0]['shop_id']); }
public function doRequestParam2($arrInterface, $strUrlPram, $arrUserInfo, $arrChange, $strAction, $boolShowLog) { if (empty($arrInterface)) { return -1; } $arrParam = self::$objParamHandler->genData($arrInterface['args'], $arrChange, $strAction); if ($arrInterface['needCookie']) { $arrInterface['host'][CURLOPT_COOKIE] = $arrUserInfo['cookie']; } if (empty($strAction)) { $arrParam = array(); } $strUrl = $arrInterface['url'] . '?' . $strUrlPram; var_dump($arrParam); $boolLoopFlag = true; while ($boolLoopFlag) { if ($arrInterface['isPost']) { $ret = Curl_class::curl_post($strUrl, $arrParam, $arrInterface['host']); } else { $ret = Curl_class::curl_get($strUrl, $arrParam, $arrInterface['host']); } $mixBody = json_decode($ret['body'], true); if (!is_array($mixBody)) { $mixBody['body'] = $ret['body']; } $strHeader = $ret['header']; if ($boolShowLog) { ColourMsg::display("interface", $arrInterface); ColourMsg::display("strUrl", $strUrl); ColourMsg::display("arrChange", $arrChange); ColourMsg::display("param", $arrParam); ColourMsg::display("arrUserInfo", $arrUserInfo); ColourMsg::display("Cookie", $arrInterface['host']); unset($ret['header']); ColourMsg::display("request result", $ret); } if ($ret['http_code'] != 200) { if (302 === $ret['http_code']) { $mixBody['http_code'] = 302; $mixBody['location'] = $this->getLocationFromHeader($strHeader); $boolLoopFlag = false; } else { $boolLoopFlag = true; } } else { $mixBody['http_code'] = 200; $mixBody['location'] = ''; $boolLoopFlag = false; } } return $mixBody; }
function subsearch($str, $start, $end) { $str = str_replace(chr(34), "", $str); $pos1 = strpos($str, $start); if ($pos1 > 0) { $pos2 = strpos($str, $end, $pos1 + strlen($start)); return substr($str, $pos1 + strlen($start), $pos2 - ($pos1 + strlen($start))); } else { return "0"; } } $urlhost = $_POST['urlhost']; $type = $_GET['type']; if ($type == "1") { $url = "https://user.daum.net/joinuser/join_step1.do?t__nil_loginbox=registration"; } else { if ($type == "2") { $url = $_GET['urlhost']; } } $curl_obj = new Curl_class(); $curl_opt[CURLOPT_SSL_VERIFYPEER] = 0; $curl_opt[CURLOPT_SSLVERSION] = 1; $curl_obj->url = $url; $curl_obj->addopt = $curl_opt; $curl_obj->post = 0; $curl_obj->headers = 1; $curl_obj->action(); $buffer = $curl_obj->receive; $ret = subsearch($buffer, "JSESSIONID=", ";"); echo $ret;