Bug 24674: Adjust tests and add new ones to cover changes

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Rebased 21-09-21.

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Jonathan Druart 2020-02-18 14:49:46 +01:00
parent 5fa32f2394
commit b71f1137ba

View file

@ -94,7 +94,7 @@ subtest 'Multiple mappings for one kohafield' => sub {
};
subtest 'Testing _adjust_pubyear' => sub {
plan tests => 12;
plan tests => 17;
is( C4::Biblio::_adjust_pubyear('2004 c2000 2007'), 2000, 'First cYEAR' );
is( C4::Biblio::_adjust_pubyear('2004 2000 2007'), 2004, 'First year' );
@ -104,7 +104,12 @@ subtest 'Testing _adjust_pubyear' => sub {
is( C4::Biblio::_adjust_pubyear('1...'), 1000, '1... on its own' );
is( C4::Biblio::_adjust_pubyear('12?? 13xx'), 1200, '12?? first' );
is( C4::Biblio::_adjust_pubyear('12? 1x'), undef, 'Too short return nothing as data must be int' );
is( C4::Biblio::_adjust_pubyear('198-'), undef, 'Missing question mark, nothing is returned as data must be int' );
is( C4::Biblio::_adjust_pubyear('198-'), '1980', '198-' );
is( C4::Biblio::_adjust_pubyear('19--'), '1900', '19--' );
is( C4::Biblio::_adjust_pubyear('19-'), '1900', '19-' );
is( C4::Biblio::_adjust_pubyear('2---'), '2000', '2---' );
is( C4::Biblio::_adjust_pubyear('2--'), '2000', '2--' );
is( C4::Biblio::_adjust_pubyear('2-'), '2000', '2-' );
is( C4::Biblio::_adjust_pubyear('198-?'), '1980', '198-?' );
is( C4::Biblio::_adjust_pubyear('1981-'), '1981', 'Date range returns first date' );
is( C4::Biblio::_adjust_pubyear('broken'), undef, 'Non-matchign data returns nothing as the field must be int' );