Bug 19444: (QA follow-up) Fix tests for UNIMARC
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
25e050e2ef
commit
4a439d0528
1 changed files with 32 additions and 46 deletions
|
@ -222,14 +222,8 @@ C4::Context->dbh->do("DELETE FROM accountlines");
|
||||||
# CanBookBeRenewed tests
|
# CanBookBeRenewed tests
|
||||||
|
|
||||||
# Generate test biblio
|
# Generate test biblio
|
||||||
my $biblio = MARC::Record->new();
|
|
||||||
my $title = 'Silence in the library';
|
my $title = 'Silence in the library';
|
||||||
$biblio->append_fields(
|
my ($biblionumber, $biblioitemnumber) = add_biblio($title, 'Moffat, Steven');
|
||||||
MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'),
|
|
||||||
MARC::Field->new('245', ' ', ' ', a => $title),
|
|
||||||
);
|
|
||||||
|
|
||||||
my ($biblionumber, $biblioitemnumber) = AddBiblio($biblio, '');
|
|
||||||
|
|
||||||
my $barcode = 'R00000342';
|
my $barcode = 'R00000342';
|
||||||
my $branch = $library2->{branchcode};
|
my $branch = $library2->{branchcode};
|
||||||
|
@ -911,13 +905,8 @@ C4::Context->dbh->do("DELETE FROM accountlines");
|
||||||
my $branch = $library2->{branchcode};
|
my $branch = $library2->{branchcode};
|
||||||
|
|
||||||
#Create another record
|
#Create another record
|
||||||
my $biblio2 = MARC::Record->new();
|
|
||||||
my $title2 = 'Something is worng here';
|
my $title2 = 'Something is worng here';
|
||||||
$biblio2->append_fields(
|
my ($biblionumber2, $biblioitemnumber2) = add_biblio($title2, 'Anonymous');
|
||||||
MARC::Field->new('100', ' ', ' ', a => 'Anonymous'),
|
|
||||||
MARC::Field->new('245', ' ', ' ', a => $title2),
|
|
||||||
);
|
|
||||||
my ($biblionumber2, $biblioitemnumber2) = AddBiblio($biblio2, '');
|
|
||||||
|
|
||||||
#Create third item
|
#Create third item
|
||||||
AddItem(
|
AddItem(
|
||||||
|
@ -996,8 +985,7 @@ C4::Context->dbh->do("DELETE FROM accountlines");
|
||||||
my $barcode = '1234567890';
|
my $barcode = '1234567890';
|
||||||
my $branch = $library2->{branchcode};
|
my $branch = $library2->{branchcode};
|
||||||
|
|
||||||
my $biblio = MARC::Record->new();
|
my ($biblionumber, $biblioitemnumber) = add_biblio();
|
||||||
my ($biblionumber, $biblioitemnumber) = AddBiblio($biblio, '');
|
|
||||||
|
|
||||||
#Create third item
|
#Create third item
|
||||||
my ( undef, undef, $itemnumber ) = AddItem(
|
my ( undef, undef, $itemnumber ) = AddItem(
|
||||||
|
@ -1054,8 +1042,7 @@ C4::Context->dbh->do("DELETE FROM accountlines");
|
||||||
undef, 0,
|
undef, 0,
|
||||||
.10, 1
|
.10, 1
|
||||||
);
|
);
|
||||||
my $biblio = MARC::Record->new();
|
my ( $biblionumber, $biblioitemnumber ) = add_biblio();
|
||||||
my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $biblio, '' );
|
|
||||||
|
|
||||||
my $barcode1 = '1234';
|
my $barcode1 = '1234';
|
||||||
my ( undef, undef, $itemnumber1 ) = AddItem(
|
my ( undef, undef, $itemnumber1 ) = AddItem(
|
||||||
|
@ -1138,12 +1125,7 @@ C4::Context->dbh->do("DELETE FROM accountlines");
|
||||||
my $branch = $library->{branchcode};
|
my $branch = $library->{branchcode};
|
||||||
|
|
||||||
#Create another record
|
#Create another record
|
||||||
my $biblio = MARC::Record->new();
|
my ($biblionumber, $biblioitemnumber) = add_biblio('A title', 'Anonymous');
|
||||||
$biblio->append_fields(
|
|
||||||
MARC::Field->new('100', ' ', ' ', a => 'Anonymous'),
|
|
||||||
MARC::Field->new('245', ' ', ' ', a => 'A title'),
|
|
||||||
);
|
|
||||||
my ($biblionumber, $biblioitemnumber) = AddBiblio($biblio, '');
|
|
||||||
|
|
||||||
my (undef, undef, $itemnumber) = AddItem(
|
my (undef, undef, $itemnumber) = AddItem(
|
||||||
{
|
{
|
||||||
|
@ -1173,8 +1155,7 @@ C4::Context->dbh->do("DELETE FROM accountlines");
|
||||||
{
|
{
|
||||||
my $library = $builder->build({ source => 'Branch' });
|
my $library = $builder->build({ source => 'Branch' });
|
||||||
|
|
||||||
my $biblio = MARC::Record->new();
|
my ($biblionumber, $biblioitemnumber) = add_biblio();
|
||||||
my ($biblionumber, $biblioitemnumber) = AddBiblio($biblio, '');
|
|
||||||
|
|
||||||
my $barcode = 'just a barcode';
|
my $barcode = 'just a barcode';
|
||||||
my ( undef, undef, $itemnumber ) = AddItem(
|
my ( undef, undef, $itemnumber ) = AddItem(
|
||||||
|
@ -1486,14 +1467,8 @@ subtest 'CanBookBeIssued + Statistic patrons "X"' => sub {
|
||||||
subtest 'MultipleReserves' => sub {
|
subtest 'MultipleReserves' => sub {
|
||||||
plan tests => 3;
|
plan tests => 3;
|
||||||
|
|
||||||
my $biblio = MARC::Record->new();
|
|
||||||
my $title = 'Silence in the library';
|
my $title = 'Silence in the library';
|
||||||
$biblio->append_fields(
|
my ($biblionumber, $biblioitemnumber) = add_biblio($title, 'Moffat, Steven');
|
||||||
MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'),
|
|
||||||
MARC::Field->new('245', ' ', ' ', a => $title),
|
|
||||||
);
|
|
||||||
|
|
||||||
my ($biblionumber, $biblioitemnumber) = AddBiblio($biblio, '');
|
|
||||||
|
|
||||||
my $branch = $library2->{branchcode};
|
my $branch = $library2->{branchcode};
|
||||||
|
|
||||||
|
@ -1855,14 +1830,8 @@ subtest '_FixAccountForLostAndReturned' => sub {
|
||||||
plan tests => 2;
|
plan tests => 2;
|
||||||
|
|
||||||
# Generate test biblio
|
# Generate test biblio
|
||||||
my $biblio = MARC::Record->new();
|
|
||||||
my $title = 'Koha for Dummies';
|
my $title = 'Koha for Dummies';
|
||||||
$biblio->append_fields(
|
my ( $biblionumber, $biblioitemnumber ) = add_biblio($title, 'Hall, Daria');
|
||||||
MARC::Field->new( '100', ' ', ' ', a => 'Hall, Daria' ),
|
|
||||||
MARC::Field->new( '245', ' ', ' ', a => $title ),
|
|
||||||
);
|
|
||||||
|
|
||||||
my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $biblio, '' );
|
|
||||||
|
|
||||||
my $barcode = 'KD123456789';
|
my $barcode = 'KD123456789';
|
||||||
my $branchcode = $library2->{branchcode};
|
my $branchcode = $library2->{branchcode};
|
||||||
|
@ -1902,14 +1871,8 @@ subtest '_FixOverduesOnReturn' => sub {
|
||||||
plan tests => 6;
|
plan tests => 6;
|
||||||
|
|
||||||
# Generate test biblio
|
# Generate test biblio
|
||||||
my $biblio = MARC::Record->new();
|
|
||||||
my $title = 'Koha for Dummies';
|
my $title = 'Koha for Dummies';
|
||||||
$biblio->append_fields(
|
my ( $biblionumber, $biblioitemnumber ) = add_biblio($title, 'Hall, Kylie');
|
||||||
MARC::Field->new( '100', ' ', ' ', a => 'Hall, Kylie' ),
|
|
||||||
MARC::Field->new( '245', ' ', ' ', a => $title ),
|
|
||||||
);
|
|
||||||
|
|
||||||
my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $biblio, '' );
|
|
||||||
|
|
||||||
my $barcode = 'KD987654321';
|
my $barcode = 'KD987654321';
|
||||||
my $branchcode = $library2->{branchcode};
|
my $branchcode = $library2->{branchcode};
|
||||||
|
@ -2097,3 +2060,26 @@ sub str {
|
||||||
$s .= %$alert ? ' (alert: ' . join( ' ', keys %$alert ) . ')' : '';
|
$s .= %$alert ? ' (alert: ' . join( ' ', keys %$alert ) . ')' : '';
|
||||||
return $s;
|
return $s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub add_biblio {
|
||||||
|
my ($title, $author) = @_;
|
||||||
|
|
||||||
|
my $marcflavour = C4::Context->preference('marcflavour');
|
||||||
|
|
||||||
|
my $biblio = MARC::Record->new();
|
||||||
|
if ($title) {
|
||||||
|
my $tag = $marcflavour eq 'UNIMARC' ? '200' : '245';
|
||||||
|
$biblio->append_fields(
|
||||||
|
MARC::Field->new($tag, ' ', ' ', a => $title),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($author) {
|
||||||
|
my ($tag, $code) = $marcflavour eq 'UNIMARC' ? (200, 'f') : (100, 'a');
|
||||||
|
$biblio->append_fields(
|
||||||
|
MARC::Field->new($tag, ' ', ' ', $code => $author),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return AddBiblio($biblio, '');
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue