|
Lines 98-110
my $item = $builder->build_object(
Link Here
|
| 98 |
AddIssue( $patron, $item->barcode ); |
98 |
AddIssue( $patron, $item->barcode ); |
| 99 |
|
99 |
|
| 100 |
is( |
100 |
is( |
| 101 |
ItemSafeToDelete( $biblio->{biblionumber}, $item->itemnumber ), |
101 |
$item->safe_to_delete, |
| 102 |
'book_on_loan', |
102 |
'book_on_loan', |
| 103 |
'ItemSafeToDelete reports item on loan', |
103 |
'Koha::Item->safe_to_delete reports item on loan', |
| 104 |
); |
104 |
); |
| 105 |
|
105 |
|
| 106 |
is( |
106 |
is( |
| 107 |
DelItemCheck( $biblio->{biblionumber}, $item->itemnumber ), |
107 |
$item->safe_delete, |
| 108 |
'book_on_loan', |
108 |
'book_on_loan', |
| 109 |
'item that is on loan cannot be deleted', |
109 |
'item that is on loan cannot be deleted', |
| 110 |
); |
110 |
); |
|
Lines 118-130
t::lib::Mocks::mock_preference('IndependentBranches', 1);
Link Here
|
| 118 |
$item->set( { homebranch => $branch2->{branchcode}, holdingbranch => $branch2->{branchcode} })->store; |
118 |
$item->set( { homebranch => $branch2->{branchcode}, holdingbranch => $branch2->{branchcode} })->store; |
| 119 |
|
119 |
|
| 120 |
is( |
120 |
is( |
| 121 |
ItemSafeToDelete( $biblio->{biblionumber}, $item->itemnumber ), |
121 |
$item->safe_to_delete, |
| 122 |
'not_same_branch', |
122 |
'not_same_branch', |
| 123 |
'ItemSafeToDelete reports IndependentBranches restriction', |
123 |
'Koha::Item->safe_to_delete reports IndependentBranches restriction', |
| 124 |
); |
124 |
); |
| 125 |
|
125 |
|
| 126 |
is( |
126 |
is( |
| 127 |
DelItemCheck( $biblio->{biblionumber}, $item->itemnumber ), |
127 |
$item->safe_delete, |
| 128 |
'not_same_branch', |
128 |
'not_same_branch', |
| 129 |
'IndependentBranches prevents deletion at another branch', |
129 |
'IndependentBranches prevents deletion at another branch', |
| 130 |
); |
130 |
); |
|
Lines 139-151
$item->set( { homebranch => $branch->{branchcode}, holdingbranch => $branch->{br
Link Here
|
| 139 |
$module->mock( GetAnalyticsCount => sub { return 1 } ); |
139 |
$module->mock( GetAnalyticsCount => sub { return 1 } ); |
| 140 |
|
140 |
|
| 141 |
is( |
141 |
is( |
| 142 |
ItemSafeToDelete( $biblio->{biblionumber}, $item->itemnumber ), |
142 |
$item->safe_to_delete, |
| 143 |
'linked_analytics', |
143 |
'linked_analytics', |
| 144 |
'ItemSafeToDelete reports linked analytics', |
144 |
'Koha::Item->safe_to_delete reports linked analytics', |
| 145 |
); |
145 |
); |
| 146 |
|
146 |
|
| 147 |
is( |
147 |
is( |
| 148 |
DelItemCheck( $biblio->{biblionumber}, $item->itemnumber ), |
148 |
$item->safe_delete, |
| 149 |
'linked_analytics', |
149 |
'linked_analytics', |
| 150 |
'Linked analytics prevents deletion of item', |
150 |
'Linked analytics prevents deletion of item', |
| 151 |
); |
151 |
); |
|
Lines 153-169
$item->set( { homebranch => $branch->{branchcode}, holdingbranch => $branch->{br
Link Here
|
| 153 |
} |
153 |
} |
| 154 |
|
154 |
|
| 155 |
is( |
155 |
is( |
| 156 |
ItemSafeToDelete( $biblio->{biblionumber}, $item->itemnumber ), |
156 |
$item->safe_to_delete, |
| 157 |
1, |
157 |
1, |
| 158 |
'ItemSafeToDelete shows item safe to delete' |
158 |
'Koha::Item->safe_to_delete shows item safe to delete' |
| 159 |
); |
159 |
); |
| 160 |
|
160 |
|
| 161 |
DelItemCheck( $biblio->{biblionumber}, $item->itemnumber ); |
161 |
$item->safe_delete, |
| 162 |
|
162 |
|
| 163 |
my $test_item = Koha::Items->find( $item->itemnumber ); |
163 |
my $test_item = Koha::Items->find( $item->itemnumber ); |
| 164 |
|
164 |
|
| 165 |
is( $test_item, undef, |
165 |
is( $test_item, undef, |
| 166 |
"DelItemCheck should delete item if ItemSafeToDelete returns true" |
166 |
"Koha::Item->safe_delete should delete item if safe_to_delete returns true" |
| 167 |
); |
167 |
); |
| 168 |
|
168 |
|
| 169 |
$schema->storage->txn_rollback; |
169 |
$schema->storage->txn_rollback; |