NAME
POE::Component::IRC::Test::Plugin - Part of the POE::Component::IRC test-suite.
SYNOPSIS
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();
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;
if ( !$self->plugin_add( 'TestPlugin' => $plugin ) ) {
fail( 'plugin_add' );
$self->yield( 'unregister' => 'all' );
$self->yield( 'shutdown' );
}
return:
}
sub irc_plugin_add {
my ($kernel, $heap, $desc, $plugin) = @_[KERNEL, HEAP, ARG0, ARG1];
isa_ok ( $plugin, 'POE::Component::IRC::Test::Plugin' );
if ( !$self->plugin_del( 'TestPlugin' ) ) {
fail( 'plugin_del' );
$self->yield( 'unregister' => 'all' );
$self->yield( 'shutdown' );
}
return;
}
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 {
if ( !$self->plugin_add( 'TestPlugin' => $plugin ) ) {
fail( 'plugin_add' );
$self->yield( 'unregister' => 'all' );
$self->yield( 'shutdown' );
}
}
return:
}
DESCRIPTION
POE::Component::IRC::Test::Plugin is a very simple POE::Component::IRC plugin used to test that the plugin system is working correctly, as demonstrated in the SYNOPSIS.
CONSTRUCTOR
new
-
No arguments required, returns an POE::Component::IRC::Test::Plugin object.
AUTHOR
Chris "BinGOs" Williams