Cpanel-iContact-Provider-XMPP.t 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. use strict;
  2. use warnings;
  3. use Test::More 'tests' => 5;
  4. use Test::Fatal;
  5. # ================================
  6. # MOCK ME BABY ALL NIGHT LONG
  7. # ================================
  8. package Cpanel::iContact::Provider;
  9. sub new {
  10. my $class = shift;
  11. my $self = {
  12. 'widdly' => 'waa',
  13. };
  14. return bless $self, $class;
  15. }
  16. is( exception { require Cpanel::iContact::Provider; }, undef, 'Module at least compiles' );
  17. isa_ok( my $xmpp = Cpanel::iContact::Provider::XMPP->new(), "Cpanel::iContact::Provider::XMPP" );
  18. my $sent;
  19. {
  20. no warnings qw{redefine once};
  21. *Net::XMPP::Client::Connect = sub { return 1; };
  22. *Net::XMPP::Client::AuthSend = sub { return ( 'ok', "Assumed Success" ); };
  23. *Net::XMPP::Client::MessageSend = sub { return; };
  24. *Net::XMPP::Client::Disconnect = sub { return; };
  25. is( exception { $sent = $xmpp->send(); }, undef, 'send() did not die' );
  26. }
  27. ok( $sent, "...and the message appears to have actually sent." );
  28. # TODO more error paths
  29. #isnt( exception { $xmpp->send(); }, undef, "We blew up when we timed out on connect" );