NAME
Test::Plack::Handler::Stomp::FakeStomp - subclass of Net::Stomp, half-mocked for testing
VERSION
version 1.15
DESCRIPTION
This class is designed to be used in conjuction with Test::Plack::Handler::Stomp. It expects a set of callbacks that will be invoked whenever a method is called. It also does not talk to the network at all.
METHODS
new
my $stomp = Test::Plack::Handler::Stomp::FakeStomp->new({
new => sub { $self->queue_constructor_call(shift) },
connect => sub { $self->queue_connection_call(shift) },
disconnect => sub { $self->queue_disconnection_call(shift) },
subscribe => sub { $self->queue_subscription_call(shift) },
unsubscribe => sub { $self->queue_unsubscription_call(shift) },
send_frame => sub { $self->queue_sent_frame(shift) },
receive_frame => sub { $self->next_frame_to_receive() },
},$params);
The first parameter must be a hashref with all those keys pointing to coderefs. Each coderef will be invoked when the corresponding method is called, and will receive all the parameters of that call (minus the invocant).
The parameters (to this new
) after the first will be passed to Net::Stomp's new
.
The new
callback is called by this method, just before delegating to the inherited constructor. This callback does not receive the callback hashref (i.e. it receives @_[2..*]
.
connect
Calls the connect
callback, and returns 1.
disconnect
Calls the disconnect
callback, and returns 1.
can_read
Returns 1.
subscribe
Calls the subscribe
callback, and returns 1.
unsubscribe
Calls the unsubscribe
callback, and returns 1.
send_frame
Calls the send_frame
callback.
receive_frame
Calls the receive_frame
callback, and returns whatever that returned.
AUTHOR
Gianni Ceccarelli <gianni.ceccarelli@net-a-porter.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2020 by Net-a-porter.com.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.