Bug 10306: (QA follow-up) More feedback for admins in koha2marclinks
[koha.git] / t / db_dependent / Koha / IsKohaFieldLinked.t
1 use Modern::Perl;
2 use Test::More;
3
4 use C4::Context;
5 use C4::Koha;
6
7 my $dbh = C4::Context->dbh;
8 $dbh->{RaiseError} = 1;
9 $dbh->{AutoCommit} = 0;
10
11 my $frameworkcode = 'FCUT';
12 $dbh->do( qq|
13     INSERT INTO marc_subfield_structure(
14         tagfield, tagsubfield, liblibrarian, kohafield, frameworkcode
15     ) VALUES
16         ('952', 'p', 'Barcode', 'items.barcode', '$frameworkcode'),
17         ('952', '8', 'Collection code', 'items.ccode', '$frameworkcode'),
18         ('952', '7', 'Not for loan', 'items.notforloan', '$frameworkcode'),
19         ('952', 'y', 'Koha item type', 'items.itype', '$frameworkcode'),
20         ('952', 'c', 'Permanent location', '', '$frameworkcode')
21 |);
22
23 is ( C4::Koha::IsKohaFieldLinked( {
24     kohafield => 'items.barcode',
25     frameworkcode => $frameworkcode,
26 }), 1, 'items.barcode is linked' );
27
28 is ( C4::Koha::IsKohaFieldLinked( {
29     kohafield => 'items.notforloan',
30     frameworkcode => $frameworkcode,
31 }), 1, 'items.notforloan is linked' );
32
33 is ( C4::Koha::IsKohaFieldLinked( {
34     kohafield => 'notforloan',
35     frameworkcode => $frameworkcode,
36 }), 0, 'notforloan is not linked' );
37
38 is ( C4::Koha::IsKohaFieldLinked( {
39     kohafield => 'items.permanent_location',
40     frameworkcode => $frameworkcode,
41 }), 0, 'items.permanent_location is not linked' );
42
43
44 done_testing;