File Coverage

blib/lib/Siesta/Web/FakeApache.pm
Criterion Covered Total %
statement 12 28 42.8
branch n/a
condition n/a
subroutine 4 10 40.0
pod 1 5 20.0
total 17 43 39.5


line stmt bran cond sub pod time code
1 1     1   1728 use strict;
  1         3  
  1         52  
2             package Siesta::Web::FakeApache;
3 1     1   7 use base 'Class::Accessor::Fast';
  1         3  
  1         448  
4             __PACKAGE__->mk_accessors(qw( filename uri headers content_type ));
5              
6             sub new {
7 0     0 1 0 my $class = shift;
8 0         0 if (0) {
9             require YAML;
10             require CGI;
11             print CGI->header('text/plain');
12             print YAML::Dump(\%ENV );
13             exit;
14             }
15             $class->SUPER::new({
16 0         0 filename => "$ENV{DOCUMENT_ROOT}/$ENV{SCRIPT_NAME}", # this is fragile
17             uri => $ENV{REQUEST_URI},
18             headers => [],
19             content_type => 'text/html',
20             });
21             }
22              
23             sub header_out {
24 0     0 0 0 my $self = shift;
25 0         0 push @{ $self->headers }, [ @_ ];
  0         0  
26             }
27              
28             sub send_http_header {
29 0     0 0 0 my $self = shift;
30 0         0 print "Content-Type: ", $self->content_type, "\r\n";
31 0         0 print "$_->[0]: $_->[1]\r\n" for @{ $self->headers };
  0         0  
32 0         0 print "\r\n";
33             }
34              
35             sub print {
36 0     0 0 0 my $self = shift;
37 0         0 print @_;
38             }
39              
40             sub log_reason {
41 0     0 0 0 shift;
42 0         0 print STDERR @_;
43             }
44              
45              
46             package Apache::Constants;
47             $INC{'Apache/Constants.pm'} = 1;
48             sub import {
49 1     1   3 my $caller = caller;
50 1     1   6 no strict 'refs';
  1         8  
  1         99  
51 1     0   6 *{"$caller\::$_"} = sub {} for qw( DECLINED SERVER_ERROR OK );
  3         34  
  0            
52             }
53             1;