Lines 17-29
use C4::Items;
Link Here
|
17 |
use Koha::DateUtils; |
17 |
use Koha::DateUtils; |
18 |
use Koha::Acquisition::Booksellers; |
18 |
use Koha::Acquisition::Booksellers; |
19 |
use t::lib::Mocks; |
19 |
use t::lib::Mocks; |
|
|
20 |
use Test::More tests => 50; |
20 |
use t::lib::TestBuilder; |
21 |
use t::lib::TestBuilder; |
21 |
use Test::More tests => 48; |
|
|
22 |
|
22 |
|
23 |
BEGIN { |
23 |
BEGIN { |
24 |
use_ok('C4::Serials'); |
24 |
use_ok('C4::Serials'); |
25 |
} |
25 |
} |
26 |
|
26 |
|
|
|
27 |
my $builder = t::lib::TestBuilder->new; |
27 |
my $dbh = C4::Context->dbh; |
28 |
my $dbh = C4::Context->dbh; |
28 |
|
29 |
|
29 |
# Start transaction |
30 |
# Start transaction |
Lines 351-356
subtest "Do not generate an expected if one already exists" => sub {
Link Here
|
351 |
is( @serialsByStatus, 1, "ModSerialStatus delete corectly serial expected and not create another if exists" ); |
352 |
is( @serialsByStatus, 1, "ModSerialStatus delete corectly serial expected and not create another if exists" ); |
352 |
}; |
353 |
}; |
353 |
|
354 |
|
|
|
355 |
subtest "Test GetSerialItemsInformations " => sub { |
356 |
plan tests => 4; |
357 |
is (C4::Serials::GetSerialItemsInformations(),0,"test GetSerialItemsInformation with nothing parameters "); |
358 |
my $branchcode = $builder->build({ source => 'Branch' })->{ branchcode }; |
359 |
my $itemtype = $builder->build({ source => 'Itemtype' })->{ itemtype }; |
360 |
my %item_infos = ( |
361 |
homebranch => $branchcode, |
362 |
holdingbranch => $branchcode, |
363 |
itype => $itemtype |
364 |
); |
365 |
my $biblionumber1 = AddBiblio(MARC::Record->new, ''); |
366 |
my $itemnumber1 = AddItem({ barcode => '0101', %item_infos }, $biblionumber1); |
367 |
my $itemnumber2 = AddItem({ barcode => '0102', %item_infos }, $biblionumber1); |
368 |
my $itemnumber3 = AddItem({ barcode => '0103', %item_infos }, $biblionumber1); |
369 |
my $itemnumber4 = AddItem({ barcode => '0104', %item_infos }, $biblionumber1); |
370 |
my @serialid = ($serials[0]->{serialid},$serials[1]->{serialid}); |
371 |
is (C4::Serials::GetSerialItemsInformations(@serialid),0,"test GetSerialItemsInformation with array of serialid and none have items"); |
372 |
subtest "Test with 2 serials and each have one item" => sub { |
373 |
plan tests => 5; |
374 |
AddItem2Serial($serialid[0],$itemnumber1); |
375 |
my @result = C4::Serials::GetSerialItemsInformations(@serialid); |
376 |
is (scalar @result, 1 , "GetSerialItemsInformation return right length of array using 1 serial with 1 item"); |
377 |
is (@result[0]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial1"); |
378 |
AddItem2Serial($serialid[1],$itemnumber3); |
379 |
@result = C4::Serials::GetSerialItemsInformations(@serialid); |
380 |
is (scalar @result, 2 , "GetSerialItemsInformation return right length of array using 2 serials and each have 1 item"); |
381 |
is (@result[0]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial1"); |
382 |
is (@result[1]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial2"); |
383 |
}; |
384 |
subtest "Test with 2 serials and each have 2 items" => sub { |
385 |
plan tests => 6; |
386 |
AddItem2Serial($serialid[0],$itemnumber2); |
387 |
my @result = C4::Serials::GetSerialItemsInformations(@serialid); |
388 |
is (scalar @result, 2 , "GetSerialItemsInformation return right length of array using 2 serials "); |
389 |
is (@result[0]->{countitems}, 2 , "GetSerialItemsInformation return right number items of serial1"); |
390 |
is (@result[1]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial2"); |
391 |
AddItem2Serial($serialid[1],$itemnumber4); |
392 |
@result = C4::Serials::GetSerialItemsInformations(@serialid); |
393 |
is (scalar @result, 2 , "GetSerialItemsInformation return right length of array using 2 serials and each have 2 items "); |
394 |
is (@result[0]->{countitems}, 2 , "GetSerialItemsInformation return right number items of serial1"); |
395 |
is (@result[1]->{countitems}, 2 , "GetSerialItemsInformation return right number items of serial2"); |
396 |
}; |
397 |
}; |
398 |
|
354 |
$dbh->rollback; |
399 |
$dbh->rollback; |
355 |
|
400 |
|
356 |
sub get_biblio { |
401 |
sub get_biblio { |
357 |
- |
|
|