#!/usr/bin/perl ##################################################################### # checks that the reflection methods return the right info about # other methods ################################################################### use Test::More tests => 11; use Test::Exception; use strict; use warnings; use Data::Dumper; use Test::Differences; use Test::XML; use Froody::Dispatch; my $client = Froody::Dispatch->new; ok my $rs = $client->call('froody.reflection.getMethods'), "Dispatch lives without authorization."; my $repo = Froody::Dispatch->new->repository; my $methods = [sort map { $_->full_name } $repo->get_methods()]; eq_or_diff( $rs->{method}, $methods, "Get the right list of methods") or die Dumper $rs, $methods; ok $rs = $client->call('froody.reflection.getMethodInfo', method_name => 'froody.reflection.getMethodInfo'); my $method = $repo->get_method('froody.reflection.getMethodInfo'); is $rs->{description}, $method->description, "Matching description"; is $rs->{name}, $method->full_name, "Matching full_name"; my $expected_errors = $method->errors; my $actual; foreach (@{ $rs->{arguments}{argument} }) { ok my $info = $method->arguments->{$_->{name}}; is $_->{-text}, $info->{doc}; is $_->{optional}, $info->{optional}; is $_->{type}, $info->{usertype}; } foreach (@{ $rs->{errors}{error} }) { $actual->{$_->{code}} = { description => $_->{-text}, message => $_->{message} }; } eq_or_diff($actual, $expected_errors); is_xml $rs->{response}, q{ A fake method xml-response-example Your favorite color. Your happy fun clothing of choice. Don't cross the streams. Don't cross the streams. };