line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
XAO::testcases::base - base class for easier XAO::Web project testing |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 DESCRIPTION |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
This class extends XAO::testcases::base for easier testing of Web based |
8
|
|
|
|
|
|
|
projects. It adds a CGI variable to the setup. |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=cut |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
############################################################################### |
13
|
|
|
|
|
|
|
package XAO::testcases::Web::base; |
14
|
22
|
|
|
22
|
|
449888
|
use strict; |
|
22
|
|
|
|
|
52
|
|
|
22
|
|
|
|
|
576
|
|
15
|
22
|
|
|
22
|
|
8113
|
use IO::File; |
|
22
|
|
|
|
|
128893
|
|
|
22
|
|
|
|
|
2449
|
|
16
|
22
|
|
|
22
|
|
174
|
use XAO::Utils; |
|
22
|
|
|
|
|
43
|
|
|
22
|
|
|
|
|
985
|
|
17
|
22
|
|
|
22
|
|
6114
|
use XAO::Base; |
|
22
|
|
|
|
|
16875
|
|
|
22
|
|
|
|
|
769
|
|
18
|
22
|
|
|
22
|
|
5850
|
use XAO::Objects; |
|
22
|
|
|
|
|
26788
|
|
|
22
|
|
|
|
|
604
|
|
19
|
22
|
|
|
22
|
|
7830
|
use XAO::Web; |
|
22
|
|
|
|
|
61
|
|
|
22
|
|
|
|
|
729
|
|
20
|
22
|
|
|
22
|
|
153
|
use XAO::Projects qw(:all); |
|
22
|
|
|
|
|
48
|
|
|
22
|
|
|
|
|
2978
|
|
21
|
|
|
|
|
|
|
|
22
|
22
|
|
|
22
|
|
345
|
use base qw(XAO::testcases::base); |
|
22
|
|
|
|
|
62
|
|
|
22
|
|
|
|
|
10201
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub new ($) { |
25
|
22
|
|
|
22
|
0
|
7084
|
my $proto=shift; |
26
|
22
|
|
|
|
|
143
|
my $self=$proto->SUPER::new(@_); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Site root is not set up yet at this point, so can't use the data |
29
|
|
|
|
|
|
|
# from the test site configuration. |
30
|
|
|
|
|
|
|
# |
31
|
|
|
|
|
|
|
# Nearly identical code is in t/xao/projects/test/objects/Config.pm |
32
|
|
|
|
|
|
|
# |
33
|
22
|
|
|
|
|
210
|
my %d; |
34
|
22
|
|
|
|
|
37
|
if(1) { |
35
|
22
|
50
|
|
|
|
954
|
open(F,'.config') || |
36
|
|
|
|
|
|
|
die "No .config found, run 'perl Makefile.PL'"; |
37
|
22
|
|
|
|
|
132
|
local($/); |
38
|
22
|
|
|
|
|
459
|
my $t=; |
39
|
22
|
|
|
|
|
206
|
close(F); |
40
|
22
|
|
|
|
|
1586
|
eval $t; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
22
|
50
|
|
|
|
213
|
$self->{'skip_db_tests'}=$d{'test_dsn'} eq 'none' ? 1 : 0; |
44
|
|
|
|
|
|
|
|
45
|
22
|
|
|
|
|
114
|
return $self; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub list_tests ($) { |
49
|
44
|
|
|
44
|
0
|
5413
|
my $self=shift; |
50
|
|
|
|
|
|
|
|
51
|
44
|
|
|
|
|
181
|
my @tests=$self->SUPER::list_tests(@_); |
52
|
|
|
|
|
|
|
|
53
|
44
|
50
|
|
|
|
13502
|
if($self->{'skip_db_tests'}) { |
54
|
44
|
|
|
|
|
74
|
@tests=grep { ! /_db_/ } @tests; |
|
96
|
|
|
|
|
238
|
|
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
44
|
50
|
|
|
|
173
|
return wantarray ? @tests : \@tests; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub set_up { |
61
|
38
|
|
|
38
|
0
|
7059
|
my $self=shift; |
62
|
|
|
|
|
|
|
|
63
|
38
|
|
|
|
|
174
|
$self->SUPER::set_up(); |
64
|
|
|
|
|
|
|
|
65
|
38
|
|
|
|
|
95511
|
my $site=XAO::Web->new(sitename => 'test'); |
66
|
38
|
|
|
|
|
311
|
$site->set_current(); |
67
|
|
|
|
|
|
|
|
68
|
38
|
|
|
|
|
665
|
my $cgi=$self->cgi_object; |
69
|
|
|
|
|
|
|
|
70
|
38
|
50
|
|
|
|
424
|
if(my $charset=$site->config->get('charset')) { |
71
|
38
|
50
|
|
|
|
2028
|
if($cgi->can('set_param_charset')) { |
72
|
38
|
|
|
|
|
124
|
$cgi->set_param_charset($charset); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
else { |
75
|
0
|
|
|
|
|
0
|
eprint "CGI object we have does not support set_param_charset"; |
76
|
|
|
|
|
|
|
} |
77
|
38
|
|
|
|
|
124
|
$site->config->header_args( |
78
|
|
|
|
|
|
|
-Charset => $charset, |
79
|
|
|
|
|
|
|
); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
38
|
|
|
|
|
138
|
$site->config->embedded('web')->enable_special_access(); |
83
|
38
|
|
|
|
|
114
|
$site->config->cgi($cgi); |
84
|
38
|
|
|
|
|
114
|
$site->config->embedded('web')->disable_special_access(); |
85
|
|
|
|
|
|
|
|
86
|
38
|
|
|
|
|
96
|
$self->{'siteconfig'}=$site->config; |
87
|
38
|
|
|
|
|
234
|
$self->{'web'}=$site; |
88
|
38
|
|
|
|
|
143
|
$self->{'cgi'}=$cgi; |
89
|
|
|
|
|
|
|
|
90
|
38
|
|
|
|
|
147
|
return $self; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub cgi_object { |
94
|
38
|
|
|
38
|
0
|
180
|
XAO::Objects->new( |
95
|
|
|
|
|
|
|
objname => 'CGI', |
96
|
|
|
|
|
|
|
query => 'foo=bar&ucode=%D1%82%D0%B5%D1%81%D1%82&bytes=%01%02%03%04&test=1', |
97
|
|
|
|
|
|
|
); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub web { |
101
|
81
|
|
|
81
|
0
|
5260
|
my $self=shift; |
102
|
81
|
|
|
|
|
146
|
return $self->{'web'}; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub cgi { |
106
|
12
|
|
|
12
|
0
|
3405
|
my $self=shift; |
107
|
12
|
|
|
|
|
72
|
return $self->{'cgi'}; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
############################################################################### |
111
|
|
|
|
|
|
|
1; |
112
|
|
|
|
|
|
|
__END__ |