Eve/EventTestBase.pm

filter: Statementstmt 88.8% 16 / 18 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 91.6% 22 / 24 CC 1 SCAR 0.5
CC
1
Cov
89%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Eve/RegistryStub.pm ↑ Summary Eve/PgSql.pm »
1 package Eve::EventTestBase;
2  
3 4 ▶use parent qw(Eve::Test);
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 4 ▶use Test::MockObject;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use Test::More;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 0 ▶use Eve::RegistryStub;
Subroutine BEGIN: called CC=1 SCAR=2.6
12  
13 use Eve::Registry;
14  
15 Eve::EventTestBase->SKIP_CLASS(1);
16  
17 =head1 NAME
18  
19 B<Eve::EventTestBase> - a base class for event test case classes.
20  
21 =head1 SYNOPSIS
22  
23 package BogusEventTest;
24  
25 use parent qw(Eve::EventTestBase);
26  
27 # Place the event test case class here
28  
29 =head1 DESCRIPTION
30  
31 B<Eve::EventTestBase> is the class that provides tests that are
32 required to pass for all event classes.
33  
34 =head1 METHODS
35  
36 =head2 B<setup()>
37  
38 =cut
39  
40 sub setup {
41 my $self = shift;
42  
43 $self->{'registry'} = Eve::Registry->new();
44 $self->{'event_map'} = $self->{'registry'}->get_event_map();
45 }
46  
47 =head2 B<test_trigger()>
48  
49 A mandatory test case for the C<trigger()> method.
50  
51 =cut
52  
53 sub test_trigger : Test(6) {
54 my $self = shift;
55  
56 my $handler_list = [];
57 for my $i (0..2) {
58 $self->{'event'}->trigger();
59  
60 for my $handler (@{$handler_list}) {
61 is($handler->call_pos(1), 'handle');
62 is_deeply(
63 [$handler->call_args(1)],
64 [$handler, event => $self->{'event'}]);
65 }
66  
67 my $handler_mock = Test::MockObject->new()->set_always('handle', 1);
68 push(@{$handler_list}, $handler_mock);
69 $self->{'event_map'}->bind(
70 event_class => ref $self->{'event'},
71 handler => $handler_mock);
72 }
73 }
74  
75 =head1 SEE ALSO
76  
77 =over 4
78  
79 =item L<Eve::Test>
80  
81 =item L<Test::Class>
82  
83 =back
84  
85 =head1 LICENSE AND COPYRIGHT
86  
87 Copyright 2010-2013 Sergey Konoplev, Igor Zinovyev.
88  
89 This program is free software; you can redistribute it and/or modify it
90 under the terms of either: the GNU General Public License as published
91 by the Free Software Foundation; or the Artistic License.
92  
93 See http://dev.perl.org/licenses/ for more information.
94  
95 =head1 AUTHOR
96  
97 =over 4
98  
99 =item L<Sergey Konoplev|mailto:gray.ru@gmail.com>
100  
101 =item L<Igor Zinovyev|mailto:zinigor@gmail.com>
102  
103 =back
104  
105 =cut
106  
107 1;
« Eve/RegistryStub.pm ↑ Summary Eve/PgSql.pm »