POE::Component::IRC::Test::Plugin - Part of the the POE::Component::IRC manpage test-suite.
use Test::More tests => 16; BEGIN { use_ok('POE::Component::IRC') }; BEGIN { use_ok('POE::Component::IRC::Test::Plugin') }; use POE;
my $self = POE::Component::IRC->spawn( );
isa_ok ( $self, 'POE::Component::IRC' );
POE::Session->create( inline_states => { _start => \&test_start, }, package_states => [ 'main' => [ qw(irc_plugin_add irc_plugin_del) ], ], );
$poe_kernel->run(); exit 0;
sub test_start { my ($kernel,$heap) = @_[KERNEL,HEAP];
$self->yield( 'register' => 'all' );
my $plugin = POE::Component::IRC::Test::Plugin->new(); isa_ok ( $plugin, 'POE::Component::IRC::Test::Plugin' ); $heap->{counter} = 6; unless ( $self->plugin_add( 'TestPlugin' => $plugin ) ) { fail( 'plugin_add' ); $self->yield( 'unregister' => 'all' ); $self->yield( 'shutdown' ); }
undef; }
sub irc_plugin_add { my ($kernel,$heap,$desc,$plugin) = @_[KERNEL,HEAP,ARG0,ARG1];
isa_ok ( $plugin, 'POE::Component::IRC::Test::Plugin' ); unless ( $self->plugin_del( 'TestPlugin' ) ) { fail( 'plugin_del' ); $self->yield( 'unregister' => 'all' ); $self->yield( 'shutdown' ); } undef; }
sub irc_plugin_del { my ($kernel,$heap,$desc,$plugin) = @_[KERNEL,HEAP,ARG0,ARG1];
isa_ok ( $plugin, 'POE::Component::IRC::Test::Plugin' ); $heap->{counter}--; if ( $heap->{counter} <= 0 ) { $self->yield( 'unregister' => 'all' ); $self->yield( 'shutdown' ); } else { unless ( $self->plugin_add( 'TestPlugin' => $plugin ) ) { fail( 'plugin_add' ); $self->yield( 'unregister' => 'all' ); $self->yield( 'shutdown' ); } } undef; }
POE::Component::IRC::Test::Plugin is a very simple the POE::Component::IRC manpage plugin used to test that the plugin system is working correctly, as demonstrated in the SYNOPSIS.
No arguments required, returns an POE::Component::IRC::Test::Plugin object.
Chris "BinGOs" Williams