Lines 17-28
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 6; |
20 |
use Test::More tests => 9; |
21 |
|
21 |
|
22 |
use t::lib::TestBuilder; |
22 |
use t::lib::TestBuilder; |
23 |
|
23 |
|
24 |
use C4::Acquisition qw( NewBasket ); |
24 |
use C4::Acquisition qw( NewBasket ); |
25 |
use C4::Biblio qw( AddBiblio ); |
25 |
use C4::Biblio qw( AddBiblio ); |
|
|
26 |
use C4::Contract qw( AddContract ); |
26 |
use C4::Budgets qw( AddBudgetPeriod AddBudget ); |
27 |
use C4::Budgets qw( AddBudgetPeriod AddBudget ); |
27 |
use C4::Serials qw( NewSubscription SearchSubscriptions ); |
28 |
use C4::Serials qw( NewSubscription SearchSubscriptions ); |
28 |
|
29 |
|
Lines 168-173
subtest '->contacts() tests' => sub {
Link Here
|
168 |
} |
169 |
} |
169 |
); |
170 |
); |
170 |
|
171 |
|
|
|
172 |
# Ensure contacts aren't being duplicated on store |
173 |
$vendor->contacts( [ $contact_1->unblessed, $contact_2->unblessed ] ); |
174 |
|
171 |
# Re-fetch vendor |
175 |
# Re-fetch vendor |
172 |
$vendor = Koha::Acquisition::Booksellers->find( $vendor->id ); |
176 |
$vendor = Koha::Acquisition::Booksellers->find( $vendor->id ); |
173 |
my $contacts = $vendor->contacts; |
177 |
my $contacts = $vendor->contacts; |
Lines 257-259
subtest 'issues' => sub {
Link Here
|
257 |
|
261 |
|
258 |
$schema->storage->txn_rollback(); |
262 |
$schema->storage->txn_rollback(); |
259 |
}; |
263 |
}; |
260 |
- |
264 |
|
|
|
265 |
subtest 'contracts' => sub { |
266 |
|
267 |
plan tests => 2; |
268 |
|
269 |
$schema->storage->txn_begin(); |
270 |
|
271 |
my $vendor = $builder->build_object( { class => 'Koha::Acquisition::Booksellers' } ); |
272 |
|
273 |
is( scalar( @{ $vendor->contracts } ), 0, 'Vendor has no contracts' ); |
274 |
|
275 |
AddContract( |
276 |
{ |
277 |
booksellerid => $vendor->id, |
278 |
contractname => 'Test contract', |
279 |
} |
280 |
); |
281 |
|
282 |
$vendor = $vendor->get_from_storage; |
283 |
my $contracts = $vendor->contracts; |
284 |
is( scalar( @{$contracts} ), 1, '1 contract stored' ); |
285 |
|
286 |
$schema->storage->txn_rollback(); |
287 |
}; |
288 |
|
289 |
subtest 'invoices' => sub { |
290 |
|
291 |
plan tests => 3; |
292 |
|
293 |
$schema->storage->txn_begin(); |
294 |
|
295 |
my $vendor = $builder->build_object( { class => 'Koha::Acquisition::Booksellers' } ); |
296 |
|
297 |
is( $vendor->invoices->count, 0, 'Vendor has no invoices' ); |
298 |
|
299 |
Koha::Acquisition::Invoice->new( |
300 |
{ |
301 |
booksellerid => $vendor->id, |
302 |
invoicenumber => 'INV12345' |
303 |
} |
304 |
)->store; |
305 |
|
306 |
$vendor = $vendor->get_from_storage; |
307 |
my $invoices = $vendor->invoices; |
308 |
is( $invoices->count, 1, '1 invoice stored' ); |
309 |
is( ref($invoices), 'Koha::Acquisition::Invoices', 'Type is correct' ); |
310 |
|
311 |
$schema->storage->txn_rollback(); |
312 |
}; |
313 |
|
314 |
subtest 'to_api() tests' => sub { |
315 |
|
316 |
plan tests => 4; |
317 |
|
318 |
$schema->storage->txn_begin; |
319 |
|
320 |
my $vendor = $builder->build_object( { class => 'Koha::Acquisition::Booksellers' } ); |
321 |
|
322 |
is( $vendor->interfaces->count, 0, 'Vendor has no interfaces' ); |
323 |
|
324 |
$vendor->interfaces( |
325 |
[ { name => 'first interface' }, { name => 'second interface', login => 'one_login', password => 'Test1234' } ] |
326 |
); |
327 |
|
328 |
my $interfaces = $vendor->to_api->{interfaces}; |
329 |
is( scalar(@$interfaces), 2, 'Vendor has two interfaces' ); |
330 |
is( @{$interfaces}[0]->{password}, undef, 'No password set for the interface' ); |
331 |
is( @{$interfaces}[1]->{password}, 'Test1234', 'password is unhashed' ); |
332 |
|
333 |
$schema->storage->txn_rollback; |
334 |
}; |