Lines 29-44
use List::MoreUtils qw/any/;
Link Here
|
29 |
use MARC::Record; |
29 |
use MARC::Record; |
30 |
use MARC::Field; |
30 |
use MARC::Field; |
31 |
use C4::Context; |
31 |
use C4::Context; |
|
|
32 |
use C4::Biblio; |
32 |
use Koha::Cache qw/flush_all/; |
33 |
use Koha::Cache qw/flush_all/; |
33 |
use Koha::Database; |
34 |
use Koha::Database; |
34 |
use English qw/-no_match_vars/; |
|
|
35 |
|
36 |
$OUTPUT_AUTOFLUSH = 1; |
37 |
|
35 |
|
38 |
BEGIN { |
36 |
BEGIN { |
39 |
use_ok('Koha::RecordProcessor'); |
37 |
use_ok('Koha::RecordProcessor'); |
40 |
} |
38 |
} |
41 |
|
39 |
|
|
|
40 |
my $dbh = C4::Context->dbh; |
41 |
|
42 |
my $database = Koha::Database->new(); |
43 |
my $schema = $database->schema(); |
44 |
$dbh->{RaiseError} = 1; |
45 |
|
42 |
sub run_hiding_tests { |
46 |
sub run_hiding_tests { |
43 |
|
47 |
|
44 |
my $interface = shift; |
48 |
my $interface = shift; |
Lines 54-76
sub run_hiding_tests {
Link Here
|
54 |
'intranet' => [ -8, -7, -4, -3, -2, 2, 3, 5, 8 ] |
58 |
'intranet' => [ -8, -7, -4, -3, -2, 2, 3, 5, 8 ] |
55 |
}; |
59 |
}; |
56 |
|
60 |
|
57 |
my $dbh = C4::Context->dbh; |
61 |
my ( $isbn_field, $isbn_subfield ) = |
58 |
|
62 |
GetMarcFromKohaField( 'biblioitems.isbn', q{} ); |
59 |
my $database = Koha::Database->new(); |
63 |
my $update_sql = |
60 |
my $schema = $database->schema(); |
64 |
q{UPDATE marc_subfield_structure SET hidden=? } |
61 |
$dbh->{RaiseError} = 1; |
65 |
. q{WHERE tagfield='} |
62 |
|
66 |
. $isbn_field |
63 |
#$ENV{'DEBUG'} = '1'; # Turn on debugging. |
67 |
. q{' OR } |
64 |
|
68 |
. q{ tagfield='008';}; |
|
|
69 |
my $sth = $dbh->prepare($update_sql); |
65 |
foreach my $hidden_value (@valid_hidden_values) { |
70 |
foreach my $hidden_value (@valid_hidden_values) { |
66 |
|
71 |
|
67 |
$schema->storage->txn_begin(); |
|
|
68 |
|
69 |
my $update_sql = |
70 |
q{UPDATE marc_subfield_structure SET hidden=? } |
71 |
. q{WHERE tagfield='020' OR } |
72 |
. q{ tagfield='008';}; |
73 |
my $sth = $dbh->prepare($update_sql); |
74 |
$sth->execute($hidden_value); |
72 |
$sth->execute($hidden_value); |
75 |
|
73 |
|
76 |
my $cache = Koha::Cache->get_instance(); |
74 |
my $cache = Koha::Cache->get_instance(); |
Lines 139-159
sub run_hiding_tests {
Link Here
|
139 |
'Records are the same' ); |
137 |
'Records are the same' ); |
140 |
} |
138 |
} |
141 |
|
139 |
|
142 |
$schema->storage->txn_rollback(); |
|
|
143 |
} |
140 |
} |
144 |
return; |
141 |
return; |
145 |
} |
142 |
} |
146 |
|
143 |
|
147 |
sub create_marc_record { |
144 |
sub create_marc_record { |
148 |
|
145 |
|
|
|
146 |
my ( $title_field, $title_subfield ) = |
147 |
GetMarcFromKohaField( 'biblio.title', q{} ); |
148 |
my ( $isbn_field, $isbn_subfield ) = |
149 |
GetMarcFromKohaField( 'biblioitems.isbn', q{} ); |
149 |
my $isbn = '0590353403'; |
150 |
my $isbn = '0590353403'; |
150 |
my $title = 'Foundation'; |
151 |
my $title = 'Foundation'; |
151 |
my $marc_record = MARC::Record->new; |
152 |
my $marc_record = MARC::Record->new; |
152 |
my @fields = ( |
153 |
my @fields = ( |
153 |
MARC::Field->new( '003', 'AR-CdUBM' ), |
154 |
MARC::Field->new( '003', 'AR-CdUBM' ), |
154 |
MARC::Field->new( '008', '######suuuu####ag_||||__||||_0||_|_uuu|d' ), |
155 |
MARC::Field->new( '008', '######suuuu####ag_||||__||||_0||_|_uuu|d' ), |
155 |
MARC::Field->new( '020', q{}, q{}, 'a' => $isbn ), |
156 |
MARC::Field->new( $isbn_field, q{}, q{}, $isbn_subfield => $isbn ), |
156 |
MARC::Field->new( '245', q{}, q{}, 'a' => $title ), |
157 |
MARC::Field->new( $title_field, q{}, q{}, $title_subfield => $title ), |
157 |
); |
158 |
); |
158 |
|
159 |
|
159 |
$marc_record->insert_fields_ordered(@fields); |
160 |
$marc_record->insert_fields_ordered(@fields); |
Lines 165-178
subtest 'Koha::Filter::MARC::ViewPolicy opac tests' => sub {
Link Here
|
165 |
|
166 |
|
166 |
plan tests => 102; |
167 |
plan tests => 102; |
167 |
|
168 |
|
|
|
169 |
$schema->storage->txn_begin(); |
168 |
run_hiding_tests('opac'); |
170 |
run_hiding_tests('opac'); |
|
|
171 |
$schema->storage->txn_rollback(); |
169 |
}; |
172 |
}; |
170 |
|
173 |
|
171 |
subtest 'Koha::Filter::MARC::ViewPolicy intranet tests' => sub { |
174 |
subtest 'Koha::Filter::MARC::ViewPolicy intranet tests' => sub { |
172 |
|
175 |
|
173 |
plan tests => 102; |
176 |
plan tests => 102; |
174 |
|
177 |
|
|
|
178 |
$schema->storage->txn_begin(); |
175 |
run_hiding_tests('intranet'); |
179 |
run_hiding_tests('intranet'); |
|
|
180 |
$schema->storage->txn_rollback(); |
176 |
}; |
181 |
}; |
177 |
|
182 |
|
178 |
1; |
183 |
1; |
179 |
- |
|
|