line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package XAO::testcases::FS::base; |
2
|
13
|
|
|
13
|
|
109
|
use strict; |
|
13
|
|
|
|
|
38
|
|
|
13
|
|
|
|
|
383
|
|
3
|
13
|
|
|
13
|
|
86
|
use XAO::Utils; |
|
13
|
|
|
|
|
39
|
|
|
13
|
|
|
|
|
701
|
|
4
|
13
|
|
|
13
|
|
1116
|
use XAO::Objects; |
|
13
|
|
|
|
|
10522
|
|
|
13
|
|
|
|
|
339
|
|
5
|
13
|
|
|
13
|
|
5938
|
use XAO::testcases::base; |
|
13
|
|
|
|
|
122012
|
|
|
13
|
|
|
|
|
459
|
|
6
|
|
|
|
|
|
|
|
7
|
13
|
|
|
13
|
|
217
|
use base qw(XAO::testcases::base); |
|
13
|
|
|
|
|
47
|
|
|
13
|
|
|
|
|
8670
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new ($) { |
10
|
13
|
|
|
13
|
0
|
2566
|
my $proto=shift; |
11
|
13
|
|
|
|
|
97
|
my $self=$proto->SUPER::new(@_); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Reading configuration |
14
|
|
|
|
|
|
|
# |
15
|
13
|
|
|
|
|
203
|
my %d; |
16
|
13
|
50
|
|
|
|
533
|
if(open(F,'.config')) { |
17
|
13
|
|
|
|
|
79
|
local($/); |
18
|
13
|
|
|
|
|
284
|
my $t=; |
19
|
13
|
|
|
|
|
136
|
close(F); |
20
|
13
|
|
|
|
|
892
|
eval $t; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
13
|
50
|
33
|
|
|
137
|
(!$@ && $d{'test_dsn'}) || |
24
|
|
|
|
|
|
|
die "Invalid config, re-run 'perl Makefile.PL'\n"; |
25
|
|
|
|
|
|
|
|
26
|
13
|
|
|
|
|
91
|
$self->{'dbconfig'}=\%d; |
27
|
|
|
|
|
|
|
|
28
|
13
|
50
|
|
|
|
49
|
if($d{'test_dsn'} eq 'none') { |
29
|
13
|
|
|
|
|
62
|
dprint "No DSN configured, skipping all tests"; |
30
|
13
|
|
|
|
|
50
|
$self->{'skip_db_tests'}=1; |
31
|
13
|
|
|
|
|
147
|
return; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
return $self; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub list_tests ($) { |
38
|
0
|
|
|
0
|
0
|
|
my $self=shift; |
39
|
|
|
|
|
|
|
|
40
|
0
|
0
|
|
|
|
|
if($self->{'skip_db_tests'}) { |
41
|
0
|
0
|
|
|
|
|
return wantarray ? () : []; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
else { |
44
|
0
|
|
|
|
|
|
return $self->SUPER::list_tests(@_); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub reconnect ($) { |
49
|
0
|
|
|
0
|
0
|
|
my $self=shift; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
my $dbconfig=$self->{'dbconfig'}; |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
$self->assert($dbconfig->{'test_dsn'}, |
54
|
|
|
|
|
|
|
"No test configuration available (no .config)"); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
$self->{'odb'}=XAO::Objects->new( |
57
|
|
|
|
|
|
|
objname => 'FS::Glue', |
58
|
|
|
|
|
|
|
dsn => $dbconfig->{'test_dsn'}, |
59
|
|
|
|
|
|
|
user => $dbconfig->{'test_user'}, |
60
|
0
|
|
|
|
|
|
password => $dbconfig->{'test_password'}, |
61
|
|
|
|
|
|
|
check_consistency => 1, |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
return $self->get_odb; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub set_up ($) { |
68
|
0
|
|
|
0
|
0
|
|
my $self=shift; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
### $self->SUPER::set_up(@_); |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
my $dbconfig=$self->{'dbconfig'}; |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
$self->assert($dbconfig->{'test_dsn'}, |
75
|
|
|
|
|
|
|
"No test configuration available (no .config)"); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
$self->{'odb'}=XAO::Objects->new( |
78
|
|
|
|
|
|
|
objname => 'FS::Glue', |
79
|
|
|
|
|
|
|
dsn => $dbconfig->{'test_dsn'}, |
80
|
|
|
|
|
|
|
user => $dbconfig->{'test_user'}, |
81
|
0
|
|
|
|
|
|
password => $dbconfig->{'test_password'}, |
82
|
|
|
|
|
|
|
empty_database => 'confirm', |
83
|
|
|
|
|
|
|
check_consistency => 1, |
84
|
|
|
|
|
|
|
); |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
$self->assert($self->{odb}, "Can't connect to the FS database"); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
$self->{'odb_args'}={ |
89
|
|
|
|
|
|
|
dsn => $dbconfig->{'test_dsn'}, |
90
|
|
|
|
|
|
|
user => $dbconfig->{'test_user'}, |
91
|
0
|
|
|
|
|
|
password => $dbconfig->{'test_password'}, |
92
|
|
|
|
|
|
|
}; |
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
my $global=$self->{'odb'}->fetch('/'); |
95
|
0
|
|
|
|
|
|
$self->assert($global, "Can't fetch Global from FS database"); |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
$global->build_structure( |
98
|
|
|
|
|
|
|
Customers => { |
99
|
|
|
|
|
|
|
type => 'list', |
100
|
|
|
|
|
|
|
class => 'Data::Customer', |
101
|
|
|
|
|
|
|
key => 'customer_id', |
102
|
|
|
|
|
|
|
structure => { |
103
|
|
|
|
|
|
|
name => { |
104
|
|
|
|
|
|
|
type => 'text', |
105
|
|
|
|
|
|
|
maxlength => 40, |
106
|
|
|
|
|
|
|
}, |
107
|
|
|
|
|
|
|
}, |
108
|
|
|
|
|
|
|
}, |
109
|
|
|
|
|
|
|
); |
110
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
my $clist=$self->{odb}->fetch('/Customers'); |
112
|
0
|
|
|
|
|
|
$self->assert($clist, "Can't fetch /Customers from FS database"); |
113
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
|
my $customer=$clist->get_new(); |
115
|
0
|
|
|
|
|
|
$self->assert(ref($customer), "Can't create new Data::Customer"); |
116
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
$customer->put(name => 'Test Customer #1'); |
118
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
$clist->put(c1 => $customer); |
120
|
|
|
|
|
|
|
|
121
|
0
|
|
|
|
|
|
$customer->put(name => 'Test Customer #2'); |
122
|
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
$clist->put(c2 => $customer); |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub tear_down { |
127
|
0
|
|
|
0
|
0
|
|
my $self=shift; |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
### $self->SUPER::tear_down(@_); |
130
|
|
|
|
|
|
|
|
131
|
0
|
|
|
|
|
|
$self->{odb}=undef; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub get_odb { |
135
|
0
|
|
|
0
|
0
|
|
my $self=shift; |
136
|
0
|
|
|
|
|
|
my $odb=$self->{'odb'}; |
137
|
0
|
|
0
|
|
|
|
$self->assert(defined($odb) && ref($odb), 'No object database handler'); |
138
|
0
|
|
|
|
|
|
$odb; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
13
|
|
|
13
|
|
125
|
use vars qw(*SE); |
|
13
|
|
|
|
|
43
|
|
|
13
|
|
|
|
|
1614
|
|
142
|
|
|
|
|
|
|
sub stderr_stop { |
143
|
0
|
|
|
0
|
0
|
|
open(SE,">&STDERR"); |
144
|
0
|
|
|
|
|
|
open(STDERR,">/dev/null"); |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub stderr_restore { |
148
|
0
|
|
|
0
|
0
|
|
open(STDERR,">&SE"); |
149
|
0
|
|
|
|
|
|
close(SE); |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
1; |