Test::Plack::Handler::Stomp::FakeStomp - subclass of Net::Stomp, half-mocked for testing
version 1.15
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.
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..*].
@_[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.
Gianni Ceccarelli <gianni.ceccarelli@net-a-porter.com>
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.
To install Plack::Handler::Stomp, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Plack::Handler::Stomp
CPAN shell
perl -MCPAN -e shell install Plack::Handler::Stomp
For more information on module installation, please visit the detailed CPAN module installation guide.