| 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
|
|
524452
|
use strict; |
|
|
22
|
|
|
|
|
57
|
|
|
|
22
|
|
|
|
|
627
|
|
|
15
|
22
|
|
|
22
|
|
9987
|
use IO::File; |
|
|
22
|
|
|
|
|
153591
|
|
|
|
22
|
|
|
|
|
2847
|
|
|
16
|
22
|
|
|
22
|
|
158
|
use XAO::Utils; |
|
|
22
|
|
|
|
|
47
|
|
|
|
22
|
|
|
|
|
1126
|
|
|
17
|
22
|
|
|
22
|
|
6337
|
use XAO::Base; |
|
|
22
|
|
|
|
|
19605
|
|
|
|
22
|
|
|
|
|
849
|
|
|
18
|
22
|
|
|
22
|
|
7086
|
use XAO::Objects; |
|
|
22
|
|
|
|
|
31696
|
|
|
|
22
|
|
|
|
|
684
|
|
|
19
|
22
|
|
|
22
|
|
8826
|
use XAO::Web; |
|
|
22
|
|
|
|
|
59
|
|
|
|
22
|
|
|
|
|
721
|
|
|
20
|
22
|
|
|
22
|
|
141
|
use XAO::Projects qw(:all); |
|
|
22
|
|
|
|
|
48
|
|
|
|
22
|
|
|
|
|
2713
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
22
|
|
|
22
|
|
386
|
use base qw(XAO::testcases::base); |
|
|
22
|
|
|
|
|
67
|
|
|
|
22
|
|
|
|
|
10530
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub new ($) { |
|
25
|
22
|
|
|
22
|
0
|
7877
|
my $proto=shift; |
|
26
|
22
|
|
|
|
|
168
|
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
|
|
|
|
|
245
|
my %d; |
|
34
|
22
|
|
|
|
|
39
|
if(1) { |
|
35
|
22
|
50
|
|
|
|
946
|
open(F,'.config') || |
|
36
|
|
|
|
|
|
|
die "No .config found, run 'perl Makefile.PL'"; |
|
37
|
22
|
|
|
|
|
149
|
local($/); |
|
38
|
22
|
|
|
|
|
630
|
my $t=; |
|
39
|
22
|
|
|
|
|
239
|
close(F); |
|
40
|
22
|
|
|
|
|
1572
|
eval $t; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
22
|
50
|
|
|
|
235
|
$self->{'skip_db_tests'}=$d{'test_dsn'} eq 'none' ? 1 : 0; |
|
44
|
|
|
|
|
|
|
|
|
45
|
22
|
|
|
|
|
126
|
return $self; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub list_tests ($) { |
|
49
|
44
|
|
|
44
|
0
|
6353
|
my $self=shift; |
|
50
|
|
|
|
|
|
|
|
|
51
|
44
|
|
|
|
|
240
|
my @tests=$self->SUPER::list_tests(@_); |
|
52
|
|
|
|
|
|
|
|
|
53
|
44
|
50
|
|
|
|
16627
|
if($self->{'skip_db_tests'}) { |
|
54
|
44
|
|
|
|
|
90
|
@tests=grep { ! /_db_/ } @tests; |
|
|
96
|
|
|
|
|
256
|
|
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
44
|
50
|
|
|
|
231
|
return wantarray ? @tests : \@tests; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub set_up { |
|
61
|
38
|
|
|
38
|
0
|
9196
|
my $self=shift; |
|
62
|
|
|
|
|
|
|
|
|
63
|
38
|
|
|
|
|
211
|
$self->SUPER::set_up(); |
|
64
|
|
|
|
|
|
|
|
|
65
|
38
|
|
|
|
|
127201
|
my $site=XAO::Web->new(sitename => 'test'); |
|
66
|
38
|
|
|
|
|
259
|
$site->set_current(); |
|
67
|
|
|
|
|
|
|
|
|
68
|
38
|
|
|
|
|
807
|
my $cgi=$self->cgi_object; |
|
69
|
|
|
|
|
|
|
|
|
70
|
38
|
50
|
|
|
|
451
|
if(my $charset=$site->config->get('charset')) { |
|
71
|
38
|
50
|
|
|
|
2365
|
if($cgi->can('set_param_charset')) { |
|
72
|
38
|
|
|
|
|
132
|
$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
|
|
|
|
|
150
|
$site->config->header_args( |
|
78
|
|
|
|
|
|
|
-Charset => $charset, |
|
79
|
|
|
|
|
|
|
); |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
38
|
|
|
|
|
161
|
$site->config->embedded('web')->enable_special_access(); |
|
83
|
38
|
|
|
|
|
143
|
$site->config->cgi($cgi); |
|
84
|
38
|
|
|
|
|
161
|
$site->config->embedded('web')->disable_special_access(); |
|
85
|
|
|
|
|
|
|
|
|
86
|
38
|
|
|
|
|
117
|
$self->{'siteconfig'}=$site->config; |
|
87
|
38
|
|
|
|
|
301
|
$self->{'web'}=$site; |
|
88
|
38
|
|
|
|
|
183
|
$self->{'cgi'}=$cgi; |
|
89
|
|
|
|
|
|
|
|
|
90
|
38
|
|
|
|
|
198
|
return $self; |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub cgi_object { |
|
94
|
38
|
|
|
38
|
0
|
186
|
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
|
6284
|
my $self=shift; |
|
102
|
81
|
|
|
|
|
198
|
return $self->{'web'}; |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub cgi { |
|
106
|
12
|
|
|
12
|
0
|
4208
|
my $self=shift; |
|
107
|
12
|
|
|
|
|
71
|
return $self->{'cgi'}; |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
############################################################################### |
|
111
|
|
|
|
|
|
|
1; |
|
112
|
|
|
|
|
|
|
__END__ |