Skip to content

Commit

Permalink
Really basic mocking of Apache::Connection
Browse files Browse the repository at this point in the history
  • Loading branch information
2shortplanks committed Oct 9, 2012
1 parent 49e8bb9 commit d2b8671
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/Plack/App/FakeApache/Request.pm
Expand Up @@ -11,6 +11,7 @@ use Plack::Request;
use Plack::Response;
use Plack::App::File;

use Plack::App::FakeApache::Request::Connection;
use Cwd qw(cwd);

my $NS = "plack.app.fakeapache";
Expand Down Expand Up @@ -217,6 +218,15 @@ sub notes {
return $old;
}

# this is strictly mocking Apache::Connection, and only partially
sub connection {
my $self = shift;

return Plack::App::FakeApache::Request::Connection->new(
remote_ip => $self->plack_request->address,
);
}

sub read {
my $self = shift;
my ($buffer, $length, $offset) = @_; # ... but use $_[0] for buffer
Expand Down
21 changes: 21 additions & 0 deletions lib/Plack/App/FakeApache/Request/Connection.pm
@@ -0,0 +1,21 @@
package Plack::App::FakeApache::Request::Connection;

use Moose;

has remote_ip => (
is => 'rw',
isa => 'Str',
);

no Moose;
__PACKAGE__->meta->make_immutable;

1;

=head1 NAME
Plack::App::FakeApache::Request::Connection - mock Apache::Connection for Plack
=head1 DESCRIPTION
Only the C<remote_ip> method is implmented.

0 comments on commit d2b8671

Please sign in to comment.