line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::PObject::Test::HAS_A; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# HAS_A.pm,v 1.5 2003/11/06 01:21:10 sherzodr Exp |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
642
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
6
|
|
|
|
|
|
|
#use diagnostics; |
7
|
1
|
|
|
1
|
|
1110
|
use Test::More; |
|
1
|
|
|
|
|
18048
|
|
|
1
|
|
|
|
|
10
|
|
8
|
1
|
|
|
1
|
|
257
|
use vars ('$VERSION', '@ISA'); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
87
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
BEGIN { |
11
|
1
|
|
|
1
|
|
5
|
plan(tests => 37); |
12
|
1
|
|
|
1
|
|
170
|
use_ok("Class::PObject"); |
|
1
|
|
|
|
|
771
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
8
|
|
13
|
1
|
|
|
1
|
|
327
|
use_ok("Class::PObject::Test") |
|
1
|
|
|
|
|
502
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
14
|
|
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
@ISA = ('Class::PObject::Test'); |
17
|
|
|
|
|
|
|
$VERSION = '1.00'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub run { |
21
|
1
|
|
|
1
|
0
|
8
|
my $self = shift; |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
|
|
13
|
pobject 'PO::Author' => { |
24
|
|
|
|
|
|
|
columns => ['id', 'name'], |
25
|
|
|
|
|
|
|
driver => $self->{driver}, |
26
|
|
|
|
|
|
|
datasource => $self->{datasource}, |
27
|
|
|
|
|
|
|
serializer => 'storable' |
28
|
|
|
|
|
|
|
}; |
29
|
1
|
|
|
|
|
8
|
ok(1); |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
391
|
pobject 'PO::Article' => { |
32
|
|
|
|
|
|
|
columns => ['id', 'title', 'author'], |
33
|
|
|
|
|
|
|
driver => $self->{driver}, |
34
|
|
|
|
|
|
|
datasource => $self->{datasource}, |
35
|
|
|
|
|
|
|
serializer => 'storable', |
36
|
|
|
|
|
|
|
tmap => { |
37
|
|
|
|
|
|
|
author => 'PO::Author' |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
}; |
40
|
1
|
|
|
|
|
4
|
ok(1); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
################ |
43
|
|
|
|
|
|
|
# |
44
|
|
|
|
|
|
|
# Creating a new Author |
45
|
|
|
|
|
|
|
# |
46
|
1
|
|
|
|
|
271
|
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
|
|
|
|
287
|
ok($author->id ? 0 : 1 ); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
################ |
57
|
|
|
|
|
|
|
# |
58
|
|
|
|
|
|
|
# Filling in details of the author |
59
|
|
|
|
|
|
|
# |
60
|
1
|
|
|
|
|
291
|
$author->name("Sherzod Ruzmetov"); |
61
|
1
|
|
|
|
|
4
|
ok($author->name eq "Sherzod Ruzmetov"); |
62
|
1
|
|
|
|
|
321
|
ok(my $author_id = $author->save, $author->errstr); |
63
|
|
|
|
|
|
|
|
64
|
1
|
|
|
|
|
365
|
$author = undef; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
################ |
67
|
|
|
|
|
|
|
# |
68
|
|
|
|
|
|
|
# Creating new article |
69
|
|
|
|
|
|
|
# |
70
|
1
|
|
|
|
|
40
|
my $article = new PO::Article(); |
71
|
|
|
|
|
|
|
#print $article->dump; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
################ |
74
|
|
|
|
|
|
|
# |
75
|
|
|
|
|
|
|
# Is segmentation fault problem fixed? |
76
|
|
|
|
|
|
|
# |
77
|
1
|
|
|
|
|
6
|
ok(!$article->id); |
78
|
|
|
|
|
|
|
|
79
|
1
|
50
|
|
|
|
311
|
ok($article->title ? 0 : 1); |
80
|
|
|
|
|
|
|
#print $article->dump; |
81
|
1
|
50
|
|
|
|
5
|
TODO: { |
82
|
|
|
|
|
|
|
#local $TODO = "Still not sure why this one keeps failing"; |
83
|
1
|
|
|
|
|
258
|
ok($article->author ? 0 : 1, $article->author . " is empty") |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
################ |
88
|
|
|
|
|
|
|
# |
89
|
|
|
|
|
|
|
# Filling in details of the article |
90
|
|
|
|
|
|
|
# |
91
|
1
|
|
|
|
|
289
|
$article->title("Class::PObject now supports type-mapping"); |
92
|
|
|
|
|
|
|
|
93
|
1
|
|
|
|
|
15
|
$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
|
|
|
|
|
4
|
ok($article->author->name eq "Sherzod Ruzmetov", $article->author->name); |
100
|
1
|
|
|
|
|
234
|
ok(ref($article->author) eq "PO::Author", ref($article->author)); |
101
|
1
|
|
|
|
|
274
|
ok(my $article_id = $article->save(), $article->errstr ); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
#print $article->dump; |
104
|
|
|
|
|
|
|
|
105
|
1
|
|
|
|
|
294
|
$article = $author = undef; |
106
|
|
|
|
|
|
|
|
107
|
1
|
|
|
|
|
28
|
$article = PO::Article->load($article_id); |
108
|
1
|
|
|
|
|
4
|
ok($article); |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
#print $article->dump; |
111
|
|
|
|
|
|
|
|
112
|
1
|
|
|
|
|
233
|
$author = $article->author; |
113
|
1
|
|
|
|
|
4
|
ok($article->title eq "Class::PObject now supports type-mapping", $article->title); |
114
|
1
|
|
|
|
|
183
|
ok($author->name eq "Sherzod Ruzmetov", $article->author->name); |
115
|
1
|
|
|
|
|
163
|
ok(ref ($author) eq "PO::Author", ref($article->author)); |
116
|
|
|
|
|
|
|
|
117
|
1
|
|
|
|
|
185
|
$article->author($author->id); |
118
|
|
|
|
|
|
|
|
119
|
1
|
|
|
|
|
4
|
ok($article->save == $article_id, $article->errstr); |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
#print $article->dump; |
122
|
1
|
|
|
|
|
228
|
$article = undef; |
123
|
|
|
|
|
|
|
|
124
|
1
|
|
|
|
|
13
|
$article = PO::Article->load({author=>$author}); |
125
|
1
|
|
|
|
|
6
|
ok($article, "article: $article"); |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
#print $article->dump; |
128
|
|
|
|
|
|
|
|
129
|
1
|
|
|
|
|
291
|
ok($article->title eq "Class::PObject now supports type-mapping"); |
130
|
1
|
|
|
|
|
189
|
ok($article->author->name eq "Sherzod Ruzmetov", ''.$article->author->name); |
131
|
1
|
|
|
|
|
247
|
ok(ref($article->author) eq "PO::Author", ref($article->author)); |
132
|
|
|
|
|
|
|
|
133
|
1
|
|
|
|
|
213
|
ok($article->save == $article_id, $article->errstr); |
134
|
|
|
|
|
|
|
|
135
|
1
|
|
|
|
|
309
|
$article = undef; |
136
|
|
|
|
|
|
|
|
137
|
1
|
|
|
|
|
16
|
my $result = PO::Article->fetch({author=>$author}); |
138
|
1
|
|
|
|
|
5
|
ok($article = $result->next); |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
#print $article->dump; |
141
|
|
|
|
|
|
|
|
142
|
1
|
|
|
|
|
233
|
ok($author = $article->author); |
143
|
|
|
|
|
|
|
#print $article->dump; |
144
|
1
|
|
|
|
|
220
|
ok($article->title eq "Class::PObject now supports type-mapping"); |
145
|
1
|
|
|
|
|
240
|
ok($author->name eq "Sherzod Ruzmetov", ''.$article->author->name); |
146
|
1
|
|
|
|
|
239
|
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
|
|
|
|
|
251
|
my $article2 = new PO::Article(); |
157
|
1
|
|
|
|
|
7
|
$article2->title("Is this annoying bug fixed?"); |
158
|
1
|
50
|
|
|
|
12
|
ok($article2->columns()->{author} ? 0 : 1, "Author shouldn't be set yet"); |
159
|
1
|
50
|
|
|
|
253
|
ok($article2->author ? 0 : 1, "Author shouldnt' be set yet"); |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
|
163
|
1
|
|
|
|
|
287
|
ok(PO::Article->count() == 1); |
164
|
1
|
|
|
|
|
254
|
ok(PO::Article->count({author=>$author}) == 1); |
165
|
1
|
|
|
|
|
282
|
ok(PO::Article->remove_all); |
166
|
1
|
|
|
|
|
319
|
ok(PO::Article->count({author=>$author}) == 0); |
167
|
|
|
|
|
|
|
|
168
|
1
|
|
|
|
|
267
|
ok(PO::Article->drop_datasource); |
169
|
1
|
|
|
|
|
258
|
ok(PO::Author->drop_datasource); |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
1; |
173
|
|
|
|
|
|
|
__END__ |