Cpanel-iContact-Provider-XMPP.t 927 B

12345678910111213141516171819202122232425
  1. use strict;
  2. use warnings;
  3. use Cwd qw{abs_path};
  4. use File::Basename qw{dirname};
  5. use lib abs_path( dirname(__FILE__) . "/../lib" );
  6. use Test::More 'tests' => 4;
  7. use Test::Fatal;
  8. is( exception { require Cpanel::iContact::Provider::XMPP; }, undef, 'Module at least compiles' );
  9. isa_ok( my $xmpp = Cpanel::iContact::Provider::XMPP->new(), "Cpanel::iContact::Provider::XMPP" );
  10. my $sent;
  11. {
  12. no warnings qw{redefine once};
  13. *Net::XMPP::Client::Connect = sub { return 1; };
  14. *Net::XMPP::Client::AuthSend = sub { return ( 'ok', "Assumed Success" ); };
  15. *Net::XMPP::Client::MessageSend = sub { return; };
  16. *Net::XMPP::Client::Disconnect = sub { return; };
  17. is( exception { $sent = $xmpp->send(); }, undef, 'send() did not die' );
  18. }
  19. ok( $sent, "...and the message appears to have actually sent." );
  20. # TODO error paths
  21. #isnt( exception { $xmpp->send(); }, undef, "We blew up when we timed out on connect" );