2 |
use strict; |
use strict; |
3 |
use warnings; |
use warnings; |
4 |
|
|
5 |
my $debug = shift @ARGV; |
my $debug = @ARGV ? 1 : 0; |
6 |
|
|
7 |
use Test::More tests => 8; |
use Test::More tests => 10; |
8 |
use lib 'lib'; |
use lib 'lib'; |
9 |
|
|
10 |
#use Devel::LeakTrace::Fast; |
#use Devel::LeakTrace::Fast; |
12 |
|
|
13 |
BEGIN { |
BEGIN { |
14 |
use_ok('Strix::User'); |
use_ok('Strix::User'); |
15 |
|
use_ok('Frey::Pager'); |
16 |
} |
} |
17 |
|
|
18 |
ok( my $u = Strix::User->new( id => 1 ), 'new' ); |
ok( my $u = Strix::User->new( id => 1 ), 'new' ); |
20 |
|
|
21 |
diag dump( $u ) if $debug; |
diag dump( $u ) if $debug; |
22 |
|
|
23 |
ok( my $i = $u->collection( { per_page => 2 } ), 'collection' ); |
ok( my $i = $u->collection(), 'collection without pager' ); |
24 |
isa_ok( $i, 'Fey::Object::Iterator' ); |
isa_ok( $i, 'Fey::Object::Iterator' ); |
25 |
|
|
26 |
diag dump( $i ) if $debug; |
diag dump( $i ) if $debug; |
27 |
|
|
28 |
ok( my $r = $u->total_rows, 'total_rows' ); |
ok( my $r = $u->total_entries, 'total_entries' ); |
29 |
diag "total_rows: $r"; # if $debug; |
diag "total_entries: $r"; # if $debug; |
30 |
|
|
31 |
|
my $max = 3; |
32 |
|
|
33 |
while ( my $row = $i->next ) { |
while ( my $row = $i->next ) { |
34 |
isa_ok( $row, 'Strix::User' ); |
isa_ok( $row, 'Strix::User' ); |
35 |
|
last if --$max == 0; |
36 |
} |
} |
37 |
|
|