line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::PObject::Test::HAS_A; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# $Id: HAS_A.pm,v 1.5 2003/11/06 01:21:10 sherzodr Exp $ |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
573
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
31
|
|
6
|
|
|
|
|
|
|
#use diagnostics; |
7
|
1
|
|
|
1
|
|
808
|
use Test::More; |
|
1
|
|
|
|
|
19874
|
|
|
1
|
|
|
|
|
12
|
|
8
|
1
|
|
|
1
|
|
337
|
use vars ('$VERSION', '@ISA'); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
82
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
BEGIN { |
11
|
1
|
|
|
1
|
|
5
|
plan(tests => 37); |
12
|
1
|
|
|
1
|
|
497
|
use_ok("Class::PObject"); |
|
1
|
|
|
|
|
754
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
7
|
|
13
|
1
|
|
|
1
|
|
963
|
use_ok("Class::PObject::Test") |
|
1
|
|
|
|
|
690
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
|
1
|
|
|
|
|
20
|
|
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
@ISA = ('Class::PObject::Test'); |
17
|
|
|
|
|
|
|
$VERSION = '1.00'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub run { |
21
|
1
|
|
|
1
|
0
|
6
|
my $self = shift; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
pobject 'PO::Author' => { |
24
|
|
|
|
|
|
|
columns => ['id', 'name'], |
25
|
|
|
|
|
|
|
driver => $self->{driver}, |
26
|
|
|
|
|
|
|
datasource => $self->{datasource}, |
27
|
1
|
|
|
|
|
12
|
serializer => 'storable' |
28
|
|
|
|
|
|
|
}; |
29
|
1
|
|
|
|
|
5
|
ok(1); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
pobject 'PO::Article' => { |
32
|
|
|
|
|
|
|
columns => ['id', 'title', 'author'], |
33
|
|
|
|
|
|
|
driver => $self->{driver}, |
34
|
|
|
|
|
|
|
datasource => $self->{datasource}, |
35
|
1
|
|
|
|
|
539
|
serializer => 'storable', |
36
|
|
|
|
|
|
|
tmap => { |
37
|
|
|
|
|
|
|
author => 'PO::Author' |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
}; |
40
|
1
|
|
|
|
|
2
|
ok(1); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
################ |
43
|
|
|
|
|
|
|
# |
44
|
|
|
|
|
|
|
# Creating a new Author |
45
|
|
|
|
|
|
|
# |
46
|
1
|
|
|
|
|
268
|
my $author = new PO::Author(); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
################ |
49
|
|
|
|
|
|
|
# |
50
|
|
|
|
|
|
|
# Is Segmentation fault still persistent? |
51
|
|
|
|
|
|
|
# |
52
|
1
|
50
|
|
|
|
5
|
ok($author->name ? 0 : 1 ); |
53
|
1
|
50
|
|
|
|
388
|
ok($author->id ? 0 : 1 ); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
################ |
57
|
|
|
|
|
|
|
# |
58
|
|
|
|
|
|
|
# Filling in details of the author |
59
|
|
|
|
|
|
|
# |
60
|
1
|
|
|
|
|
393
|
$author->name("Sherzod Ruzmetov"); |
61
|
1
|
|
|
|
|
4
|
ok($author->name eq "Sherzod Ruzmetov"); |
62
|
1
|
|
|
|
|
460
|
ok(my $author_id = $author->save, $author->errstr); |
63
|
|
|
|
|
|
|
|
64
|
1
|
|
|
|
|
722
|
$author = undef; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
################ |
67
|
|
|
|
|
|
|
# |
68
|
|
|
|
|
|
|
# Creating new article |
69
|
|
|
|
|
|
|
# |
70
|
1
|
|
|
|
|
35
|
my $article = new PO::Article(); |
71
|
|
|
|
|
|
|
#print $article->dump; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
################ |
74
|
|
|
|
|
|
|
# |
75
|
|
|
|
|
|
|
# Is segmentation fault problem fixed? |
76
|
|
|
|
|
|
|
# |
77
|
1
|
|
|
|
|
5
|
ok(!$article->id); |
78
|
|
|
|
|
|
|
|
79
|
1
|
50
|
|
|
|
431
|
ok($article->title ? 0 : 1); |
80
|
|
|
|
|
|
|
#print $article->dump; |
81
|
|
|
|
|
|
|
TODO: { |
82
|
|
|
|
|
|
|
#local $TODO = "Still not sure why this one keeps failing"; |
83
|
1
|
50
|
|
|
|
415
|
ok($article->author ? 0 : 1, $article->author . " is empty") |
|
1
|
|
|
|
|
7
|
|
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
################ |
88
|
|
|
|
|
|
|
# |
89
|
|
|
|
|
|
|
# Filling in details of the article |
90
|
|
|
|
|
|
|
# |
91
|
1
|
|
|
|
|
445
|
$article->title("Class::PObject now supports type-mapping"); |
92
|
|
|
|
|
|
|
|
93
|
1
|
|
|
|
|
13
|
$author = PO::Author->load($author_id); |
94
|
|
|
|
|
|
|
#print $article->dump; |
95
|
1
|
|
|
|
|
5
|
$article->author( $author ); |
96
|
|
|
|
|
|
|
#print $article->dump; |
97
|
|
|
|
|
|
|
#print $author->dump; |
98
|
|
|
|
|
|
|
|
99
|
1
|
|
|
|
|
5
|
ok($article->author->name eq "Sherzod Ruzmetov", $article->author->name); |
100
|
1
|
|
|
|
|
313
|
ok(ref($article->author) eq "PO::Author", ref($article->author)); |
101
|
1
|
|
|
|
|
279
|
ok(my $article_id = $article->save(), $article->errstr ); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
#print $article->dump; |
104
|
|
|
|
|
|
|
|
105
|
1
|
|
|
|
|
325
|
$article = $author = undef; |
106
|
|
|
|
|
|
|
|
107
|
1
|
|
|
|
|
18
|
$article = PO::Article->load($article_id); |
108
|
1
|
|
|
|
|
3
|
ok($article); |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
#print $article->dump; |
111
|
|
|
|
|
|
|
|
112
|
1
|
|
|
|
|
308
|
$author = $article->author; |
113
|
1
|
|
|
|
|
4
|
ok($article->title eq "Class::PObject now supports type-mapping", $article->title); |
114
|
1
|
|
|
|
|
236
|
ok($author->name eq "Sherzod Ruzmetov", $article->author->name); |
115
|
1
|
|
|
|
|
241
|
ok(ref ($author) eq "PO::Author", ref($article->author)); |
116
|
|
|
|
|
|
|
|
117
|
1
|
|
|
|
|
260
|
$article->author($author->id); |
118
|
|
|
|
|
|
|
|
119
|
1
|
|
|
|
|
3
|
ok($article->save == $article_id, $article->errstr); |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
#print $article->dump; |
122
|
1
|
|
|
|
|
274
|
$article = undef; |
123
|
|
|
|
|
|
|
|
124
|
1
|
|
|
|
|
11
|
$article = PO::Article->load({author=>$author}); |
125
|
1
|
|
|
|
|
6
|
ok($article, "article: $article"); |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
#print $article->dump; |
128
|
|
|
|
|
|
|
|
129
|
1
|
|
|
|
|
525
|
ok($article->title eq "Class::PObject now supports type-mapping"); |
130
|
1
|
|
|
|
|
261
|
ok($article->author->name eq "Sherzod Ruzmetov", ''.$article->author->name); |
131
|
1
|
|
|
|
|
277
|
ok(ref($article->author) eq "PO::Author", ref($article->author)); |
132
|
|
|
|
|
|
|
|
133
|
1
|
|
|
|
|
294
|
ok($article->save == $article_id, $article->errstr); |
134
|
|
|
|
|
|
|
|
135
|
1
|
|
|
|
|
275
|
$article = undef; |
136
|
|
|
|
|
|
|
|
137
|
1
|
|
|
|
|
14
|
my $result = PO::Article->fetch({author=>$author}); |
138
|
1
|
|
|
|
|
3
|
ok($article = $result->next); |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
#print $article->dump; |
141
|
|
|
|
|
|
|
|
142
|
1
|
|
|
|
|
384
|
ok($author = $article->author); |
143
|
|
|
|
|
|
|
#print $article->dump; |
144
|
1
|
|
|
|
|
327
|
ok($article->title eq "Class::PObject now supports type-mapping"); |
145
|
1
|
|
|
|
|
311
|
ok($author->name eq "Sherzod Ruzmetov", ''.$article->author->name); |
146
|
1
|
|
|
|
|
382
|
ok(ref($author) eq "PO::Author", ref($article->author)); |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
#print Dumper($article); |
149
|
|
|
|
|
|
|
#print Dumper($author); |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
################ |
152
|
|
|
|
|
|
|
# FIX: |
153
|
|
|
|
|
|
|
# If we created another article, but didn't assign any value to its |
154
|
|
|
|
|
|
|
# author field, when we access author(), it used to return the Author object |
155
|
|
|
|
|
|
|
# from the previous article's author. |
156
|
1
|
|
|
|
|
374
|
my $article2 = new PO::Article(); |
157
|
1
|
|
|
|
|
6
|
$article2->title("Is this annoying bug fixed?"); |
158
|
1
|
50
|
|
|
|
9
|
ok($article2->columns()->{author} ? 0 : 1, "Author shouldn't be set yet"); |
159
|
1
|
50
|
|
|
|
289
|
ok($article2->author ? 0 : 1, "Author shouldnt' be set yet"); |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
|
163
|
1
|
|
|
|
|
439
|
ok(PO::Article->count() == 1); |
164
|
1
|
|
|
|
|
492
|
ok(PO::Article->count({author=>$author}) == 1); |
165
|
1
|
|
|
|
|
522
|
ok(PO::Article->remove_all); |
166
|
1
|
|
|
|
|
510
|
ok(PO::Article->count({author=>$author}) == 0); |
167
|
|
|
|
|
|
|
|
168
|
1
|
|
|
|
|
464
|
ok(PO::Article->drop_datasource); |
169
|
1
|
|
|
|
|
381
|
ok(PO::Author->drop_datasource); |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
1; |
173
|
|
|
|
|
|
|
__END__ |