line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::PObject::Test::Types; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# $Id: Types.pm,v 1.6 2004/05/19 06:07:53 sherzodr Exp $ |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
640
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
6
|
|
|
|
|
|
|
#use diagnostics; |
7
|
1
|
|
|
1
|
|
906
|
use Test::More; |
|
1
|
|
|
|
|
20702
|
|
|
1
|
|
|
|
|
13
|
|
8
|
1
|
|
|
1
|
|
340
|
use vars ('$VERSION', '@ISA'); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
97
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
BEGIN { |
11
|
1
|
|
|
1
|
|
4
|
plan(tests => 46); |
12
|
1
|
|
|
1
|
|
545
|
use_ok("Class::PObject"); |
|
1
|
|
|
|
|
10061
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
13
|
1
|
|
|
1
|
|
737
|
use_ok("Class::PObject::Test"); |
|
1
|
|
|
|
|
637
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
20
|
|
14
|
1
|
|
|
1
|
|
456
|
use_ok("Class::PObject::Type"); |
|
1
|
|
|
|
|
571
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
17
|
|
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
@ISA = ('Class::PObject::Test'); |
18
|
|
|
|
|
|
|
$VERSION = '1.02'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub run { |
22
|
1
|
|
|
1
|
0
|
9
|
my $self = shift; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
pobject User => { |
25
|
|
|
|
|
|
|
columns => ['id', 'name', 'login', 'psswd', 'activation_key'], |
26
|
|
|
|
|
|
|
driver => $self->{driver}, |
27
|
|
|
|
|
|
|
datasource => $self->{datasource}, |
28
|
1
|
|
|
|
|
24
|
serializer => 'storable', |
29
|
|
|
|
|
|
|
tmap => { |
30
|
|
|
|
|
|
|
login => 'CHAR(18)', |
31
|
|
|
|
|
|
|
psswd => 'ENCRYPT', |
32
|
|
|
|
|
|
|
name => 'VARCHAR(40)', |
33
|
|
|
|
|
|
|
id => 'INTEGER', |
34
|
|
|
|
|
|
|
activation_key => 'MD5' |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
}; |
37
|
1
|
|
|
|
|
8
|
ok(1); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
################ |
40
|
|
|
|
|
|
|
# |
41
|
|
|
|
|
|
|
# Creating a new user |
42
|
|
|
|
|
|
|
# |
43
|
1
|
|
|
|
|
761
|
my $u = new User(); |
44
|
1
|
|
|
|
|
6
|
ok(ref $u); |
45
|
1
|
|
|
|
|
511
|
$u->name("Sherzod Ruzmetov"); |
46
|
1
|
|
|
|
|
5
|
$u->login("sherzodr"); |
47
|
1
|
|
|
|
|
4
|
$u->psswd("marley01"); |
48
|
1
|
|
|
|
|
6
|
$u->activation_key("geek"); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
#print $u->dump; |
51
|
|
|
|
|
|
|
#exit(0); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
################ |
54
|
|
|
|
|
|
|
# |
55
|
|
|
|
|
|
|
# checking integrity of data before saving to disk |
56
|
|
|
|
|
|
|
# |
57
|
1
|
|
|
|
|
4
|
ok($u->name eq "Sherzod Ruzmetov"); |
58
|
1
|
|
|
|
|
551
|
ok($u->login eq "sherzodr"); |
59
|
1
|
|
|
|
|
440
|
ok($u->psswd eq "marley01", ''.$u->psswd); |
60
|
1
|
|
|
|
|
395
|
ok($u->activation_key eq "geek", ''.$u->activation_key); |
61
|
|
|
|
|
|
|
|
62
|
1
|
|
|
|
|
389
|
ok(ref($u->name) eq 'VARCHAR'); |
63
|
1
|
|
|
|
|
387
|
ok(ref($u->login) eq 'CHAR'); |
64
|
|
|
|
|
|
|
TODO: { |
65
|
|
|
|
|
|
|
# If a value of a column is undef, even ref() doesn't work. |
66
|
|
|
|
|
|
|
# Should it? |
67
|
1
|
|
|
|
|
384
|
local $TODO = "Not sure if it is a bug or a feature"; |
|
1
|
|
|
|
|
3
|
|
68
|
1
|
|
|
|
|
7
|
ok(ref($u->id) eq 'INTEGER'); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
1
|
|
|
|
|
806
|
ok(ref($u->psswd) eq 'ENCRYPT'); |
72
|
1
|
|
|
|
|
385
|
ok(ref($u->activation_key) eq 'MD5'); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
#print $u->dump; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# let's check if we can assign objects directly |
77
|
1
|
|
|
|
|
379
|
my $name = VARCHAR->new(id=>"Sherzod Ruzmetov (e)", args=>40); |
78
|
1
|
|
|
|
|
5
|
ok($name, $name); |
79
|
1
|
|
|
|
|
471
|
$u->name( $name ); |
80
|
1
|
|
|
|
|
14
|
ok($u->name eq "Sherzod Ruzmetov (e)"); |
81
|
1
|
|
|
|
|
397
|
ok(ref($u->name) eq "VARCHAR", ref($u->name)); |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
#print $u->dump; |
84
|
|
|
|
|
|
|
|
85
|
1
|
|
|
|
|
379
|
$u->name( "Sherzod Ruzmetov" ); |
86
|
1
|
|
|
|
|
5
|
ok($u->name eq "Sherzod Ruzmetov", ''.$u->name); |
87
|
1
|
|
|
|
|
433
|
ok(ref($u->name) eq "VARCHAR", ref($u->name)); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
#print $u->dump; |
90
|
|
|
|
|
|
|
|
91
|
1
|
|
|
|
|
401
|
ok(my $id = $u->save, $u->errstr); |
92
|
|
|
|
|
|
|
|
93
|
1
|
|
|
|
|
993
|
$u = undef; |
94
|
|
|
|
|
|
|
|
95
|
1
|
|
|
|
|
79
|
$u = User->load($id); |
96
|
1
|
|
|
|
|
4
|
ok($u); |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
#print $u->dump; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
################ |
101
|
|
|
|
|
|
|
# |
102
|
|
|
|
|
|
|
# checking integrity of data after loaded from disk |
103
|
|
|
|
|
|
|
# |
104
|
1
|
|
|
|
|
404
|
ok($u->name eq "Sherzod Ruzmetov"); |
105
|
1
|
|
|
|
|
369
|
ok($u->login eq "sherzodr"); |
106
|
1
|
|
|
|
|
391
|
ok($u->psswd eq "marley01", ''.$u->psswd); |
107
|
|
|
|
|
|
|
|
108
|
1
|
|
|
|
|
390
|
ok(ref($u->name) eq 'VARCHAR'); |
109
|
1
|
|
|
|
|
358
|
ok(ref($u->login) eq 'CHAR'); |
110
|
1
|
|
|
|
|
554
|
ok(ref($u->id) eq 'INTEGER'); |
111
|
1
|
|
|
|
|
530
|
ok(ref($u->psswd) eq 'ENCRYPT'); |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
################ |
114
|
|
|
|
|
|
|
# |
115
|
|
|
|
|
|
|
# Updating the values again |
116
|
|
|
|
|
|
|
# |
117
|
1
|
|
|
|
|
371
|
$u->name("Sherzod Ruzmetov (e)"); |
118
|
1
|
|
|
|
|
6
|
$u->psswd("marley02)"); |
119
|
|
|
|
|
|
|
|
120
|
1
|
|
|
|
|
5
|
ok($u->psswd eq "marley02", ''.$u->psswd); |
121
|
1
|
|
|
|
|
403
|
ok($u->name eq "Sherzod Ruzmetov (e)"); |
122
|
1
|
|
|
|
|
387
|
ok($u->activation_key eq "geek"); |
123
|
1
|
|
|
|
|
838
|
ok(ref($u->psswd) eq 'ENCRYPT'); |
124
|
1
|
|
|
|
|
504
|
ok(ref($u->activation_key), 'MD5'); |
125
|
1
|
|
|
|
|
416
|
ok($u->save == $id, $u->errstr); |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
################ |
129
|
|
|
|
|
|
|
# |
130
|
|
|
|
|
|
|
# Checking col. member functions (inside Type.pm) |
131
|
|
|
|
|
|
|
# |
132
|
1
|
|
|
|
|
417
|
my $substr = $u->name()->substr(0, 6); |
133
|
1
|
|
|
|
|
5
|
ok($substr eq "Sherzo", $substr); |
134
|
|
|
|
|
|
|
|
135
|
1
|
|
|
|
|
384
|
my $lcfirst = $u->name()->lcfirst(); |
136
|
1
|
|
|
|
|
5
|
ok($lcfirst eq 'sherzod Ruzmetov (e)'); |
137
|
|
|
|
|
|
|
|
138
|
1
|
|
|
|
|
392
|
my $ucfirst = $u->name()->ucfirst(); |
139
|
1
|
|
|
|
|
4
|
ok($ucfirst eq 'Sherzod Ruzmetov (e)'); |
140
|
|
|
|
|
|
|
|
141
|
1
|
|
|
|
|
368
|
my $lc = $u->name()->lc(); |
142
|
1
|
|
|
|
|
4
|
ok($lc eq 'sherzod ruzmetov (e)'); |
143
|
|
|
|
|
|
|
|
144
|
1
|
|
|
|
|
370
|
my $uc = $u->name()->uc(); |
145
|
1
|
|
|
|
|
4
|
ok($uc eq 'SHERZOD RUZMETOV (E)'); |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
################ |
149
|
|
|
|
|
|
|
# |
150
|
|
|
|
|
|
|
# Checking load(\%terms, undef) syntax |
151
|
|
|
|
|
|
|
# |
152
|
|
|
|
|
|
|
|
153
|
1
|
|
|
|
|
371
|
$u = User->load({login=>'sherzodr'}); |
154
|
1
|
|
|
|
|
17
|
ok($u); |
155
|
1
|
|
|
|
|
668
|
ok($u->psswd eq "marley02"); |
156
|
1
|
|
|
|
|
382
|
ok($u->activation_key eq "geek"); |
157
|
|
|
|
|
|
|
|
158
|
1
|
|
|
|
|
387
|
ok(User->count == 1); |
159
|
1
|
|
|
|
|
436
|
ok(User->remove_all()); |
160
|
1
|
|
|
|
|
477
|
ok(User->count == 0); |
161
|
|
|
|
|
|
|
|
162
|
1
|
|
|
|
|
399
|
ok(User->drop_datasource); |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
package VARCHAR; |
171
|
1
|
|
|
1
|
|
1378
|
use vars ('@ISA'); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
46
|
|
172
|
1
|
|
|
1
|
|
533
|
use Class::PObject::Type::VARCHAR; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
173
|
|
|
|
|
|
|
@ISA = ("Class::PObject::Type::VARCHAR"); |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
1; |
177
|
|
|
|
|
|
|
__END__ |