Changeset 2154
- Timestamp:
- 04/29/08 22:54:19 (7 months ago)
- Files:
-
- branches/release-36/t/driver-tests.pl (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/release-36/t/driver-tests.pl
r2153 r2154 30 30 } 31 31 32 use constant TESTS => 2 45;32 use constant TESTS => 261; 33 33 34 34 use Test::More; … … 267 267 direction => 'ascend', 268 268 start_val => $foo[0]->created_on }); 269 isa_ok($tmp, 'Foo'); 270 is($tmp->id, $foo[1]->id, 'id'); 269 is_object($tmp, $foo[1], 'Next newer Foo after Foo #1'); 271 270 272 271 ## Given the first Foo object, try to load the "previous" one … … 277 276 direction => 'descend', 278 277 start_val => $foo[0]->created_on }); 279 ok(!$tmp, ' no Foo');278 ok(!$tmp, 'Search for next older Foo before Foo #1 found none'); 280 279 281 280 ## Given the second Foo object, try to load the "previous" one … … 286 285 direction => 'descend', 287 286 start_val => $foo[1]->created_on }); 288 isa_ok($tmp, 'Foo'); 289 is($tmp->id, $foo[0]->id, 'id'); 287 is_object($tmp, $foo[0], 'Next older Foo before Foo #2'); 290 288 291 289 ## Given the second Foo object, try to load the "next" one 292 ## (the one with a larger created_on time). This should work.290 ## (the one with a larger created_on time). This should fail. 293 291 $tmp = Foo->load(undef, { 294 292 limit => 1, … … 296 294 direction => 'ascend', 297 295 start_val => $foo[1]->created_on }); 298 ok(!$tmp, ' no Foo');296 ok(!$tmp, 'Search for next newer Foo after Foo #2 found none'); 299 297 300 298 ## Now, given the second Foo object's created_on - 1, try to … … 305 303 direction => 'descend', 306 304 start_val => $foo[1]->created_on-1 }); 307 isa_ok($tmp, 'Foo'); 308 is($tmp->id, $foo[0]->id, 'id'); 305 is_object($tmp, $foo[0], 'Next older Foo before just before Foo #2'); 309 306 310 307 ## Now, given the second Foo object's created_on - 1, try to … … 315 312 direction => 'ascend', 316 313 start_val => $foo[1]->created_on-1 }); 317 isa_ok($tmp, 'Foo'); 318 is($tmp->id, $foo[1]->id, 'id'); 314 is_object($tmp, $foo[1], 'Next newer Foo after just before Foo #2'); 319 315 320 316 ## Override created_on timestamp, make sure it works … … 322 318 $foo[1]->created_on($ts); 323 319 $foo[1]->save; 320 324 321 @tmp = Foo->load(undef, { 325 322 sort => 'created_on', 326 323 direction => 'descend', 327 324 limit => 2 }); 328 is(@tmp, 2, 'array length 2'); 329 is($tmp[0]->id, 1, 'id'); 330 is($tmp[1]->id, 2, 'id'); 325 are_objects(\@tmp, \@foo, 'Time-traveled Foos newest-first'); 331 326 332 327 ## Test limit of 2 with direction descend, but without … … 336 331 direction => 'descend', 337 332 limit => 2 }); 338 is(@tmp, 2, 'array length 2'); 339 is($tmp[0]->id, $foo[1]->id, 'id'); 340 is($tmp[1]->id, $foo[0]->id, 'id'); 333 are_objects(\@tmp, [ reverse @foo ], 'Foos highest-id-first'); 341 334 342 335 ## Test loading using offset. … … 347 340 limit => 1, 348 341 offset => 1 }); 349 isa_ok($tmp, 'Foo'); 350 is($tmp->id, $foo[1]->id, 'id'); 342 is_object($tmp, $foo[1], 'Second newest Foo'); 351 343 352 344 ## We only have 2 Foo objects, so this should load … … 357 349 limit => 2, 358 350 offset => 1 }); 359 is(@tmp, 1, 'array length 1'); 360 is($tmp[0]->id, $foo[1]->id, 'id'); 351 are_objects(\@tmp, [ $foo[1] ], 'Second and third newest Foos'); 361 352 362 353 ## Should load the first Foo object (ascend with offset of 1). … … 366 357 limit => 1, 367 358 offset => 1 }); 368 isa_ok($tmp, 'Foo'); 369 is($tmp->id, 1, 'id'); 359 is_object($tmp, $foo[0], 'Second oldest Foo'); 370 360 371 361 ## Now test join loads.
