Changeset 2500 for branches/release-39/t/driver-tests.pl
- Timestamp:
- 06/04/08 01:21:49 (18 months ago)
- Files:
-
- 1 modified
-
branches/release-39/t/driver-tests.pl (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/release-39/t/driver-tests.pl
r2475 r2500 33 33 } 34 34 35 plan tests => 1 84;35 plan tests => 197; 36 36 37 37 package Zot; … … 400 400 sleep(2); ## Sleep to ensure created_on timestamps are unique 401 401 402 # legacy way of specifying sort direction 402 403 my $cgb_iter = Bar->count_group_by({ 403 404 status => '0', 404 405 }, { 405 406 group => [ 'foo_id' ], 406 sort => 'foo_id', 407 direction => 'descend', 407 sort => 'foo_id desc', 408 408 }); 409 409 my ($count, $bfid, $month); … … 417 417 ok(!$cgb_iter->(), 'no $iter'); 418 418 419 $cgb_iter = Bar->count_group_by(undef, { 419 # new way of specifying sort direction 420 my $cgb_iter2 = Bar->count_group_by({ 421 status => '0', 422 }, { 423 group => [ 'foo_id' ], 424 sort => 'foo_id', 425 direction => 'descend' 426 }); 427 428 isa_ok($cgb_iter2, 'CODE'); 429 ok(($count, $bfid) = $cgb_iter2->(), 'set'); 430 is($bfid, $bar[1]->id, 'id'); 431 is($count, 1, 'count4'); 432 ok(($count, $bfid) = $cgb_iter2->(), 'set'); 433 is($bfid, $bar[0]->id, 'id'); 434 is($count, 1, 'count5'); 435 ok(!$cgb_iter2->(), 'no $iter'); 436 437 # legacy way of specifying sort direction 438 my $cgb_iter3 = Bar->count_group_by(undef, { 420 439 group => [ 'extract(month from created_on)' ], 421 sort => 'extract(month from created_on)', 422 direction => 'descend', 440 sort => 'extract(month from created_on) desc', 423 441 }); 424 isa_ok($cgb_iter , 'CODE');425 ok(($count, $month) = $cgb_iter ->(), 'set');442 isa_ok($cgb_iter3, 'CODE'); 443 ok(($count, $month) = $cgb_iter3->(), 'set'); 426 444 use POSIX qw(strftime); 427 445 is(int($month), int(strftime("%m", localtime)), 'month'); 428 446 is($count, 3, 'count6'); 429 ok(!$cgb_iter->(), 'no $iter'); 447 ok(!$cgb_iter3->(), 'no $iter'); 448 449 # new way of specifying sort direction 450 my $cgb_iter4 = Bar->count_group_by(undef, { 451 group => [ 'extract(month from created_on)' ], 452 sort => [{ column => 'extract(month from created_on)', 453 desc => 'desc' }] 454 }); 455 isa_ok($cgb_iter4, 'CODE'); 456 ok(($count, $month) = $cgb_iter4->(), 'set'); 457 is(int($month), int(strftime("%m", localtime)), 'month'); 458 is($count, 3, 'count6'); 459 ok(!$cgb_iter4->(), 'no $iter'); 430 460 431 461 ## Get a count of all Foo objects in order of most recently
