db755a4307
Some minor changes to get the test suite working a bit better: I removed a superfluous method from t/lib/KohaTest.pm. I made each barcode for the items added in KohaTest.pm unique so that they would actually get inserted. Then, I removed t/override_context_prefs.pm. If you need that functionality, you're a database dependent test and should be a module in t/lib. So, I deleted all of the trivial .t tests that just 'use'd their modules and had no other tests and replaced them with lib/KohaTest/*pm modules that do a little bit more checking on those modules. I removed the references to override_context_prefs.pm in all of the other .t modules. They all pass now with no override_context_prefs.pm module. The database_depenedent.pl test script still does not pass entirely. There's a problem with the zebra index not being reset each time that the tables are truncated. I'll get to that. no functional or documentation changes here. Signed-off-by: Joshua Ferraro <jmf@liblime.com>
100 lines
3.3 KiB
Perl
100 lines
3.3 KiB
Perl
#!/usr/bin/perl
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
use Test::More tests => 28;
|
|
BEGIN {
|
|
use FindBin;
|
|
use lib $FindBin::Bin;
|
|
# use override_context_prefs;
|
|
use_ok('C4::Items');
|
|
}
|
|
|
|
my $item_mod_fixes_1 = {
|
|
notforloan => undef,
|
|
damaged => undef,
|
|
wthdrawn => undef,
|
|
itemlost => undef,
|
|
};
|
|
|
|
my $item_mod_fixes_2 = {
|
|
notforloan => '',
|
|
damaged => '',
|
|
wthdrawn => '',
|
|
itemlost => '',
|
|
};
|
|
|
|
my $item_mod_fixes_3 = {
|
|
notforloan => 1,
|
|
damaged => 2,
|
|
wthdrawn => 3,
|
|
itemlost => 4,
|
|
};
|
|
|
|
C4::Items::_do_column_fixes_for_mod($item_mod_fixes_1);
|
|
is($item_mod_fixes_1->{'notforloan'}, 0, 'null notforloan fixed during mod');
|
|
is($item_mod_fixes_1->{'damaged'}, 0, 'null damaged fixed during mod');
|
|
is($item_mod_fixes_1->{'wthdrawn'}, 0, 'null wthdrawn fixed during mod');
|
|
is($item_mod_fixes_1->{'itemlost'}, 0, 'null itemlost fixed during mod');
|
|
|
|
C4::Items::_do_column_fixes_for_mod($item_mod_fixes_2);
|
|
is($item_mod_fixes_2->{'notforloan'}, 0, 'empty notforloan fixed during mod');
|
|
is($item_mod_fixes_2->{'damaged'}, 0, 'empty damaged fixed during mod');
|
|
is($item_mod_fixes_2->{'wthdrawn'}, 0, 'empty wthdrawn fixed during mod');
|
|
is($item_mod_fixes_2->{'itemlost'}, 0, 'empty itemlost fixed during mod');
|
|
|
|
C4::Items::_do_column_fixes_for_mod($item_mod_fixes_3);
|
|
is($item_mod_fixes_3->{'notforloan'}, 1, 'do not clobber notforloan during mod');
|
|
is($item_mod_fixes_3->{'damaged'}, 2, 'do not clobber damaged during mod');
|
|
is($item_mod_fixes_3->{'wthdrawn'}, 3, 'do not clobber wthdrawn during mod');
|
|
is($item_mod_fixes_3->{'itemlost'}, 4, 'do not clobber itemlost during mod');
|
|
|
|
my $item_to_add_1 = {
|
|
itemnotes => 'newitem',
|
|
};
|
|
|
|
C4::Items::_set_defaults_for_add($item_to_add_1);
|
|
ok(exists $item_to_add_1->{'dateaccessioned'}, 'dateaccessioned added to new item');
|
|
like($item_to_add_1->{'dateaccessioned'}, qr/^\d\d\d\d-\d\d-\d\d$/ , 'new dateaccessioned is dddd-dd-dd');
|
|
is($item_to_add_1->{'itemnotes'}, 'newitem', 'itemnotes not clobbered');
|
|
|
|
my $item_add_fixes_1 = {
|
|
notforloan => undef,
|
|
damaged => undef,
|
|
wthdrawn => undef,
|
|
itemlost => undef,
|
|
};
|
|
|
|
my $item_add_fixes_2 = {
|
|
notforloan => '',
|
|
damaged => '',
|
|
wthdrawn => '',
|
|
itemlost => '',
|
|
};
|
|
|
|
my $item_add_fixes_3 = {
|
|
notforloan => 1,
|
|
damaged => 2,
|
|
wthdrawn => 3,
|
|
itemlost => 4,
|
|
};
|
|
|
|
C4::Items::_set_defaults_for_add($item_add_fixes_1);
|
|
is($item_add_fixes_1->{'notforloan'}, 0, 'null notforloan fixed during add');
|
|
is($item_add_fixes_1->{'damaged'}, 0, 'null damaged fixed during add');
|
|
is($item_add_fixes_1->{'wthdrawn'}, 0, 'null wthdrawn fixed during add');
|
|
is($item_add_fixes_1->{'itemlost'}, 0, 'null itemlost fixed during add');
|
|
|
|
C4::Items::_set_defaults_for_add($item_add_fixes_2);
|
|
is($item_add_fixes_2->{'notforloan'}, 0, 'empty notforloan fixed during add');
|
|
is($item_add_fixes_2->{'damaged'}, 0, 'empty damaged fixed during add');
|
|
is($item_add_fixes_2->{'wthdrawn'}, 0, 'empty wthdrawn fixed during add');
|
|
is($item_add_fixes_2->{'itemlost'}, 0, 'empty itemlost fixed during add');
|
|
|
|
C4::Items::_set_defaults_for_add($item_add_fixes_3);
|
|
is($item_add_fixes_3->{'notforloan'}, 1, 'do not clobber notforloan during mod');
|
|
is($item_add_fixes_3->{'damaged'}, 2, 'do not clobber damaged during mod');
|
|
is($item_add_fixes_3->{'wthdrawn'}, 3, 'do not clobber wthdrawn during mod');
|
|
is($item_add_fixes_3->{'itemlost'}, 4, 'do not clobber itemlost during mod');
|
|
|