function test_ping_public() { $rmt_mck = new mck_mdl_remotes('sue', 'Big fat human'); $xml = new SimpleXMLElement("<data></data>"); $xml->addChild('remote_name', 'fred'); $xml->addChild('remote_profile', make_profile_url('fred')); $xml->addChild('remote_avatar', APP_ROOT . 'media/default_avatar.jpg'); $xml->addChild('remote_message', '@sue a message from fred'); $rmt = new mdl_remotes(); $_POST['data'] = $rmt->send_ping('http://localhost/', 'public', 'sue', $rmt_mck->get_pub_key(), $rmt_mck->get_priv_key(), $xml->asXML(), true); $msg = new ctrl_messages(); // call ping ob_start(); $msg->ping(); $result = ob_get_contents(); ob_end_clean(); $xml = $rmt->decode_ping_response($result); $this->assertTrue($xml->state == 'success'); $query = "SELECT * FROM `direct-message` WHERE `Remote_message` = '@sue a message from fred'"; $result = mysql_query($query); $this->assertEquals(mysql_num_rows($result), 1); }
function test_create_logged_in_invalid_url() { $_SESSION['active_user'] = array('name' => 'sue', 'id' => 2); $_POST = array( 'follow_user' => 'invalid_url', 'Submit' => 'Submit'); $rmt_mck = new mck_mdl_remotes('sue', 'Big fat human'); $rel = new ctrl_relations(); try { $rel->create($rmt_mck); $this->fail(); } catch(exception $e) { $this->assertEquals(preg_match("/messages/", $e->getMessage()), 1); } // After redirect, should display error $usr = new ctrl_messages(); $usr->index(); $result = $usr->display_outer(true); $this->assertEquals(preg_match("/url is invalid/", $result), 1); }