/** * Adds the data value to the curl request */ protected function prepareData() { if (!empty($this->data)) { if ($this->method === HttpMethods::GET) { $this->url = Utils::appendUrlQuery($this->url, $this->data); } else { if ($this->method === HttpMethods::POST) { curl_setopt($this->curl, CURLOPT_POSTFIELDS, $this->data); } } } }
/** * @covers Headzoo\Web\Tools\Utils::appendUrlQuery */ public function testAppendUrlQuery() { $this->assertEquals("http://site.com?name=Sean&job=programmer", Utils::appendUrlQuery("http://site.com", "name=Sean&job=programmer")); $this->assertEquals("http://site.com?action=list&name=Sean&job=programmer", Utils::appendUrlQuery("http://site.com?action=list", "name=Sean&job=programmer")); $this->assertEquals("http://site.com?action=list&name=Sean&job=programmer", Utils::appendUrlQuery("http://site.com?action=list", "?name=Sean&job=programmer")); }