File: Test.pm

package info (click to toggle)
libmessage-passing-perl 0.117-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 544 kB
  • sloc: perl: 2,742; makefile: 2; sh: 1
file content (70 lines) | stat: -rw-r--r-- 1,397 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package Message::Passing::Output::Test;
use Moo;
use MooX::Types::MooseLike::Base qw/ ArrayRef /;
use namespace::clean -except => 'meta';

extends 'Message::Passing::Output::Callback';

has '+cb' => (
    default => sub { sub {} },
);

has _messages => (
    is => 'ro',
    isa => ArrayRef,
    default => sub { [] },
    clearer => 'clear_messages',
    lazy => 1,
);

sub messages { @{ $_[0]->_messages } }
sub consume_test { push(@{$_[0]->_messages }, $_[1]) }
sub message_count { scalar @{ $_[0]->_messages } }


after consume => sub {
    shift()->consume_test(@_);
};


1;

=head1 NAME

Message::Passing::Output::Test - Output for use in unit tests

=head1 SYNOPSIS

    You only want this if you're writing tests...
    See the current tests for examples..

=head1 METHODS

=head2 messages

=head2 clear_messages

Clears all stores messages. Useful to speed up tests by resetting the
instance instead of re-instantiating it.

=head2 consume_test

=head2 message_count

=head1 SEE ALSO

L<Message::Passing>

=head1 SPONSORSHIP

This module exists due to the wonderful people at Suretec Systems Ltd.
<http://www.suretecsystems.com/> who sponsored its development for its
VoIP division called SureVoIP <http://www.surevoip.co.uk/> for use with
the SureVoIP API -
<http://www.surevoip.co.uk/support/wiki/api_documentation>

=head1 AUTHOR, COPYRIGHT AND LICENSE

See L<Message::Passing>.

=cut