Added unit tests for Biblio and moved it to db_dependent as it requires the database.
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
This commit is contained in:
parent
4093615e9f
commit
65e2cda8d2
2 changed files with 39 additions and 14 deletions
14
t/Biblio.t
14
t/Biblio.t
|
@ -1,14 +0,0 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
# This Koha test module is a stub!
|
||||
# Add more tests here!!!
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Test::More tests => 1;
|
||||
|
||||
BEGIN {
|
||||
use_ok('C4::Biblio');
|
||||
}
|
||||
|
39
t/db_dependent/Biblio.t
Executable file
39
t/db_dependent/Biblio.t
Executable file
|
@ -0,0 +1,39 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
# This Koha test module is a stub!
|
||||
# Add more tests here!!!
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 6;
|
||||
use MARC::Record;
|
||||
use C4::Biblio;
|
||||
|
||||
BEGIN {
|
||||
use_ok('C4::Biblio');
|
||||
}
|
||||
|
||||
my $isbn = '0590353403';
|
||||
my $title = 'Foundation';
|
||||
|
||||
my $marc_record=MARC::Record->new;
|
||||
my $field = MARC::Field->new('020','','','a' => $isbn);
|
||||
$marc_record->append_fields($field);
|
||||
my($biblionumber,$biblioitemnumber) = AddBiblio($marc_record,'');
|
||||
my $data = &GetBiblioData($biblionumber);
|
||||
is($data->{Title},undef,'Makes sure title field in biblio is empty.');
|
||||
|
||||
$field = MARC::Field->new('245','','','a' => $title);
|
||||
$marc_record->append_fields($field);
|
||||
ModBiblio($marc_record,$biblionumber,'');
|
||||
$data = &GetBiblioData($biblionumber);
|
||||
is($data->{title},$title,'uses ModBiblio to add a title to the previously created record and checks that its there.');
|
||||
is($data->{isbn},$isbn,'Makes sure the isbn is still there after using ModBiblio.');
|
||||
|
||||
my $itemdata = &GetBiblioItemData($biblioitemnumber);
|
||||
is($itemdata->{title},$title,'First test of GetBiblioItemData to get same result of previous two GetBiblioData tests.');
|
||||
is($itemdata->{isbn},$isbn,'Second test checking it returns the correct isbn.');
|
||||
|
||||
|
||||
# clean up after ourselves
|
||||
DelBiblio($biblionumber);
|
Loading…
Reference in a new issue