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_ping_remove() { $rmt_mck = new mck_mdl_remotes('sue', 'Big fat human'); $rmt = new mdl_remotes(); $_POST['data'] = $rmt->send_ping( 'http://localhost', 'remove', 'fred', $rmt_mck->get_pub_key(), $rmt_mck->get_priv_key(), 'http://localhost/messages/follow/sue', true); $rel = new ctrl_relations(); ob_start(); $rel->ping($rmt_mck); $result = ob_get_contents(); ob_end_clean(); $ping_response = $rmt->decode_ping_response($result); $this->assertEquals((string) $ping_response->state, 'fail'); }
function test_validate_priv_key_valid() { $mck = new mck_mdl_remotes('',''); validate_priv_key($mck->get_priv_key()); }
function test_create_follower_invalid_message_pingback() { $rmt_mck = new mck_mdl_remotes('', ''); $this->setExpectedException('invalid_url_exception'); $rel = new mdl_relations(); $rel->create_follower(2, 'http://localhost/messages/follow/fred', 'fred', 'http://localhost/users/profile/fred', APP_ROOT . '/media/default_avatar.jpg', $rmt_mck->get_pub_key(), 'http://localhost/relations/ping', 'invalid_url'); }