public function testUrlOptions() { $url = 'http://httpbin.org/'; $request = new Request(); $request->setOption(CURLOPT_URL, $url); $this->assertEquals($url, $request->url); }
/** * Adds a Request * * @param \pahanini\curl\Request $request * @throws \yii\base\InvalidParamException */ public function add(Request $request) { if ($request->isExecuted()) { throw new InvalidParamException("Can not add executed request"); } $this->_requests[] = $request; }
public function testException() { $request1 = new Request(); $request1->setOptions([CURLOPT_URL => "http://httpbin.org"]); $request2 = new Request(); $request2->setOptions([CURLOPT_CONNECTTIMEOUT_MS => 1, CURLOPT_TIMEOUT_MS => 1, CURLOPT_URL => "http://httpbin.org/delay/3"]); $multi = new Multi(); $multi->add($request1); $multi->add($request2); $multi->execute(); $this->assertEquals(200, $request1->response->statusCode); $this->assertEquals(0, $request2->response->statusCode); }