function testParseMultiHeader() { $arr = array('a: 111', 'b: 222', 'c: 333'); $expectedArr = array('a' => '111', 'b' => '222', 'c' => '333'); $str = join("\r\n", $arr); $curl = new CurlHelper(); $curl->setOptions(''); $curl->getInstance(); $curlR = new CurlResponder('', $curl); $headers = $curlR->getHeaders($str); $this->assertEquals($expectedArr, $headers); }
function login($cookie_file) { $data = $this->getData(); $curl = new CurlHelper(); $url = $data['URL']; $post_params = []; foreach ($data['PARAMS'] as $param) { $param[1] = str_replace(['[USER]', '[PASS]'], [$this['user'], $this['pass']], $param[1]); $post_params[$param[0]] = $param[1]; } $options = [CURLOPT_COOKIEJAR => $cookie_file, CURLOPT_POST => true, CURLOPT_POSTFIELDS => http_build_query($post_params, '', '&')]; $curl->setOptions($url, null, $options); $curl->process(); $return = [CURLOPT_COOKIEFILE => $cookie_file]; return $return; }