line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::PObject::Test::Basic; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# $Id: Basic.pm,v 1.12 2003/11/07 00:28:24 sherzodr Exp $ |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
11920
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
28
|
|
6
|
|
|
|
|
|
|
#use diagnostics; |
7
|
1
|
|
|
1
|
|
548
|
use Test::More; |
|
1
|
|
|
|
|
14222
|
|
|
1
|
|
|
|
|
8
|
|
8
|
1
|
|
|
1
|
|
729
|
use Class::PObject; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
7
|
|
9
|
1
|
|
|
1
|
|
1165
|
use Class::PObject::Test; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
10
|
1
|
|
|
1
|
|
3
|
use vars ('$VERSION', '@ISA'); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
35
|
|
11
|
1
|
|
|
1
|
|
3
|
use overload; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
@ISA = ('Class::PObject::Test'); |
14
|
|
|
|
|
|
|
$VERSION = '1.02'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
BEGIN { |
18
|
1
|
|
|
1
|
|
59
|
plan(tests => 173); |
19
|
1
|
|
|
1
|
|
130
|
use_ok("Class::PObject") |
|
1
|
|
|
|
|
108
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
3
|
|
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub run { |
24
|
1
|
|
|
1
|
0
|
6
|
my $self = shift; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
pobject 'PO::Author' => { |
27
|
|
|
|
|
|
|
columns => ['id', 'name', 'url', 'email'], |
28
|
|
|
|
|
|
|
driver => $self->{driver}, |
29
|
|
|
|
|
|
|
datasource => $self->{datasource}, |
30
|
1
|
|
|
|
|
39
|
serializer => 'storable', |
31
|
|
|
|
|
|
|
tmap => { |
32
|
|
|
|
|
|
|
name => 'VARCHAR(40)' |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
}; |
35
|
1
|
|
|
|
|
8
|
ok(1); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
pobject 'PO::Article' => { |
39
|
|
|
|
|
|
|
columns => ['id', 'title', 'author', 'content', 'rating'], |
40
|
|
|
|
|
|
|
driver => $self->{driver}, |
41
|
|
|
|
|
|
|
datasource => $self->{datasource}, |
42
|
1
|
|
|
|
|
295
|
serializer => 'storable' |
43
|
|
|
|
|
|
|
}; |
44
|
1
|
|
|
|
|
3
|
ok(1); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
#################### |
47
|
|
|
|
|
|
|
# |
48
|
|
|
|
|
|
|
# 2. Testing pobject_init() method |
49
|
|
|
|
|
|
|
# |
50
|
|
|
|
|
|
|
{ |
51
|
0
|
|
|
|
|
0
|
package PO::Author; |
52
|
1
|
|
|
1
|
|
391
|
use Test::More; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
3
|
|
53
|
|
|
|
|
|
|
sub pobject_init { |
54
|
42
|
|
|
42
|
|
113
|
ok(ref($_[0]) eq 'PO::Author') |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
package PO::Article; |
58
|
1
|
|
|
1
|
|
240
|
use Test::More; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
2
|
|
59
|
|
|
|
|
|
|
sub pobject_init { |
60
|
4
|
|
|
4
|
|
12
|
ok(ref($_[0]) eq 'PO::Article') |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
################ |
65
|
|
|
|
|
|
|
# |
66
|
|
|
|
|
|
|
# Testing for the values of @ISA |
67
|
|
|
|
|
|
|
# |
68
|
1
|
|
|
|
|
189
|
ok($PO::Author::ISA[0] eq "Class::PObject::Template"); |
|
1
|
|
|
|
|
5
|
|
69
|
1
|
|
|
|
|
150
|
ok($PO::Article::ISA[0] eq "Class::PObject::Template"); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
#################### |
73
|
|
|
|
|
|
|
# |
74
|
|
|
|
|
|
|
# 3. Creating new objects |
75
|
|
|
|
|
|
|
# |
76
|
1
|
|
|
|
|
141
|
my $author1 = new PO::Author(); |
77
|
1
|
|
|
|
|
2
|
ok(ref $author1); |
78
|
|
|
|
|
|
|
|
79
|
1
|
|
|
|
|
138
|
my $author2 = new PO::Author(); |
80
|
1
|
|
|
|
|
3
|
ok(ref $author2); |
81
|
|
|
|
|
|
|
|
82
|
1
|
|
|
|
|
173
|
my $author3 = new PO::Author(name=>"Geek", email=>'sherzodr@cpan.org'); |
83
|
1
|
|
|
|
|
4
|
ok(ref $author3); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
1
|
|
|
|
|
138
|
my $article1 = new PO::Article(); |
87
|
1
|
|
|
|
|
3
|
ok(ref $article1); |
88
|
|
|
|
|
|
|
|
89
|
1
|
|
|
|
|
137
|
my $article2 = new PO::Article(); |
90
|
1
|
|
|
|
|
4
|
ok(ref $article2); |
91
|
|
|
|
|
|
|
|
92
|
1
|
|
|
|
|
248
|
my $article3 = new PO::Article(); |
93
|
1
|
|
|
|
|
9
|
ok(ref $article3); |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
################ |
97
|
|
|
|
|
|
|
# |
98
|
|
|
|
|
|
|
# Testing if our object is a 'Class::PObject::Template' |
99
|
|
|
|
|
|
|
# |
100
|
1
|
|
33
|
|
|
271
|
ok($author1->isa('Class::PObject::Template') && $author2->isa('Class::PObject::Template') && |
101
|
|
|
|
|
|
|
$article1->isa('Class::PObject::Template')); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
################ |
104
|
|
|
|
|
|
|
# |
105
|
|
|
|
|
|
|
# Testing if overloading is applicable |
106
|
|
|
|
|
|
|
# to these particular objects |
107
|
|
|
|
|
|
|
# |
108
|
1
|
|
|
|
|
252
|
ok(overload::Overloaded($author1)); |
109
|
1
|
|
|
|
|
1735
|
ok(overload::Overloaded($author2)); |
110
|
1
|
|
|
|
|
306
|
ok(overload::Overloaded($author3)); |
111
|
1
|
|
|
|
|
306
|
ok(overload::Overloaded($article1)); |
112
|
1
|
|
|
|
|
271
|
ok(overload::Overloaded($article2)); |
113
|
1
|
|
|
|
|
269
|
ok(overload::Overloaded($article3)); |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
#################### |
116
|
|
|
|
|
|
|
# |
117
|
|
|
|
|
|
|
# 4. Test columns(), __props() and __driver() methods |
118
|
|
|
|
|
|
|
# |
119
|
1
|
|
|
|
|
290
|
ok(ref($author1) eq 'PO::Author'); |
120
|
1
|
|
|
|
|
259
|
ok(ref($author1->columns) eq 'HASH'); |
121
|
1
|
|
|
|
|
295
|
ok(ref($author1->__props) eq 'HASH'); |
122
|
1
|
|
|
|
|
273
|
ok(ref($author1->__driver) eq 'Class::PObject::Driver::' . $self->{driver}); |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
#################### |
126
|
|
|
|
|
|
|
# |
127
|
|
|
|
|
|
|
# 5. Test if accessor methods have been created successfully |
128
|
|
|
|
|
|
|
# |
129
|
1
|
|
33
|
|
|
396
|
ok($author1->can('id') && $author2->can('name') && $author3->can('email')); |
130
|
1
|
50
|
|
|
|
267
|
ok($author1->name ? 0 : 1); |
131
|
|
|
|
|
|
|
#ok(1); |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|
134
|
1
|
|
33
|
|
|
272
|
ok($article1->can('id') && $article2->can('title') && $article3->can('author')); |
135
|
|
|
|
|
|
|
#exit; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
#################### |
138
|
|
|
|
|
|
|
# |
139
|
|
|
|
|
|
|
# 6. Checking if accessor methods function as expected |
140
|
|
|
|
|
|
|
# |
141
|
1
|
|
|
|
|
252
|
$author1->name("Sherzod Ruzmetov"); |
142
|
1
|
|
|
|
|
3
|
$author1->url('http://author.handalak.com/'); |
143
|
1
|
|
|
|
|
3
|
$author1->email('sherzodr@cpan.org'); |
144
|
|
|
|
|
|
|
|
145
|
1
|
|
|
|
|
3
|
my $name = $author1->name(); |
146
|
1
|
|
|
|
|
12
|
ok($name->isa("Class::PObject::Type")); |
147
|
1
|
|
|
|
|
329
|
ok($name eq "Sherzod Ruzmetov"); |
148
|
|
|
|
|
|
|
|
149
|
1
|
|
|
|
|
251
|
ok($author1->name eq "Sherzod Ruzmetov"); |
150
|
1
|
|
|
|
|
292
|
ok($author1->email eq 'sherzodr@cpan.org'); |
151
|
|
|
|
|
|
|
|
152
|
1
|
|
|
|
|
278
|
$author1->name(undef); |
153
|
|
|
|
|
|
|
|
154
|
1
|
50
|
|
|
|
9
|
ok($author1->name ? 0 : 1); |
155
|
|
|
|
|
|
|
#ok($author1->{_is_new} == 1); |
156
|
1
|
|
|
|
|
251
|
ok(1); |
157
|
|
|
|
|
|
|
#exit; |
158
|
|
|
|
|
|
|
|
159
|
1
|
|
|
|
|
305
|
$author2->name("Hilola Nasyrova"); |
160
|
1
|
|
|
|
|
3
|
$author2->url('http://hilola.handalak.com/'); |
161
|
1
|
|
|
|
|
3
|
$author2->email('some@email.com'); |
162
|
|
|
|
|
|
|
|
163
|
1
|
|
|
|
|
3
|
ok($author2->name eq "Hilola Nasyrova"); |
164
|
1
|
|
|
|
|
256
|
ok($author2->email eq 'some@email.com'); |
165
|
1
|
|
|
|
|
249
|
ok($author2->{_is_new} == 1); |
166
|
|
|
|
|
|
|
|
167
|
1
|
|
|
|
|
246
|
$article1->title("Class::PObject rules!"); |
168
|
1
|
|
|
|
|
3
|
$article1->content("This is the article about Class::PObject and how great this library is"); |
169
|
1
|
|
|
|
|
3
|
$article1->rating(0); |
170
|
|
|
|
|
|
|
|
171
|
1
|
|
|
|
|
3
|
ok($article1->title eq "Class::PObject rules!"); |
172
|
1
|
|
|
|
|
258
|
ok($article1->rating == 0); |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
#################### |
176
|
|
|
|
|
|
|
# |
177
|
|
|
|
|
|
|
# 7. Testing save() |
178
|
|
|
|
|
|
|
# |
179
|
1
|
|
|
|
|
361
|
my $author1_id = undef; |
180
|
1
|
|
|
|
|
9
|
ok($author1_id = $author1->save); |
181
|
|
|
|
|
|
|
|
182
|
1
|
|
|
|
|
343
|
my $author2_id = undef; |
183
|
1
|
|
|
|
|
4
|
ok($author2_id = $author2->save); |
184
|
|
|
|
|
|
|
|
185
|
1
|
|
|
|
|
329
|
my $author3_id = undef; |
186
|
1
|
|
|
|
|
4
|
ok($author3_id = $author3->save); |
187
|
|
|
|
|
|
|
|
188
|
1
|
|
|
|
|
305
|
$article1->author($author1_id); |
189
|
|
|
|
|
|
|
|
190
|
1
|
|
|
|
|
2
|
my $article1_id = undef; |
191
|
1
|
|
|
|
|
6
|
print $article1->dump; |
192
|
1
|
|
|
|
|
819
|
ok($article1_id = $article1->save); |
193
|
|
|
|
|
|
|
|
194
|
1
|
|
|
|
|
334
|
ok($article1_id == $article1->id); |
195
|
1
|
|
|
|
|
290
|
ok($article1 == $article1_id); |
196
|
|
|
|
|
|
|
|
197
|
1
|
|
|
|
|
294
|
undef($author1); |
198
|
1
|
|
|
|
|
4
|
undef($author2); |
199
|
1
|
|
|
|
|
5
|
undef($article1); |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
#################### |
202
|
|
|
|
|
|
|
# |
203
|
|
|
|
|
|
|
# 8. Testing load() and integrity of the object |
204
|
|
|
|
|
|
|
# |
205
|
|
|
|
|
|
|
|
206
|
1
|
|
|
|
|
9
|
$article1 = PO::Article->load($article1_id); |
207
|
1
|
|
|
|
|
4
|
ok($article1); |
208
|
|
|
|
|
|
|
|
209
|
1
|
|
|
|
|
304
|
ok($article1->title eq "Class::PObject rules!"); |
210
|
1
|
|
|
|
|
284
|
ok(defined $article1->rating); |
211
|
1
|
|
|
|
|
257
|
ok($article1->rating == 0); |
212
|
|
|
|
|
|
|
|
213
|
1
|
|
|
|
|
309
|
$author1 = PO::Author->load($article1->author); |
214
|
1
|
|
|
|
|
4
|
ok($author1); |
215
|
|
|
|
|
|
|
|
216
|
1
|
|
|
|
|
254
|
ok($author1->{_is_new} == 0); |
217
|
1
|
|
|
|
|
306
|
ok($author1->email eq 'sherzodr@cpan.org'); |
218
|
1
|
50
|
|
|
|
262
|
ok($author1->name ? 0 : 1); |
219
|
1
|
|
|
|
|
288
|
ok($author1->url eq 'http://author.handalak.com/'); |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
#################### |
222
|
|
|
|
|
|
|
# |
223
|
|
|
|
|
|
|
# 9. Checking if object properties can be updated |
224
|
|
|
|
|
|
|
# |
225
|
1
|
|
|
|
|
290
|
$author1->url('http://sherzodr.handalak.com/'); |
226
|
1
|
|
|
|
|
4
|
$author1->name("Sherzod Ruzmetov"); |
227
|
1
|
|
|
|
|
3
|
ok($author1->save); |
228
|
|
|
|
|
|
|
|
229
|
1
|
|
|
|
|
283
|
$author1 = undef; |
230
|
1
|
|
|
|
|
7
|
$author1 = PO::Author->load($author1_id); |
231
|
1
|
|
|
|
|
4
|
ok($author1); |
232
|
|
|
|
|
|
|
|
233
|
1
|
|
|
|
|
249
|
ok($author1->name eq "Sherzod Ruzmetov"); |
234
|
1
|
|
|
|
|
303
|
ok($author1->email eq "sherzodr\@cpan.org"); |
235
|
1
|
|
|
|
|
317
|
ok($author1->url eq 'http://sherzodr.handalak.com/'); |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
#################### |
238
|
|
|
|
|
|
|
# |
239
|
|
|
|
|
|
|
# 10. load()ing pobject in array context |
240
|
|
|
|
|
|
|
# |
241
|
1
|
|
|
|
|
254
|
my @authors = PO::Author->load(); |
242
|
1
|
|
|
|
|
5
|
ok(@authors == 3); |
243
|
1
|
|
|
|
|
261
|
for ( @authors ) { |
244
|
3
|
|
|
|
|
12
|
printf("[%d] - %s <%s>\n", $_->id, $_->name, $_->email) |
245
|
|
|
|
|
|
|
} |
246
|
1
|
|
|
|
|
9
|
@authors = undef; |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
################ |
251
|
|
|
|
|
|
|
# |
252
|
|
|
|
|
|
|
# FIX: if load(0) was treated the same way as load() |
253
|
|
|
|
|
|
|
# |
254
|
1
|
|
|
|
|
5
|
my $author4 = PO::Author->load(0); |
255
|
1
|
|
|
|
|
4
|
ok(!$author4); |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
#################### |
258
|
|
|
|
|
|
|
# |
259
|
|
|
|
|
|
|
# 11. Loading object(s) in array context with terms |
260
|
|
|
|
|
|
|
# |
261
|
1
|
|
|
|
|
298
|
@authors = PO::Author->load({id=>$author1_id}); |
262
|
1
|
|
|
|
|
4
|
for ( @authors ) { |
263
|
1
|
|
|
|
|
4
|
ok($_->name eq "Sherzod Ruzmetov"); |
264
|
1
|
|
|
|
|
285
|
ok($_->email eq "sherzodr\@cpan.org") |
265
|
|
|
|
|
|
|
} |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
#################### |
269
|
|
|
|
|
|
|
# |
270
|
|
|
|
|
|
|
# 12. Checking count() |
271
|
|
|
|
|
|
|
# |
272
|
1
|
|
|
|
|
270
|
ok(PO::Author->count == 3); |
273
|
|
|
|
|
|
|
|
274
|
1
|
|
|
|
|
332
|
ok(PO::Author->count({name=>"Doesn't exist!"}) == 0); |
275
|
|
|
|
|
|
|
|
276
|
1
|
|
|
|
|
344
|
ok(PO::Author->count({email=>'sherzodr@cpan.org', name=>"Sherzod Ruzmetov"}) == 1); |
277
|
|
|
|
|
|
|
|
278
|
1
|
|
|
|
|
319
|
ok(PO::Author->count({email=>'sherzodr@cpan.org'}) == 2); |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
#################### |
282
|
|
|
|
|
|
|
# |
283
|
|
|
|
|
|
|
# 13. Checking more complex terms |
284
|
|
|
|
|
|
|
# |
285
|
1
|
|
|
|
|
286
|
@authors = PO::Author->load({email=>'sherzodr@cpan.org', name=>"Sherzod Ruzmetov"}); |
286
|
1
|
|
|
|
|
6
|
ok(@authors == 1); |
287
|
1
|
|
|
|
|
264
|
ok($authors[0]->id == $author1_id); |
288
|
1
|
|
|
|
|
258
|
ok($authors[0]->url eq 'http://sherzodr.handalak.com/', $authors[0]->url); |
289
|
|
|
|
|
|
|
|
290
|
1
|
|
|
|
|
268
|
@authors = undef; |
291
|
1
|
|
|
|
|
6
|
@authors = PO::Author->load({url=>'http://hilola.handalak.com/', name=>"Bogus"}); |
292
|
1
|
|
|
|
|
5
|
ok(@authors == 0); |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
|
295
|
1
|
|
|
|
|
283
|
@authors = PO::Author->load({url=>'http://hilola.handalak.com/'}); |
296
|
1
|
|
|
|
|
5
|
ok(@authors == 1); |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
#################### |
300
|
|
|
|
|
|
|
# |
301
|
|
|
|
|
|
|
# 14. Checking load(undef, \%args) syntax |
302
|
|
|
|
|
|
|
# |
303
|
1
|
|
|
|
|
266
|
@authors = PO::Author->load(undef, {'sort' => 'name'}); |
304
|
1
|
|
|
|
|
5
|
ok(@authors == 3); |
305
|
|
|
|
|
|
|
|
306
|
1
|
|
|
|
|
257
|
ok($authors[0]->name eq "Geek"); |
307
|
1
|
|
|
|
|
258
|
ok($authors[1]->name eq "Hilola Nasyrova"); |
308
|
1
|
|
|
|
|
253
|
ok($authors[2]->name eq "Sherzod Ruzmetov"); |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
|
314
|
1
|
|
|
|
|
252
|
@authors = (); |
315
|
1
|
|
|
|
|
8
|
@authors = PO::Author->load(undef, {'sort' => 'email'}); |
316
|
1
|
|
|
|
|
4
|
ok(@authors == 3); |
317
|
|
|
|
|
|
|
|
318
|
1
|
|
|
|
|
255
|
ok($authors[0]->email eq 'sherzodr@cpan.org'); |
319
|
1
|
|
|
|
|
275
|
ok($authors[1]->email eq 'sherzodr@cpan.org'); |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
# same as above, but with explicit 'direction' |
326
|
1
|
|
|
|
|
281
|
@authors = (); |
327
|
1
|
|
|
|
|
9
|
@authors = PO::Author->load(undef, {'sort' => 'email', direction=>'asc'}); |
328
|
1
|
|
|
|
|
5
|
ok(@authors == 3); |
329
|
|
|
|
|
|
|
|
330
|
1
|
|
|
|
|
290
|
ok($authors[0]->email eq 'sherzodr@cpan.org'); |
331
|
1
|
|
|
|
|
257
|
ok($authors[1]->email eq 'sherzodr@cpan.org'); |
332
|
1
|
|
|
|
|
253
|
ok($authors[2]->email eq 'some@email.com'); |
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
|
340
|
1
|
|
|
|
|
252
|
@authors = (); |
341
|
1
|
|
|
|
|
7
|
@authors = PO::Author->load(undef, {'sort'=>'name', direction=>'desc'}); |
342
|
1
|
|
|
|
|
5
|
ok(@authors == 3); |
343
|
|
|
|
|
|
|
|
344
|
1
|
|
|
|
|
257
|
ok($authors[0]->name eq "Sherzod Ruzmetov"); |
345
|
1
|
|
|
|
|
255
|
ok($authors[1]->name eq "Hilola Nasyrova"); |
346
|
1
|
|
|
|
|
252
|
ok($authors[2]->name eq "Geek"); |
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
|
351
|
1
|
|
|
|
|
254
|
@authors = (); |
352
|
1
|
|
|
|
|
7
|
@authors = PO::Author->load(undef, {'sort'=>'id', direction=>'desc', limit=>1}); |
353
|
1
|
|
|
|
|
5
|
ok(@authors == 1); |
354
|
|
|
|
|
|
|
|
355
|
1
|
|
|
|
|
286
|
ok($authors[0]->name eq "Geek"); |
356
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
|
359
|
|
|
|
|
|
|
# same as above, but with explicit 'offset' |
360
|
1
|
|
|
|
|
255
|
@authors = (); |
361
|
1
|
|
|
|
|
8
|
@authors = PO::Author->load(undef, {'sort'=>'id', direction=>'desc', limit=>1, offset=>0}); |
362
|
1
|
|
|
|
|
5
|
ok(@authors == 1); |
363
|
|
|
|
|
|
|
|
364
|
1
|
|
|
|
|
259
|
ok($authors[0]->name eq "Geek"); |
365
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
|
368
|
1
|
|
|
|
|
257
|
@authors = (); |
369
|
1
|
|
|
|
|
7
|
@authors = PO::Author->load(undef, {'sort'=>'id', direction=>'desc', offset=>1, limit=>1}); |
370
|
1
|
|
|
|
|
6
|
ok(@authors == 1); |
371
|
|
|
|
|
|
|
|
372
|
1
|
|
|
|
|
259
|
ok($authors[0]->name eq "Hilola Nasyrova"); |
373
|
|
|
|
|
|
|
|
374
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
|
376
|
1
|
|
|
|
|
259
|
$author1 = PO::Author->load(undef, {'sort'=>'id', direction=>'desc', limit=>1}); |
377
|
1
|
|
|
|
|
10
|
ok($author1); |
378
|
1
|
|
|
|
|
328
|
ok($author1->name eq "Geek"); |
379
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
#################### |
383
|
|
|
|
|
|
|
# |
384
|
|
|
|
|
|
|
# 15. Checking load(\%terms, \%args) syntax |
385
|
|
|
|
|
|
|
# |
386
|
1
|
|
|
|
|
275
|
@authors = (); |
387
|
1
|
|
|
|
|
7
|
@authors = PO::Author->load({name=>"Sherzod Ruzmetov"}, {'sort'=>'name'}); |
388
|
1
|
|
|
|
|
5
|
ok(@authors == 1); |
389
|
1
|
|
|
|
|
306
|
ok($authors[0]->email eq 'sherzodr@cpan.org'); |
390
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
|
395
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
|
397
|
1
|
|
|
|
|
294
|
@authors = (); |
398
|
1
|
|
|
|
|
7
|
@authors = PO::Author->load({email=>'sherzodr@cpan.org'}, {'sort'=>'name'}); |
399
|
1
|
|
|
|
|
4
|
ok(@authors == 2); |
400
|
|
|
|
|
|
|
|
401
|
1
|
|
|
|
|
259
|
ok($authors[0]->name eq "Geek"); |
402
|
1
|
|
|
|
|
283
|
ok($authors[1]->name eq "Sherzod Ruzmetov"); |
403
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
|
407
|
1
|
|
|
|
|
279
|
@authors = (); |
408
|
1
|
|
|
|
|
8
|
@authors = PO::Author->load({email=>'sherzodr@cpan.org'}, {'sort'=>'name', direction=>'desc'}); |
409
|
1
|
|
|
|
|
6
|
ok(@authors == 2); |
410
|
|
|
|
|
|
|
|
411
|
1
|
|
|
|
|
256
|
ok($authors[0]->name eq "Sherzod Ruzmetov"); |
412
|
1
|
|
|
|
|
274
|
ok($authors[1]->name eq "Geek"); |
413
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
|
416
|
|
|
|
|
|
|
|
417
|
1
|
|
|
|
|
298
|
@authors = PO::Author->load({email=>'sherzodr@cpan.org'}, {'sort'=>'name', direction=>'asc', limit=>1}); |
418
|
1
|
|
|
|
|
7
|
ok(@authors == 1); |
419
|
|
|
|
|
|
|
|
420
|
1
|
|
|
|
|
299
|
ok($authors[0]->name eq "Geek"); |
421
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
|
423
|
|
|
|
|
|
|
|
424
|
1
|
|
|
|
|
298
|
$author3 = undef; |
425
|
1
|
|
|
|
|
11
|
$author3 = PO::Author->load({email=>'sherzodr@cpan.org'}, {'sort'=>'name', direction=>'asc', limit=>1}); |
426
|
1
|
|
|
|
|
5
|
ok($author3); |
427
|
|
|
|
|
|
|
|
428
|
1
|
|
|
|
|
294
|
ok($author3->name eq "Geek"); |
429
|
|
|
|
|
|
|
|
430
|
|
|
|
|
|
|
|
431
|
1
|
|
|
|
|
265
|
@authors = PO::Author->load({email=>'sherzodr@cpan.org'}, {'sort'=>'name', limit=>1, offset=>1}); |
432
|
1
|
|
|
|
|
5
|
ok(@authors == 1); |
433
|
|
|
|
|
|
|
|
434
|
1
|
|
|
|
|
260
|
ok($authors[0]->name eq "Sherzod Ruzmetov"); |
435
|
|
|
|
|
|
|
|
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
################### |
438
|
|
|
|
|
|
|
# |
439
|
|
|
|
|
|
|
# Checking the iterator |
440
|
|
|
|
|
|
|
# |
441
|
1
|
|
|
|
|
315
|
my $iterator = PO::Author->fetch(undef, {'sort'=>'name'}); |
442
|
|
|
|
|
|
|
#die $iterator->dump; |
443
|
1
|
|
|
|
|
3
|
ok( $iterator->size == 3); |
444
|
|
|
|
|
|
|
#die $iterator->size; |
445
|
1
|
|
|
|
|
314
|
ok(ref $iterator eq "Class::PObject::Iterator"); |
446
|
1
|
|
|
|
|
298
|
$author1 = $iterator->next(); |
447
|
1
|
|
|
|
|
10
|
ok(ref $author1 eq "PO::Author"); |
448
|
1
|
|
|
|
|
258
|
ok( $author1->name eq "Geek"); |
449
|
|
|
|
|
|
|
|
450
|
1
|
|
|
|
|
254
|
$author2 = $iterator->next(); |
451
|
1
|
|
|
|
|
4
|
ok( ref $author2 eq "PO::Author"); |
452
|
1
|
|
|
|
|
280
|
ok( $author2->name eq "Hilola Nasyrova"); |
453
|
|
|
|
|
|
|
|
454
|
1
|
|
|
|
|
269
|
ok( $iterator->size == 1); |
455
|
|
|
|
|
|
|
|
456
|
|
|
|
|
|
|
# trying to iterate through the list. We should |
457
|
|
|
|
|
|
|
# have only one object left, since we already called next() two times: |
458
|
1
|
|
|
|
|
254
|
while ( my $author = $iterator->next ) { |
459
|
1
|
|
|
|
|
3
|
ok( $author->name eq "Sherzod Ruzmetov" ); |
460
|
|
|
|
|
|
|
} |
461
|
|
|
|
|
|
|
|
462
|
|
|
|
|
|
|
# now we need to reset the pointers: |
463
|
1
|
|
|
|
|
4
|
$iterator->reset(); |
464
|
|
|
|
|
|
|
|
465
|
1
|
|
|
|
|
2
|
while ( my $author = $iterator->next ) { |
466
|
3
|
|
|
|
|
10
|
ok( ref $author eq "PO::Author"); |
467
|
|
|
|
|
|
|
} |
468
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
|
470
|
|
|
|
|
|
|
#################### |
471
|
|
|
|
|
|
|
# |
472
|
|
|
|
|
|
|
# Cleaning up all the objects so that for the next 'make test' |
473
|
|
|
|
|
|
|
# can start with brand new scratch board |
474
|
|
|
|
|
|
|
# |
475
|
|
|
|
|
|
|
|
476
|
1
|
|
|
|
|
3
|
$iterator->reset(); |
477
|
1
|
|
|
|
|
2
|
my $author = $iterator->next; |
478
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
# removing author named 'Geek': |
480
|
1
|
|
|
|
|
12
|
ok($author->remove, $author->errstr); |
481
|
|
|
|
|
|
|
|
482
|
1
|
|
|
|
|
290
|
ok(PO::Author->count == 2, "count: " . PO::Author->count); |
483
|
|
|
|
|
|
|
|
484
|
|
|
|
|
|
|
# again trying to remove the author 'Geek'. This should have no |
485
|
|
|
|
|
|
|
# effect, since it's been removed in previous query |
486
|
1
|
|
|
|
|
332
|
ok(PO::Author->remove_all({name=>"Geek"})); |
487
|
|
|
|
|
|
|
# we still should have two objects in total in our database |
488
|
1
|
|
|
|
|
292
|
ok(PO::Author->count == 2, "count: " . PO::Author->count); |
489
|
1
|
|
|
|
|
293
|
ok(PO::Author->remove_all); |
490
|
1
|
|
|
|
|
289
|
ok(PO::Author->count == 0); |
491
|
|
|
|
|
|
|
|
492
|
1
|
|
|
|
|
289
|
ok(PO::Article->remove_all); |
493
|
1
|
|
|
|
|
295
|
ok(PO::Article->count == 0); |
494
|
|
|
|
|
|
|
|
495
|
1
|
|
|
|
|
288
|
ok(PO::Article->drop_datasource); |
496
|
1
|
|
|
|
|
319
|
ok(PO::Author->drop_datasource); |
497
|
|
|
|
|
|
|
} |
498
|
|
|
|
|
|
|
|
499
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
|
501
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
|
503
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
|
505
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
1; |
508
|
|
|
|
|
|
|
__END__ |