File Coverage

blib/lib/Apache2/ASP/Test/Base.pm
Criterion Covered Total %
statement 20 31 64.5
branch 0 4 0.0
condition n/a
subroutine 7 14 50.0
pod 5 8 62.5
total 32 57 56.1


line stmt bran cond sub pod time code
1              
2             package Apache2::ASP::Test::Base;
3              
4 18     18   95501 use strict;
  18         27  
  18         547  
5 18     18   72 use warnings 'all';
  18         24  
  18         621  
6 18     18   6891 use Apache2::ASP::ConfigLoader;
  18         47  
  18         622  
7 18     18   9531 use Apache2::ASP::Test::UserAgent;
  18         50  
  18         599  
8 18     18   7466 use Apache2::ASP::Test::Fixtures;
  18         60  
  18         518  
9 18     18   138 use Data::Properties::YAML;
  18         23  
  18         4357  
10              
11              
12             #==============================================================================
13             sub new
14             {
15 18     18 0 1307 my $class = shift;
16            
17 18         161 my $config = Apache2::ASP::ConfigLoader->load();
18            
19             # Our test fixtures:
20 0 0         my $data = Apache2::ASP::Test::Fixtures->new(
21             properties_file => $config->web->application_root . '/etc/test_fixtures.yaml'
22             ) if -f $config->web->application_root . '/etc/test_fixtures.yaml';
23            
24             # Our diagnostic messages:
25 0 0         my $properties = Data::Properties::YAML->new(
26             properties_file => $config->web->application_root . '/etc/properties.yaml'
27             ) if -f $config->web->application_root . '/etc/properties.yaml';
28            
29 0           my $s = bless {
30             # TBD:
31             ua => Apache2::ASP::Test::UserAgent->new( config => $config ),
32             config => $config,
33             data => $data,
34             properties => $properties,
35             }, $class;
36            
37 0           return $s;
38             }# end new()
39              
40              
41             #==============================================================================
42 0     0 1   sub ua { $_[0]->{ua} }
43 0     0 1   sub config { $_[0]->{config} }
44 0     0 0   sub data { $_[0]->{data} } # Deprecated
45 0     0 1   sub test_fixtures { $_[0]->{data} }
46 0     0 0   sub diags { $_[0]->{properties} } # Deprecated
47 0     0 1   sub properties { $_[0]->{properties} }
48 0     0 1   sub session { $_[0]->{ua}->context->session }
49              
50             1;# return true:
51              
52             =head1 NAME
53              
54             Apache2::ASP::Test::Base - base class for all test helper objects.
55              
56             =head1 SYNOPSIS
57              
58             #!/usr/bin/perl -w
59            
60             use strict;
61             use warnings 'all';
62             use Test::More 'no_plan';
63             use Apache2::ASP::Test::Base;
64            
65             ok( my $t = Apache2::ASP::Test::Base->new() );
66            
67             my $res = $t->ua->get("/index.asp");
68             ok( $res->is_success );
69             is( $res->header('location') => undef );
70              
71             =head1 DESCRIPTION
72              
73             The whole point of writing Apache2::ASP was to enable command-line testing
74             of entire websites - and to gather statistics via L and L.
75              
76             Somehow the test-driven-development world completely missed the point:
77              
78             B
79              
80             Apache2::ASP and this class provide an excellent means of doing that.
81              
82             See the C folder in this distribution for several examples of testing different
83             kinds of functionality with C.
84              
85             =head1 PUBLIC PROPERTIES
86              
87             =head2 ua
88              
89             Returns the current L object.
90              
91             =head2 config
92              
93             Shortcut method to the current L object.
94              
95             =head2 test_fixtures
96              
97             Shortcut method to the current L object
98             representing the test fixtures found in C
99              
100             =head2 properties
101              
102             Shortcut method to the current L object
103             representing the properties found in C
104              
105             =head2 session
106              
107             Shortcut method to the current L object.
108            
109             =head1 BUGS
110            
111             It's possible that some bugs have found their way into this release.
112            
113             Use RT L to submit bug reports.
114            
115             =head1 HOMEPAGE
116            
117             Please visit the Apache2::ASP homepage at L to see examples
118             of Apache2::ASP in action.
119            
120             =head1 AUTHOR
121            
122             John Drago L
123            
124             =head1 COPYRIGHT AND LICENSE
125            
126             Copyright 2007 John Drago, All rights reserved.
127            
128             This software is free software. It may be used and distributed under the
129             same terms as Perl itself.
130            
131             =cut
132