|
Lines 19-25
Link Here
|
| 19 |
|
19 |
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 31; |
22 |
use Test::More tests => 32; |
| 23 |
use Test::Warn; |
23 |
use Test::Warn; |
| 24 |
use Time::Fake; |
24 |
use Time::Fake; |
| 25 |
use DateTime; |
25 |
use DateTime; |
|
Lines 84-90
subtest 'library' => sub {
Link Here
|
| 84 |
}; |
84 |
}; |
| 85 |
|
85 |
|
| 86 |
subtest 'guarantees' => sub { |
86 |
subtest 'guarantees' => sub { |
| 87 |
plan tests => 8; |
87 |
plan tests => 13; |
| 88 |
my $guarantees = $new_patron_1->guarantees; |
88 |
my $guarantees = $new_patron_1->guarantees; |
| 89 |
is( ref($guarantees), 'Koha::Patrons', 'Koha::Patron->guarantees should return a Koha::Patrons result set in a scalar context' ); |
89 |
is( ref($guarantees), 'Koha::Patrons', 'Koha::Patron->guarantees should return a Koha::Patrons result set in a scalar context' ); |
| 90 |
is( $guarantees->count, 0, 'new_patron_1 should have 0 guarantee' ); |
90 |
is( $guarantees->count, 0, 'new_patron_1 should have 0 guarantee' ); |
|
Lines 102-107
subtest 'guarantees' => sub {
Link Here
|
| 102 |
is( ref(\@guarantees), 'ARRAY', 'Koha::Patron->guarantees should return an array in a list context' ); |
102 |
is( ref(\@guarantees), 'ARRAY', 'Koha::Patron->guarantees should return an array in a list context' ); |
| 103 |
is( scalar(@guarantees), 2, 'new_patron_1 should have 2 guarantees' ); |
103 |
is( scalar(@guarantees), 2, 'new_patron_1 should have 2 guarantees' ); |
| 104 |
$_->delete for @guarantees; |
104 |
$_->delete for @guarantees; |
|
|
105 |
|
| 106 |
#Test return order of guarantees BZ 18635 |
| 107 |
my $categorycode = $builder->build({ source => 'Category' })->{categorycode}; |
| 108 |
my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; |
| 109 |
|
| 110 |
my $guarantor = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 111 |
|
| 112 |
my $order_guarantee1 = $builder->build_object( { class => 'Koha::Patrons' , value => { |
| 113 |
surname => 'Zebra', |
| 114 |
guarantorid => $guarantor->borrowernumber |
| 115 |
} |
| 116 |
})->borrowernumber; |
| 117 |
|
| 118 |
my $order_guarantee2 = $builder->build_object( { class => 'Koha::Patrons' , value => { |
| 119 |
surname => 'Yak', |
| 120 |
guarantorid => $guarantor->borrowernumber |
| 121 |
} |
| 122 |
})->borrowernumber; |
| 123 |
|
| 124 |
my $order_guarantee3 = $builder->build_object( { class => 'Koha::Patrons' , value => { |
| 125 |
surname => 'Xerus', |
| 126 |
firstname => 'Walrus', |
| 127 |
guarantorid => $guarantor->borrowernumber |
| 128 |
} |
| 129 |
})->borrowernumber; |
| 130 |
|
| 131 |
my $order_guarantee4 = $builder->build_object( { class => 'Koha::Patrons' , value => { |
| 132 |
surname => 'Xerus', |
| 133 |
firstname => 'Vulture', |
| 134 |
guarantorid => $guarantor->borrowernumber |
| 135 |
} |
| 136 |
})->borrowernumber; |
| 137 |
|
| 138 |
my $order_guarantee5 = $builder->build_object( { class => 'Koha::Patrons' , value => { |
| 139 |
surname => 'Xerus', |
| 140 |
firstname => 'Unicorn', |
| 141 |
guarantorid => $guarantor->borrowernumber |
| 142 |
} |
| 143 |
})->borrowernumber; |
| 144 |
|
| 145 |
$guarantees = $guarantor->guarantees(); |
| 146 |
|
| 147 |
is( $guarantees->next()->borrowernumber, $order_guarantee5, "Return first guarantor alphabetically" ); |
| 148 |
is( $guarantees->next()->borrowernumber, $order_guarantee4, "Return second guarantor alphabetically" ); |
| 149 |
is( $guarantees->next()->borrowernumber, $order_guarantee3, "Return third guarantor alphabetically" ); |
| 150 |
is( $guarantees->next()->borrowernumber, $order_guarantee2, "Return fourth guarantor alphabetically" ); |
| 151 |
is( $guarantees->next()->borrowernumber, $order_guarantee1, "Return fifth guarantor alphabetically" ); |
| 105 |
}; |
152 |
}; |
| 106 |
|
153 |
|
| 107 |
subtest 'category' => sub { |
154 |
subtest 'category' => sub { |
| 108 |
- |
|
|