|
Lines 16-27
use C4::Biblio;
Link Here
|
| 16 |
use C4::Budgets; |
16 |
use C4::Budgets; |
| 17 |
use Koha::DateUtils; |
17 |
use Koha::DateUtils; |
| 18 |
use t::lib::Mocks; |
18 |
use t::lib::Mocks; |
| 19 |
use Test::More tests => 48; |
19 |
use t::lib::TestBuilder; |
|
|
20 |
use C4::Items; |
| 21 |
use Test::More tests => 49; |
| 20 |
|
22 |
|
| 21 |
BEGIN { |
23 |
BEGIN { |
| 22 |
use_ok('C4::Serials'); |
24 |
use_ok('C4::Serials'); |
| 23 |
} |
25 |
} |
| 24 |
|
26 |
|
|
|
27 |
my $builder = t::lib::TestBuilder->new; |
| 25 |
my $dbh = C4::Context->dbh; |
28 |
my $dbh = C4::Context->dbh; |
| 26 |
|
29 |
|
| 27 |
# Start transaction |
30 |
# Start transaction |
|
Lines 316-319
subtest "Do not generate an expected if one already exists" => sub {
Link Here
|
| 316 |
is( @serialsByStatus, 1, "ModSerialStatus delete corectly serial expected and not create another if exists" ); |
319 |
is( @serialsByStatus, 1, "ModSerialStatus delete corectly serial expected and not create another if exists" ); |
| 317 |
}; |
320 |
}; |
| 318 |
|
321 |
|
|
|
322 |
subtest "Test GetSerialItemsInformations " => sub { |
| 323 |
plan tests => 4; |
| 324 |
is (C4::Serials::GetSerialItemsInformations(),0,"test GetSerialItemsInformation with nothing parameters "); |
| 325 |
my $branchcode = $builder->build({ source => 'Branch' })->{ branchcode }; |
| 326 |
my $itemtype = $builder->build({ source => 'Itemtype' })->{ itemtype }; |
| 327 |
my %item_infos = ( |
| 328 |
homebranch => $branchcode, |
| 329 |
holdingbranch => $branchcode, |
| 330 |
itype => $itemtype |
| 331 |
); |
| 332 |
my $biblionumber1 = AddBiblio(MARC::Record->new, ''); |
| 333 |
my $itemnumber1 = AddItem({ barcode => '0101', %item_infos }, $biblionumber1); |
| 334 |
my $itemnumber2 = AddItem({ barcode => '0102', %item_infos }, $biblionumber1); |
| 335 |
my $itemnumber3 = AddItem({ barcode => '0103', %item_infos }, $biblionumber1); |
| 336 |
my $itemnumber4 = AddItem({ barcode => '0104', %item_infos }, $biblionumber1); |
| 337 |
my @serialid = ($serials[0]->{serialid},$serials[1]->{serialid}); |
| 338 |
is (C4::Serials::GetSerialItemsInformations(@serialid),0,"test GetSerialItemsInformation with array of serialid and none have items"); |
| 339 |
subtest "Test with 2 serials and each have one item" => sub { |
| 340 |
plan tests => 5; |
| 341 |
AddItem2Serial($serialid[0],$itemnumber1); |
| 342 |
my @result = C4::Serials::GetSerialItemsInformations(@serialid); |
| 343 |
is (scalar @result, 1 , "GetSerialItemsInformation return right length of array using 1 serial with 1 item"); |
| 344 |
is (@result[0]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial1"); |
| 345 |
AddItem2Serial($serialid[1],$itemnumber3); |
| 346 |
@result = C4::Serials::GetSerialItemsInformations(@serialid); |
| 347 |
is (scalar @result, 2 , "GetSerialItemsInformation return right length of array using 2 serials and each have 1 item"); |
| 348 |
is (@result[0]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial1"); |
| 349 |
is (@result[1]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial2"); |
| 350 |
}; |
| 351 |
subtest "Test with 2 serials and each have 2 items" => sub { |
| 352 |
plan tests => 6; |
| 353 |
AddItem2Serial($serialid[0],$itemnumber2); |
| 354 |
my @result = C4::Serials::GetSerialItemsInformations(@serialid); |
| 355 |
is (scalar @result, 2 , "GetSerialItemsInformation return right length of array using 2 serials "); |
| 356 |
is (@result[0]->{countitems}, 2 , "GetSerialItemsInformation return right number items of serial1"); |
| 357 |
is (@result[1]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial2"); |
| 358 |
AddItem2Serial($serialid[1],$itemnumber4); |
| 359 |
@result = C4::Serials::GetSerialItemsInformations(@serialid); |
| 360 |
is (scalar @result, 2 , "GetSerialItemsInformation return right length of array using 2 serials and each have 2 items "); |
| 361 |
is (@result[0]->{countitems}, 2 , "GetSerialItemsInformation return right number items of serial1"); |
| 362 |
is (@result[1]->{countitems}, 2 , "GetSerialItemsInformation return right number items of serial2"); |
| 363 |
}; |
| 364 |
}; |
| 365 |
|
| 319 |
$dbh->rollback; |
366 |
$dbh->rollback; |
| 320 |
- |
|
|