function testSend() { $client = new DemocracyInAction_Client(); list($status, $data) = $client->send(authentication_url(), array('email' => test_user(), 'password' => test_pass()), 'post'); $this->assertWantedPattern('/Successful Login/', $data); $url = 'https://' . test_node() . '/api/getObjects.sjs'; list($status, $data) = $client->send($url, array('object' => 'supporter', 'limit' => 1)); $this->assertWantedPattern('/organization_KEY="1"/', $data); }
function authenticated_get($path) { $ch = authenticated_curl_handle(); $url = 'https://' . test_node() . $path; curl_setopt($ch, CURLOPT_URL, $url); $data = curl_exec($ch); $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); return array($status, $data); }
function testSaveResponse() { list($status, $by_query_data) = authenticated_get('/api/getObjects.sjs?object=supporter&limit=1'); $xml = new SimpleXMLElement($by_query_data); $supporters = $xml->xpath('/data/supporter/item'); $supporter = $supporters[0]; $key = $supporter->supporter_KEY; list($status, $data) = post('https://' . test_node() . '/save?xml=true&object=supporter&key=' . $key, array()); $this->assertWantedPattern('/You do not have permission to modify this object/', $data); list($status, $data) = authenticated_post('https://' . test_node() . '/save?xml=true&object=supporter&key=' . $key, array()); $this->assertWantedPattern('/Modified entry/', $data); }