line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CGI::Session::Test::Default; |
2
|
|
|
|
|
|
|
|
3
|
15
|
|
|
15
|
|
2708844
|
use strict; |
|
15
|
|
|
|
|
32
|
|
|
15
|
|
|
|
|
578
|
|
4
|
15
|
|
|
15
|
|
71
|
use Carp; |
|
15
|
|
|
|
|
20
|
|
|
15
|
|
|
|
|
891
|
|
5
|
15
|
|
|
15
|
|
1292
|
use Test::More; |
|
15
|
|
|
|
|
13232
|
|
|
15
|
|
|
|
|
82
|
|
6
|
15
|
|
|
15
|
|
11858
|
use Data::Dumper; |
|
15
|
|
|
|
|
117079
|
|
|
15
|
|
|
|
|
28030
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
$CGI::Session::Test::Default::VERSION = '1.52'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 CGI::Session::Test::Default |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Run a suite of tests for a given CGI::Session::Driver |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head2 new() |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $t = CGI::Session::Test::Default->new( |
17
|
|
|
|
|
|
|
# These are all optional, with default as follows |
18
|
|
|
|
|
|
|
dsn => "driver:file", |
19
|
|
|
|
|
|
|
args => undef, |
20
|
|
|
|
|
|
|
tests => 77, |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Create a new test object, possibly overriding some defaults. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub new { |
28
|
2
|
|
|
2
|
1
|
4724
|
my $class = shift; |
29
|
2
|
|
|
|
|
16
|
my $self = bless { |
30
|
|
|
|
|
|
|
dsn => "driver:file", |
31
|
|
|
|
|
|
|
args => undef, |
32
|
|
|
|
|
|
|
tests => 99, |
33
|
|
|
|
|
|
|
@_ |
34
|
|
|
|
|
|
|
}, $class; |
35
|
|
|
|
|
|
|
|
36
|
2
|
|
|
|
|
8
|
return $self; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head2 number_of_tests() |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $new_num = $t->number_of_tests($new_num); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
A setter/accessor method to affect the number of tests to run, |
44
|
|
|
|
|
|
|
after C has been called and before C. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub number_of_tests { |
49
|
2
|
|
|
2
|
1
|
12
|
my $self = shift; |
50
|
|
|
|
|
|
|
|
51
|
2
|
50
|
|
|
|
11
|
if ( @_ ) { |
52
|
0
|
|
|
|
|
0
|
$self->{tests} = $_[0]; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
2
|
|
|
|
|
22
|
return $self->{tests}; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 run() |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
$t->run(); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Run the test suite. See C for setting related options. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub run { |
67
|
2
|
|
|
2
|
1
|
6
|
my $self = shift; |
68
|
|
|
|
|
|
|
|
69
|
2
|
|
|
2
|
|
1506
|
use_ok("CGI::Session", "CGI::Session loaded successfully!"); |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
22
|
|
|
2
|
|
|
|
|
11
|
|
70
|
|
|
|
|
|
|
|
71
|
2
|
|
|
|
|
1331
|
my $sid = undef; |
72
|
2
|
|
|
|
|
10
|
FIRST: { |
73
|
2
|
|
|
|
|
4
|
ok(1, "=== 1 ==="); |
74
|
2
|
50
|
|
|
|
750
|
my $session = CGI::Session->load() or die CGI::Session->errstr; |
75
|
2
|
|
|
|
|
14
|
ok($session, "empty session should be created"); |
76
|
2
|
|
|
|
|
1354
|
ok(!$session->id); |
77
|
2
|
|
|
|
|
816
|
ok($session->is_empty); |
78
|
2
|
|
|
|
|
857
|
ok(!$session->is_expired); |
79
|
|
|
|
|
|
|
|
80
|
2
|
|
|
|
|
768
|
undef $session; |
81
|
|
|
|
|
|
|
|
82
|
2
|
50
|
|
|
|
15
|
$session = CGI::Session->new($self->{dsn}, '_DOESN\'T EXIST_', $self->{args}) or die CGI::Session->errstr; |
83
|
2
|
|
|
|
|
11
|
ok( $session, "Session created successfully!"); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# |
86
|
|
|
|
|
|
|
# checking if the driver object created is really the driver requested: |
87
|
|
|
|
|
|
|
# |
88
|
2
|
|
|
|
|
1111
|
my $dsn = $session->parse_dsn( $self->{dsn} ); |
89
|
2
|
|
|
|
|
9
|
ok( ref $session->_driver eq "CGI::Session::Driver::" . $dsn->{driver}, ref $dsn->{Driver} ); |
90
|
|
|
|
|
|
|
|
91
|
2
|
|
33
|
|
|
859
|
ok( $session->ctime && $session->atime, "ctime & atime are set"); |
92
|
2
|
|
|
|
|
854
|
ok( $session->atime == $session->ctime, "ctime == atime"); |
93
|
2
|
|
|
|
|
855
|
ok( !$session->etime, "etime not set yet"); |
94
|
|
|
|
|
|
|
|
95
|
2
|
|
|
|
|
870
|
ok( $session->id, "session id is " . $session->id); |
96
|
|
|
|
|
|
|
|
97
|
2
|
|
|
|
|
832
|
$session->param('author', "Sherzod Ruzmetov"); |
98
|
2
|
|
|
|
|
16
|
$session->param(-name=>'emails', -value=>['sherzodr@cpan.org', 'sherzodr@handalak.com']); |
99
|
2
|
|
|
|
|
14
|
$session->param('blogs', { |
100
|
|
|
|
|
|
|
'./lost+found' => 'http://author.handalak.com/', |
101
|
|
|
|
|
|
|
'Yigitlik sarguzashtlari' => 'http://author.handalak.com/uz/' |
102
|
|
|
|
|
|
|
}); |
103
|
|
|
|
|
|
|
|
104
|
2
|
|
|
|
|
7
|
ok( ($session->param) == 3, "session holds 3 params" . scalar $session->param ); |
105
|
2
|
|
|
|
|
836
|
ok( $session->param('author') eq "Sherzod Ruzmetov", "My name's correct!"); |
106
|
|
|
|
|
|
|
|
107
|
2
|
|
|
|
|
806
|
ok( ref ($session->param('emails')) eq 'ARRAY', "'emails' holds list of values" ); |
108
|
2
|
|
|
|
|
792
|
ok( @{ $session->param('emails') } == 2, "'emails' holds list of two values"); |
|
2
|
|
|
|
|
11
|
|
109
|
2
|
|
|
|
|
819
|
ok( $session->param('emails')->[0] eq 'sherzodr@cpan.org', "first value of 'emails' is correct!"); |
110
|
2
|
|
|
|
|
829
|
ok( $session->param('emails')->[1] eq 'sherzodr@handalak.com', "second value of 'emails' is correct!"); |
111
|
|
|
|
|
|
|
|
112
|
2
|
|
|
|
|
816
|
ok( ref( $session->param('blogs') ) eq 'HASH', "'blogs' holds a hash"); |
113
|
2
|
|
|
|
|
804
|
ok( $session->param('blogs')->{'./lost+found'} eq 'http://author.handalak.com/', "first blog is correct"); |
114
|
2
|
|
|
|
|
804
|
ok( $session->param('blogs')->{'Yigitlik sarguzashtlari'} eq 'http://author.handalak.com/uz/', "second blog is correct"); |
115
|
|
|
|
|
|
|
|
116
|
2
|
|
|
|
|
800
|
$sid = $session->id; |
117
|
2
|
|
|
|
|
10
|
$session->flush(); |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
2
|
|
|
|
|
2000269
|
sleep(1); |
121
|
|
|
|
|
|
|
|
122
|
2
|
|
|
|
|
24
|
SECOND: { |
123
|
2
|
|
|
|
|
17
|
SKIP: { |
124
|
2
|
|
|
|
|
6
|
ok(1, "=== 2 ==="); |
125
|
2
|
|
|
|
|
1451
|
my $session; |
126
|
2
|
|
|
|
|
4
|
eval { $session = CGI::Session->load($self->{dsn}, $sid, $self->{args}) }; |
|
2
|
|
|
|
|
24
|
|
127
|
|
|
|
|
|
|
|
128
|
2
|
100
|
66
|
|
|
28
|
if ($@ || CGI::Session->errstr) { |
129
|
1
|
|
|
|
|
6
|
skip "couldn't load session, bailing out: SQLite/Storable support is TODO", 56; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
1
|
|
|
|
|
6
|
is($@.CGI::Session->errstr,'','survived eval without error.'); |
133
|
1
|
|
|
|
|
328
|
ok($session, "Session was retrieved successfully"); |
134
|
1
|
|
|
|
|
355
|
ok(!$session->is_expired, "session isn't expired yet"); |
135
|
|
|
|
|
|
|
|
136
|
1
|
|
|
|
|
343
|
is($session->id,$sid, "session IDs are consistent: " . $session->id); |
137
|
1
|
|
|
|
|
351
|
ok($session->atime > $session->ctime, "ctime should be older than atime"); |
138
|
1
|
|
|
|
|
323
|
ok(!$session->etime, "etime shouldn't be set yet"); |
139
|
|
|
|
|
|
|
|
140
|
1
|
|
|
|
|
333
|
ok( ($session->param) == 3, "session should hold params" ); |
141
|
1
|
|
|
|
|
366
|
ok( $session->param('author') eq "Sherzod Ruzmetov", "my name's correct"); |
142
|
|
|
|
|
|
|
|
143
|
1
|
|
|
|
|
365
|
ok( ref ($session->param('emails')) eq 'ARRAY', "'emails' should hold list of values" ); |
144
|
1
|
|
|
|
|
314
|
ok( @{ $session->param('emails') } == 2, "'emails' should hold list of two values"); |
|
1
|
|
|
|
|
5
|
|
145
|
1
|
|
|
|
|
462
|
ok( $session->param('emails')->[0] eq 'sherzodr@cpan.org', "first value is correct!"); |
146
|
1
|
|
|
|
|
384
|
ok( $session->param('emails')->[1] eq 'sherzodr@handalak.com', "second value is correct!"); |
147
|
|
|
|
|
|
|
|
148
|
1
|
|
|
|
|
325
|
ok( ref( $session->param('blogs') ) eq 'HASH', "'blogs' holds a hash"); |
149
|
1
|
|
|
|
|
382
|
ok( $session->param('blogs')->{'./lost+found'} eq 'http://author.handalak.com/', "first blog is correct!"); |
150
|
1
|
|
|
|
|
350
|
ok( $session->param('blogs')->{'Yigitlik sarguzashtlari'} eq 'http://author.handalak.com/uz/', "second blog is correct!"); |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
# TODO: test many any other variations of expire() syntax |
153
|
1
|
|
|
|
|
354
|
$session->expire('+1s'); |
154
|
1
|
|
|
|
|
4
|
ok($session->etime == 1, "etime set to 1 second"); |
155
|
|
|
|
|
|
|
|
156
|
1
|
|
|
|
|
395
|
$session->expire("+1m"); |
157
|
1
|
|
|
|
|
3
|
ok($session->etime == 60, "etime set to one minute"); |
158
|
|
|
|
|
|
|
|
159
|
1
|
|
|
|
|
375
|
$session->expires("2h"); |
160
|
1
|
|
|
|
|
4
|
ok($session->etime == 7200, "etime set to two hours"); |
161
|
|
|
|
|
|
|
|
162
|
1
|
|
|
|
|
407
|
$session->expires("5d"); |
163
|
1
|
|
|
|
|
3
|
ok($session->etime == 432000, "etime set to 5 days"); |
164
|
|
|
|
|
|
|
|
165
|
1
|
|
|
|
|
327
|
$session->expires("-10s"); |
166
|
1
|
|
|
|
|
4
|
ok($session->etime == -10, "etime set to 10 seconds in the past"); |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
# |
169
|
|
|
|
|
|
|
# Setting the expiration time back to 1s, so that subsequent tests |
170
|
|
|
|
|
|
|
# relying on this value pass |
171
|
|
|
|
|
|
|
# |
172
|
1
|
|
|
|
|
356
|
$session->expire("1s"); |
173
|
1
|
|
|
|
|
5
|
ok($session->etime == 1, "etime set back to one second"); |
174
|
1
|
|
|
|
|
322
|
eval { $session->close(); }; |
|
1
|
|
|
|
|
5
|
|
175
|
1
|
|
|
|
|
6
|
is($@, '', 'calling close method survives eval'); |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
2
|
|
|
|
|
2013824
|
sleep(1); # <-- letting the time tick |
180
|
|
|
|
|
|
|
|
181
|
2
|
|
|
|
|
15
|
my $driver; |
182
|
2
|
|
|
|
|
21
|
THREE: { |
183
|
2
|
|
|
|
|
6
|
ok(1, "=== 3 ==="); |
184
|
2
|
100
|
|
|
|
1476
|
my $session = CGI::Session->load($self->{dsn}, $sid, $self->{args}) or die CGI::Session->errstr; |
185
|
1
|
|
|
|
|
4
|
ok($session, "Session instance loaded "); |
186
|
1
|
|
|
|
|
525
|
ok(!$session->id, "session doesn't have ID"); |
187
|
1
|
|
|
|
|
462
|
ok($session->is_empty, "session is empty, which is the same as above"); |
188
|
|
|
|
|
|
|
#print $session->dump; |
189
|
1
|
|
|
|
|
333
|
ok($session->is_expired, "session was expired"); |
190
|
1
|
|
|
|
|
414
|
ok(!$session->param('author'), "session data cleared"); |
191
|
|
|
|
|
|
|
|
192
|
1
|
|
|
|
|
1000461
|
sleep(1); |
193
|
|
|
|
|
|
|
|
194
|
1
|
50
|
|
|
|
17
|
$session = $session->new() or die CGI::Session->errstr; |
195
|
|
|
|
|
|
|
#print $session->dump(); |
196
|
1
|
|
|
|
|
4
|
ok($session, "new session created"); |
197
|
1
|
|
|
|
|
811
|
ok($session->id, "session has id :" . $session->id ); |
198
|
1
|
|
|
|
|
459
|
ok(!$session->is_expired, "session isn't expired"); |
199
|
1
|
|
|
|
|
484
|
ok(!$session->is_empty, "session isn't empty"); |
200
|
1
|
|
|
|
|
458
|
ok($session->atime == $session->ctime, "access and creation times are same"); |
201
|
|
|
|
|
|
|
|
202
|
1
|
|
|
|
|
475
|
ok($session->id ne $sid, "it's a completely different session than above"); |
203
|
|
|
|
|
|
|
|
204
|
1
|
|
|
|
|
447
|
$driver = $session->_driver(); |
205
|
1
|
|
|
|
|
6
|
$sid = $session->id; |
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
FOUR: { |
211
|
|
|
|
|
|
|
# We are intentionally removing the session stored in the datastore and will be requesting |
212
|
|
|
|
|
|
|
# re-initialization of that id. This test is necessary since I noticed weird behaviors in |
213
|
|
|
|
|
|
|
# some of my web applications that kept creating new sessions when the object requested |
214
|
|
|
|
|
|
|
# wasn't in the datastore. |
215
|
1
|
|
|
|
|
3
|
ok(1, "=== 4 ==="); |
|
1
|
|
|
|
|
5
|
|
216
|
|
|
|
|
|
|
|
217
|
1
|
|
|
|
|
336
|
ok($driver->remove( $sid ), "Session '$sid' removed from datastore successfully"); |
218
|
|
|
|
|
|
|
|
219
|
1
|
50
|
|
|
|
335
|
my $session = CGI::Session->new($self->{dsn}, $sid, $self->{args} ) or die CGI::Session->errstr; |
220
|
1
|
|
|
|
|
4
|
ok($session, "session object created successfully"); |
221
|
1
|
|
|
|
|
375
|
ok($session->id ne $sid, "claimed ID ($sid) couldn't be recovered. New ID is: " . $session->id); |
222
|
1
|
|
|
|
|
338
|
$sid = $session->id; |
223
|
|
|
|
|
|
|
} |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
FIVE: { |
228
|
1
|
|
|
|
|
3
|
ok(1, "=== 5 ==="); |
|
1
|
|
|
|
|
5
|
|
229
|
1
|
50
|
|
|
|
335
|
my $session = CGI::Session->new($self->{dsn}, $sid, $self->{args}) or die CGI::Session->errstr; |
230
|
1
|
|
|
|
|
20
|
ok($session, "Session object created successfully"); |
231
|
1
|
|
|
|
|
328
|
ok($session->id eq $sid, "claimed id ($sid) was recovered successfully!"); |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
# Remove the object, finally! |
234
|
1
|
|
|
|
|
314
|
$session->delete(); |
235
|
|
|
|
|
|
|
} |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
SIX: { |
239
|
1
|
|
|
|
|
3
|
ok(1, "=== 6 ==="); |
|
1
|
|
|
|
|
5
|
|
240
|
1
|
50
|
|
|
|
353
|
my $session = CGI::Session->new($self->{dsn}, $sid, $self->{args}) or die CGI::Session->errstr; |
241
|
1
|
|
|
|
|
3
|
ok($session, "Session object created successfully"); |
242
|
1
|
|
|
|
|
329
|
ok($session->id ne $sid, "New object created, because previous object was deleted"); |
243
|
1
|
|
|
|
|
320
|
$sid = $session->id; |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
# |
246
|
|
|
|
|
|
|
# creating a simple object to be stored into session |
247
|
1
|
|
|
|
|
34
|
my $simple_class = SimpleObjectClass->new(); |
248
|
1
|
|
|
|
|
71
|
ok($simple_class, "SimpleObjectClass created successfully"); |
249
|
|
|
|
|
|
|
|
250
|
1
|
|
|
|
|
439
|
$simple_class->name("Sherzod Ruzmetov"); |
251
|
1
|
|
|
|
|
19
|
$simple_class->emails(0, 'sherzodr@handalak.com'); |
252
|
1
|
|
|
|
|
20
|
$simple_class->emails(1, 'sherzodr@cpan.org'); |
253
|
1
|
|
|
|
|
18
|
$simple_class->blogs('lost+found', 'http://author.handalak.com/'); |
254
|
1
|
|
|
|
|
21
|
$simple_class->blogs('yigitlik', 'http://author.handalak.com/uz/'); |
255
|
1
|
|
|
|
|
9
|
$session->param('simple_object', $simple_class); |
256
|
|
|
|
|
|
|
|
257
|
1
|
|
|
|
|
3
|
ok($session->param('simple_object')->name eq "Sherzod Ruzmetov"); |
258
|
1
|
|
|
|
|
317
|
ok($session->param('simple_object')->emails(1) eq 'sherzodr@cpan.org'); |
259
|
1
|
|
|
|
|
316
|
ok($session->param('simple_object')->blogs('yigitlik') eq 'http://author.handalak.com/uz/'); |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
# |
262
|
|
|
|
|
|
|
# creating an overloaded object to be stored into session |
263
|
1
|
|
|
|
|
372
|
my $overloaded_class = OverloadedObjectClass->new("ABCDEFG"); |
264
|
1
|
|
|
|
|
5
|
ok($overloaded_class, "OverloadedObjectClass created successfully"); |
265
|
1
|
|
|
|
|
316
|
ok(overload::Overloaded($overloaded_class) , "OverloadedObjectClass is properly overloaded"); |
266
|
1
|
|
|
|
|
1370
|
ok(ref ($overloaded_class) eq "OverloadedObjectClass", "OverloadedObjectClass is an object"); |
267
|
1
|
|
|
|
|
317
|
$session->param("overloaded_object", $overloaded_class); |
268
|
|
|
|
|
|
|
|
269
|
1
|
|
|
|
|
3
|
ok($session->param("overloaded_object") eq "ABCDEFG"); |
270
|
|
|
|
|
|
|
|
271
|
1
|
|
|
|
|
467
|
my $simple_class2 = SimpleObjectClass->new(); |
272
|
1
|
|
|
|
|
29
|
ok($simple_class2, "SimpleObjectClass created successfully"); |
273
|
|
|
|
|
|
|
|
274
|
1
|
|
|
|
|
339
|
$simple_class2->name("Sherzod Ruzmetov"); |
275
|
1
|
|
|
|
|
18
|
$simple_class2->emails(0, 'sherzodr@handalak.com'); |
276
|
1
|
|
|
|
|
20
|
$simple_class2->emails(1, 'sherzodr@cpan.org'); |
277
|
1
|
|
|
|
|
17
|
$simple_class2->blogs('lost+found', 'http://author.handalak.com/'); |
278
|
1
|
|
|
|
|
19
|
$simple_class2->blogs('yigitlik', 'http://author.handalak.com/uz/'); |
279
|
1
|
|
|
|
|
11
|
$session->param("embedded_simple_and_overloaded",[ undef, $simple_class2, OverloadedObjectClass->new("Embedded") ]); |
280
|
|
|
|
|
|
|
|
281
|
1
|
|
|
|
|
4
|
ok(!defined($session->param("embedded_simple_and_overloaded")->[0]),"First element of anonymous array undef"); |
282
|
|
|
|
|
|
|
|
283
|
1
|
|
|
|
|
322
|
ok($session->param("embedded_simple_and_overloaded")->[1]->name eq "Sherzod Ruzmetov"); |
284
|
1
|
|
|
|
|
314
|
ok($session->param("embedded_simple_and_overloaded")->[1]->emails(1) eq 'sherzodr@cpan.org'); |
285
|
1
|
|
|
|
|
315
|
ok($session->param("embedded_simple_and_overloaded")->[1]->blogs('yigitlik') eq 'http://author.handalak.com/uz/'); |
286
|
|
|
|
|
|
|
|
287
|
1
|
|
|
|
|
318
|
ok($session->param("embedded_simple_and_overloaded")->[2] eq "Embedded"); |
288
|
|
|
|
|
|
|
} |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
SEVEN: { |
292
|
1
|
|
|
|
|
4
|
ok(1, "=== 7 ==="); |
|
1
|
|
|
|
|
5
|
|
293
|
1
|
50
|
|
|
|
402
|
my $session = CGI::Session->new($self->{dsn}, $sid, $self->{args}) or die CGI::Session->errstr; |
294
|
1
|
|
|
|
|
4
|
ok($session, "Session object created successfully"); |
295
|
1
|
|
|
|
|
322
|
ok($session->id eq $sid, "Previously stored object loaded successfully"); |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
|
298
|
1
|
|
|
|
|
315
|
my $simple_object = $session->param("simple_object"); |
299
|
1
|
|
|
|
|
5
|
ok(ref $simple_object eq "SimpleObjectClass", "SimpleObjectClass loaded successfully"); |
300
|
|
|
|
|
|
|
|
301
|
1
|
|
|
|
|
313
|
my $dsn = CGI::Session->parse_dsn($self->{dsn}); |
302
|
1
|
|
|
|
|
22
|
ok($simple_object->name eq "Sherzod Ruzmetov"); |
303
|
1
|
|
|
|
|
334
|
ok($simple_object->emails(1) eq 'sherzodr@cpan.org'); |
304
|
1
|
|
|
|
|
328
|
ok($simple_object->emails(0) eq 'sherzodr@handalak.com'); |
305
|
1
|
|
|
|
|
327
|
ok($simple_object->blogs('lost+found') eq 'http://author.handalak.com/'); |
306
|
1
|
|
|
|
|
310
|
ok(ref $session->param("overloaded_object") ); |
307
|
1
|
|
|
|
|
303
|
ok($session->param("overloaded_object") eq "ABCDEFG", "Object is still overloaded"); |
308
|
1
|
|
|
|
|
345
|
ok(overload::Overloaded($session->param("overloaded_object")), "Object is really overloaded"); |
309
|
|
|
|
|
|
|
|
310
|
1
|
|
|
|
|
456
|
ok(!defined($session->param("embedded_simple_and_overloaded")->[0]),"First element of anonymous array undef"); |
311
|
|
|
|
|
|
|
|
312
|
1
|
|
|
|
|
316
|
my $simple_object2 = $session->param("embedded_simple_and_overloaded")->[1]; |
313
|
1
|
|
|
|
|
4
|
ok(ref $simple_object2 eq "SimpleObjectClass", "SimpleObjectClass loaded successfully"); |
314
|
|
|
|
|
|
|
|
315
|
1
|
|
|
|
|
349
|
ok($simple_object2->name eq "Sherzod Ruzmetov"); |
316
|
1
|
|
|
|
|
328
|
ok($simple_object2->emails(1) eq 'sherzodr@cpan.org'); |
317
|
1
|
|
|
|
|
329
|
ok($simple_object2->emails(0) eq 'sherzodr@handalak.com'); |
318
|
1
|
|
|
|
|
329
|
ok($simple_object2->blogs('lost+found') eq 'http://author.handalak.com/'); |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
|
321
|
1
|
|
|
|
|
310
|
ok($session->param("embedded_simple_and_overloaded")->[2] eq "Embedded"); |
322
|
1
|
|
|
|
|
302
|
ok(overload::Overloaded($session->param("embedded_simple_and_overloaded")->[2]), "Object is really overloaded"); |
323
|
1
|
|
|
|
|
340
|
$session->delete(); |
324
|
|
|
|
|
|
|
} |
325
|
|
|
|
|
|
|
} |
326
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
package SimpleObjectClass; |
329
|
15
|
|
|
15
|
|
130
|
use strict; |
|
15
|
|
|
|
|
44
|
|
|
15
|
|
|
|
|
550
|
|
330
|
15
|
|
|
15
|
|
9300
|
use Class::Struct; |
|
15
|
|
|
|
|
24522
|
|
|
15
|
|
|
|
|
77
|
|
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
struct ( |
333
|
|
|
|
|
|
|
name => '$', |
334
|
|
|
|
|
|
|
emails => '@', |
335
|
|
|
|
|
|
|
blogs => '%' |
336
|
|
|
|
|
|
|
); |
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
package OverloadedObjectClass; |
341
|
|
|
|
|
|
|
|
342
|
15
|
|
|
15
|
|
2386
|
use strict; |
|
15
|
|
|
|
|
26
|
|
|
15
|
|
|
|
|
603
|
|
343
|
|
|
|
|
|
|
use overload ( |
344
|
15
|
|
|
|
|
148
|
'""' => \&as_string, |
345
|
|
|
|
|
|
|
'eq' => \&equals |
346
|
15
|
|
|
15
|
|
62
|
); |
|
15
|
|
|
|
|
29
|
|
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
sub new { |
350
|
2
|
|
|
2
|
|
10
|
return bless { |
351
|
|
|
|
|
|
|
str_value => $_[1] |
352
|
|
|
|
|
|
|
}, $_[0]; |
353
|
|
|
|
|
|
|
} |
354
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
sub as_string { |
357
|
5
|
|
|
5
|
|
62
|
return $_[0]->{str_value}; |
358
|
|
|
|
|
|
|
} |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
sub equals { |
361
|
4
|
|
|
4
|
|
7
|
my ($self, $arg) = @_; |
362
|
|
|
|
|
|
|
|
363
|
4
|
|
|
|
|
8
|
return ($self->as_string eq $arg); |
364
|
|
|
|
|
|
|
} |
365
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
1; |