Initial release
[poe-component-irc-plugin-hello.git] / t / POE-Component-IRC-Plugin-Hello.t
CommitLineData
29280d6c
MG
1use v5.14;
2use strict;
3use warnings;
4
5use Test::More tests => 15;
6use Test::MockObject;
7
8BEGIN { use_ok('POE::Component::IRC::Plugin::Hello') };
9
10# Variable setup
11my $hello_sent;
12
13my $mockirc = Test::MockObject->new;
14$mockirc->mock(yield => sub { $hello_sent = 1 })->set_always(nick_name => 'hellobot');
15
16my $self = POE::Component::IRC::Plugin::Hello->new;
17my $channels = [ '#chan' ];
18
19# Sub setup
20sub runtest{
21 my ($message, $expect, $comment) = @_;
22 $hello_sent=0;
23 $self->S_public($mockirc, \'mgv!marius@ieval.ro', \$channels, \$message);
24 ok($hello_sent == $expect, $comment)
25}
26
27#Tests
28runtest 'privet', 1, 'simple privet';
29runtest 'PrIvEt', 1, 'privet in mixed case';
30runtest ' privet ', 1, 'privet with spaces';
31runtest 'hellobot: privet', 1, 'addressed privet';
32runtest 'hellobot: privet ', 1, 'addressed privet with spaces';
33runtest 'ahoy', 1, 'ahoy';
34runtest 'namaste', 1, 'namaste';
35runtest 'neaţa', 1, 'neaţa (UTF-8 test)';
36runtest 'こんにちは', 1, 'こんにちは (another UTF-8 test)';
37
38runtest 'salu', 0, 'salu (misspelling)';
39runtest 'hii', 0, 'hii (misspelling)';
40runtest 'neaţa mgv', 0, 'neaţa mgv (valid greeting with garbage after it)';
41
42$self = POE::Component::IRC::Plugin::Hello->new(greetings => ['sayonara']);
43
44runtest 'privet', 0, 'custom greetings - privet';
45runtest ' sayonara ', 1, 'custom greetings - sayonara';
This page took 0.010833 seconds and 4 git commands to generate.