line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::PObject::Test::Types; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Types.pm,v 1.7 2005/01/26 19:21:58 sherzodr Exp |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
532
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
6
|
|
|
|
|
|
|
#use diagnostics; |
7
|
1
|
|
|
1
|
|
1011
|
use Test::More; |
|
1
|
|
|
|
|
18173
|
|
|
1
|
|
|
|
|
9
|
|
8
|
1
|
|
|
1
|
|
289
|
use vars ('$VERSION', '@ISA'); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
86
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
BEGIN { |
11
|
1
|
|
|
1
|
|
3
|
plan(tests => 46); |
12
|
1
|
|
|
1
|
|
571
|
use_ok("Class::PObject"); |
|
1
|
|
|
|
|
724
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
7
|
|
13
|
1
|
|
|
1
|
|
831
|
use_ok("Class::PObject::Test"); |
|
1
|
|
|
|
|
739
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
14
|
|
14
|
1
|
|
|
1
|
|
376
|
use_ok("Class::PObject::Type"); |
|
1
|
|
|
|
|
515
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
14
|
|
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
@ISA = ('Class::PObject::Test'); |
18
|
|
|
|
|
|
|
$VERSION = '1.03'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub run { |
22
|
1
|
|
|
1
|
0
|
7
|
my $self = shift; |
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
|
|
20
|
pobject User => { |
25
|
|
|
|
|
|
|
columns => ['id', 'name', 'login', 'psswd', 'activation_key'], |
26
|
|
|
|
|
|
|
driver => $self->{driver}, |
27
|
|
|
|
|
|
|
# datasource => $self->{datasource}, |
28
|
|
|
|
|
|
|
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
|
|
|
|
|
9
|
ok(1); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
{ |
41
|
1
|
|
|
|
|
715
|
package User; |
42
|
|
|
|
|
|
|
*pobject_init = sub { |
43
|
5
|
|
|
5
|
|
28
|
$_[0]->set_datasource( $self->{datasource} ); |
44
|
|
|
|
|
|
|
} |
45
|
1
|
|
|
|
|
8
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
################ |
49
|
|
|
|
|
|
|
# |
50
|
|
|
|
|
|
|
# Creating a new user |
51
|
|
|
|
|
|
|
# |
52
|
1
|
|
|
|
|
10
|
my $u = new User(); |
53
|
1
|
|
|
|
|
7
|
ok(ref $u); |
54
|
1
|
|
|
|
|
401
|
$u->name("Sherzod Ruzmetov"); |
55
|
1
|
|
|
|
|
5
|
$u->login("sherzodr"); |
56
|
1
|
|
|
|
|
5
|
$u->psswd("marley01"); |
57
|
1
|
|
|
|
|
5
|
$u->activation_key("geek"); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
#print $u->dump; |
60
|
|
|
|
|
|
|
#exit(0); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
################ |
63
|
|
|
|
|
|
|
# |
64
|
|
|
|
|
|
|
# checking integrity of data before saving to disk |
65
|
|
|
|
|
|
|
# |
66
|
1
|
|
|
|
|
6
|
ok($u->name eq "Sherzod Ruzmetov"); |
67
|
1
|
|
|
|
|
502
|
ok($u->login eq "sherzodr"); |
68
|
1
|
|
|
|
|
436
|
ok($u->psswd eq "marley01", ''.$u->psswd); |
69
|
1
|
|
|
|
|
407
|
ok($u->activation_key eq "geek", ''.$u->activation_key); |
70
|
|
|
|
|
|
|
|
71
|
1
|
|
|
|
|
449
|
ok(ref($u->name) eq 'VARCHAR'); |
72
|
1
|
|
|
|
|
396
|
ok(ref($u->login) eq 'CHAR'); |
73
|
1
|
|
|
|
|
3
|
TODO: { |
74
|
|
|
|
|
|
|
# If a value of a column is undef, even ref() doesn't work. |
75
|
|
|
|
|
|
|
# Should it? |
76
|
1
|
|
|
|
|
413
|
local $TODO = "Not sure if it is a bug or a feature"; |
77
|
1
|
|
|
|
|
5
|
ok(ref($u->id) eq 'INTEGER'); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
1
|
|
|
|
|
766
|
ok(ref($u->psswd) eq 'ENCRYPT'); |
81
|
1
|
|
|
|
|
428
|
ok(ref($u->activation_key) eq 'MD5'); |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
#print $u->dump; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# let's check if we can assign objects directly |
86
|
1
|
|
|
|
|
430
|
my $name = VARCHAR->new(id=>"Sherzod Ruzmetov (e)", args=>40); |
87
|
1
|
|
|
|
|
5
|
ok($name, $name); |
88
|
1
|
|
|
|
|
461
|
$u->name( $name ); |
89
|
1
|
|
|
|
|
18
|
ok($u->name eq "Sherzod Ruzmetov (e)"); |
90
|
1
|
|
|
|
|
406
|
ok(ref($u->name) eq "VARCHAR", ref($u->name)); |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
#print $u->dump; |
93
|
|
|
|
|
|
|
|
94
|
1
|
|
|
|
|
503
|
$u->name( "Sherzod Ruzmetov" ); |
95
|
1
|
|
|
|
|
4
|
ok($u->name eq "Sherzod Ruzmetov", ''.$u->name); |
96
|
1
|
|
|
|
|
402
|
ok(ref($u->name) eq "VARCHAR", ref($u->name)); |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
#print $u->dump; |
99
|
|
|
|
|
|
|
|
100
|
1
|
|
|
|
|
357
|
ok(my $id = $u->save, $u->errstr); |
101
|
|
|
|
|
|
|
|
102
|
1
|
|
|
|
|
780
|
$u = undef; |
103
|
|
|
|
|
|
|
|
104
|
1
|
|
|
|
|
70
|
$u = User->load($id); |
105
|
1
|
|
|
|
|
4
|
ok($u); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
#print $u->dump; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
################ |
110
|
|
|
|
|
|
|
# |
111
|
|
|
|
|
|
|
# checking integrity of data after loaded from disk |
112
|
|
|
|
|
|
|
# |
113
|
1
|
|
|
|
|
370
|
ok($u->name eq "Sherzod Ruzmetov"); |
114
|
1
|
|
|
|
|
406
|
ok($u->login eq "sherzodr"); |
115
|
1
|
|
|
|
|
326
|
ok($u->psswd eq "marley01", ''.$u->psswd); |
116
|
|
|
|
|
|
|
|
117
|
1
|
|
|
|
|
474
|
ok(ref($u->name) eq 'VARCHAR'); |
118
|
1
|
|
|
|
|
383
|
ok(ref($u->login) eq 'CHAR'); |
119
|
1
|
|
|
|
|
423
|
ok(ref($u->id) eq 'INTEGER'); |
120
|
1
|
|
|
|
|
364
|
ok(ref($u->psswd) eq 'ENCRYPT'); |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
################ |
123
|
|
|
|
|
|
|
# |
124
|
|
|
|
|
|
|
# Updating the values again |
125
|
|
|
|
|
|
|
# |
126
|
1
|
|
|
|
|
416
|
$u->name("Sherzod Ruzmetov (e)"); |
127
|
1
|
|
|
|
|
6
|
$u->psswd("marley02)"); |
128
|
|
|
|
|
|
|
|
129
|
1
|
|
|
|
|
5
|
ok($u->psswd eq "marley02", ''.$u->psswd); |
130
|
1
|
|
|
|
|
403
|
ok($u->name eq "Sherzod Ruzmetov (e)"); |
131
|
1
|
|
|
|
|
374
|
ok($u->activation_key eq "geek"); |
132
|
1
|
|
|
|
|
323
|
ok(ref($u->psswd) eq 'ENCRYPT'); |
133
|
1
|
|
|
|
|
378
|
ok(ref($u->activation_key), 'MD5'); |
134
|
1
|
|
|
|
|
347
|
ok($u->save == $id, $u->errstr); |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
################ |
138
|
|
|
|
|
|
|
# |
139
|
|
|
|
|
|
|
# Checking col. member functions (inside Type.pm) |
140
|
|
|
|
|
|
|
# |
141
|
1
|
|
|
|
|
390
|
my $substr = $u->name()->substr(0, 6); |
142
|
1
|
|
|
|
|
4
|
ok($substr eq "Sherzo", $substr); |
143
|
|
|
|
|
|
|
|
144
|
1
|
|
|
|
|
403
|
my $lcfirst = $u->name()->lcfirst(); |
145
|
1
|
|
|
|
|
4
|
ok($lcfirst eq 'sherzod Ruzmetov (e)'); |
146
|
|
|
|
|
|
|
|
147
|
1
|
|
|
|
|
364
|
my $ucfirst = $u->name()->ucfirst(); |
148
|
1
|
|
|
|
|
5
|
ok($ucfirst eq 'Sherzod Ruzmetov (e)'); |
149
|
|
|
|
|
|
|
|
150
|
1
|
|
|
|
|
442
|
my $lc = $u->name()->lc(); |
151
|
1
|
|
|
|
|
5
|
ok($lc eq 'sherzod ruzmetov (e)'); |
152
|
|
|
|
|
|
|
|
153
|
1
|
|
|
|
|
374
|
my $uc = $u->name()->uc(); |
154
|
1
|
|
|
|
|
6
|
ok($uc eq 'SHERZOD RUZMETOV (E)'); |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
################ |
158
|
|
|
|
|
|
|
# |
159
|
|
|
|
|
|
|
# Checking load(\%terms, undef) syntax |
160
|
|
|
|
|
|
|
# |
161
|
|
|
|
|
|
|
|
162
|
1
|
|
|
|
|
500
|
$u = User->load({login=>'sherzodr'}); |
163
|
1
|
|
|
|
|
16
|
ok($u); |
164
|
1
|
|
|
|
|
638
|
ok($u->psswd eq "marley02"); |
165
|
1
|
|
|
|
|
370
|
ok($u->activation_key eq "geek"); |
166
|
|
|
|
|
|
|
|
167
|
1
|
|
|
|
|
10439
|
ok(User->count == 1); |
168
|
1
|
|
|
|
|
887
|
ok(User->remove_all()); |
169
|
1
|
|
|
|
|
734
|
ok(User->count == 0); |
170
|
|
|
|
|
|
|
|
171
|
1
|
|
|
|
|
920
|
ok(User->drop_datasource); |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
package VARCHAR; |
180
|
1
|
|
|
1
|
|
1245
|
use vars ('@ISA'); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
76
|
|
181
|
1
|
|
|
1
|
|
576
|
use Class::PObject::Type::VARCHAR; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
182
|
|
|
|
|
|
|
@ISA = ("Class::PObject::Type::VARCHAR"); |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
1; |
186
|
|
|
|
|
|
|
__END__ |