function test_decode_ping_invalid_username()
    {
        $this->setExpectedException('invalid_username_exception');

        $rmt = new mdl_remotes();

        $xml = $rmt->send_ping(
            'http://localhost',
            'test',
            'fred',
            $this->get_pub_key(),
            $this->get_priv_key(),
            'this is some data',
            true);

        $xml = preg_replace('/<user>.+<\/user>/', '<user>+_</user>', $xml);

        $result = $rmt->decode_ping($xml, false);
    }
    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');
    }