|
Lines 19-25
Link Here
|
| 19 |
|
19 |
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 12; |
22 |
use Test::More tests => 13; |
| 23 |
use Test::Exception; |
23 |
use Test::Exception; |
| 24 |
use Test::MockModule; |
24 |
use Test::MockModule; |
| 25 |
|
25 |
|
|
Lines 105-110
subtest 'item() tests' => sub {
Link Here
|
| 105 |
$schema->storage->txn_rollback; |
105 |
$schema->storage->txn_rollback; |
| 106 |
}; |
106 |
}; |
| 107 |
|
107 |
|
|
|
108 |
subtest 'library() tests' => sub { |
| 109 |
|
| 110 |
plan tests => 4; |
| 111 |
|
| 112 |
$schema->storage->txn_begin; |
| 113 |
|
| 114 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 115 |
my $patron = $builder->build( { source => 'Borrower' } ); |
| 116 |
|
| 117 |
my $line = Koha::Account::Line->new( |
| 118 |
{ |
| 119 |
borrowernumber => $patron->{borrowernumber}, |
| 120 |
branchcode => $library->branchcode, |
| 121 |
debit_type_code => "OVERDUE", |
| 122 |
status => "RETURNED", |
| 123 |
amount => 10, |
| 124 |
interface => 'commandline', |
| 125 |
} |
| 126 |
)->store; |
| 127 |
|
| 128 |
my $account_line_library = $line->library; |
| 129 |
is( ref($account_line_library), |
| 130 |
'Koha::Library', |
| 131 |
'Koha::Account::Line->library should return a Koha::Library' ); |
| 132 |
is( |
| 133 |
$line->branchcode, |
| 134 |
$account_line_library->branchcode, |
| 135 |
'Koha::Account::Line->library should return the correct library' |
| 136 |
); |
| 137 |
|
| 138 |
# Test ON DELETE SET NULL |
| 139 |
$library->delete; |
| 140 |
my $found = Koha::Account::Lines->find( $line->accountlines_id ); |
| 141 |
ok( $found, "Koha::Account::Line not deleted when the linked library is deleted" ); |
| 142 |
|
| 143 |
is( $found->library, undef, |
| 144 |
'Koha::Account::Line->library should return undef if linked library has been deleted' |
| 145 |
); |
| 146 |
|
| 147 |
$schema->storage->txn_rollback; |
| 148 |
}; |
| 149 |
|
| 108 |
subtest 'is_credit() and is_debit() tests' => sub { |
150 |
subtest 'is_credit() and is_debit() tests' => sub { |
| 109 |
|
151 |
|
| 110 |
plan tests => 4; |
152 |
plan tests => 4; |
| 111 |
- |
|
|