File Coverage

blib/lib/ASP4/Mock/Connection.pm
Criterion Covered Total %
statement 13 15 86.6
branch n/a
condition n/a
subroutine 5 7 71.4
pod 2 3 66.6
total 20 25 80.0


line stmt bran cond sub pod time code
1              
2             package ASP4::Mock::Connection;
3              
4 9     9   27 use strict;
  9         13  
  9         241  
5 9     9   32 use warnings 'all';
  9         45  
  9         220  
6 9     9   2803 use ASP4::Mock::ClientSocket;
  9         12  
  9         827  
7              
8             sub new {
9 5130     5130 0 10523 my $s = bless {
10             aborted => 0,
11             client_socket => ASP4::Mock::ClientSocket->new()
12             }, shift;
13             $s->{client_socket}->on_close(sub {
14 0     0   0 $s->{aborted} = 0;
15 5130         15800 });
16            
17 5130         37511 return $s;
18             }
19              
20 1103     1103 1 2660 sub aborted { shift->{aborted} }
21 0     0 1   sub client_socket { shift->{client_socket} }
22              
23             1;# return true:
24              
25             =pod
26              
27             =head1 NAME
28              
29             ASP4::Mock::Connection - Mimic the Apache2::Connection object
30              
31             =head1 SYNOPSIS
32              
33             my $connection = $r->connection;
34            
35             if( $connection->aborted ) {
36             # The connection has been closed:
37             }
38            
39             my $socket = $connection->client_socket;
40              
41             =head1 DESCRIPTION
42              
43             Minimal mimic of the L object.
44              
45             =head1 PUBLIC PROPERTIES
46              
47             =head2 aborted( )
48              
49             Returns true or false, if the current connection has been aborted or not - respectively.
50              
51             =head2 client_socket( )
52              
53             Returns an instance of L.
54              
55             =cut
56