Changeset 2539
- Timestamp:
- 06/10/08 22:17:13 (20 months ago)
- Files:
-
- 1 modified
-
branches/release-39/t/driver-tests.pl (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/release-39/t/driver-tests.pl
r2534 r2539 33 33 } 34 34 35 plan tests => 1 97;35 plan tests => 186; 36 36 37 37 package Zot; … … 469 469 { unique => 1, 470 470 sort => 'created_on', 471 direction => 'descend', } ] }), 2, ' count7');471 direction => 'descend', } ] }), 2, 'There are 2 unique Foos associated with Bars'); 472 472 473 473 ## Now load all Foo objects in order of most recently … … 479 479 direction => 'descend', 480 480 unique => 1 } ] }); 481 is(@tmp, 2, 'array length 2'); 482 is($tmp[0]->id, $foo[0]->id, 'id'); 483 is($tmp[1]->id, $foo[1]->id, 'id'); 481 are_objects(\@tmp, \@foo, 'unique Foos associated with Bars, oldest first'); 484 482 485 483 ## Load all Foo objects in order of most recently … … 490 488 { sort => 'created_on', 491 489 direction => 'descend', } ] }); 492 is(@tmp, 3, 'array length 3'); 493 is($tmp[0]->id, $foo[0]->id, 'id'); 494 is($tmp[1]->id, $foo[1]->id, 'id'); 495 is($tmp[2]->id, $foo[1]->id, 'id'); 490 are_objects(\@tmp, [ @foo, $foo[1] ], 'Foos associated with Bars, oldest first'); 496 491 497 492 ## Load last 1 Foo object in order of most recently … … 504 499 unique => 1, 505 500 limit => 1, } ] }); 506 is(@tmp, 1, 'array length 1 with join'); 507 is($tmp[0]->id, $foo[0]->id, 'id'); 501 are_objects(\@tmp, [ $foo[0] ], 'Foos associated with oldest Bar'); 508 502 509 503 ## Load all Foo objects where Bar.name = 'bar0' … … 514 508 direction => 'descend', 515 509 unique => 1, } ] }); 516 is(@tmp, 1, 'array length 1 with join, limit by name'); 517 is($tmp[0]->id, $foo[1]->id, 'id'); 510 are_objects(\@tmp, [ $foo[1] ], 'Foos associated with Bars named bar0'); 518 511 519 512 ## foo[1] is older than foo[0] because we overrode the timestamp, … … 522 515 { sort => 'created_on', direction => 'descend', limit => 1, 523 516 join => [ 'Bar', 'foo_id', { status => 0 }, { unique => 1 } ] }); 524 is(@tmp, 1, 'array length 1'); 525 is($tmp[0]->id, $foo[0]->id, 'id'); 517 are_objects(\@tmp, [ $foo[0] ], 'One Foo associated with Bars of status=0'); 526 518 527 519 ## This is the same join as the last one, but without the limit--so … … 530 522 { sort => 'created_on', direction => 'descend', 531 523 join => [ 'Bar', 'foo_id', { status => 0 }, { unique => 1 } ] }); 532 is(@tmp, 2, 'array length 2'); 533 is($tmp[0]->id, $foo[0]->id, 'id'); 534 is($tmp[1]->id, $foo[1]->id, 'id'); 524 are_objects(\@tmp, \@foo, 'All Foos associated with Bars of status=0'); 535 525 536 526 ## Filter join results by providing a value for 'status'; only Foo[0] … … 539 529 { sort => 'created_on', direction => 'descend', 540 530 join => [ 'Bar', 'foo_id', { status => 0 }, { unique => 1 } ] }); 541 is(@tmp, 1, 'array length 1'); 542 is($tmp[0]->id, $foo[0]->id, 'id'); 531 are_objects(\@tmp, [ $foo[0] ], 'Foos of status=2 associated with Bars of status=0'); 543 532 544 533 # Join across a column. … … 554 543 555 544 ## TEST EXISTS METHOD 556 ok($foo [0]->exists, 'exists');545 ok($foo->exists, 'First Foo long saved exists in db'); 557 546 $tmp = Foo->new; 558 ok(!$tmp->exists, ' does not exist');547 ok(!$tmp->exists, 'New Foo just created does not exist in db'); 559 548 $tmp->id(5); 560 ok(!$tmp->exists, ' does not exist');549 ok(!$tmp->exists, 'New Foo just created with fake id does not exist in db'); 561 550 562 551 ## Change foo[1]->status so that its value is unique (for index)
