|
Lines 29-34
use Koha::Database;
Link Here
|
| 29 |
use Koha::Caches; |
29 |
use Koha::Caches; |
| 30 |
use Koha::MarcSubfieldStructures; |
30 |
use Koha::MarcSubfieldStructures; |
| 31 |
|
31 |
|
|
|
32 |
use C4::Linker::Default; |
| 33 |
|
| 32 |
BEGIN { |
34 |
BEGIN { |
| 33 |
use_ok('C4::Biblio'); |
35 |
use_ok('C4::Biblio'); |
| 34 |
} |
36 |
} |
|
Lines 124-129
subtest "GetMarcFromKohaField" => sub {
Link Here
|
| 124 |
is( $retval[0].$retval[1], '399a', 'Including 399a' ); |
126 |
is( $retval[0].$retval[1], '399a', 'Including 399a' ); |
| 125 |
}; |
127 |
}; |
| 126 |
|
128 |
|
|
|
129 |
subtest "Authority creation with default linker" => sub { |
| 130 |
plan tests => 2; |
| 131 |
# Automatic authority creation |
| 132 |
t::lib::Mocks::mock_preference('LinkerModule', 'Default'); |
| 133 |
t::lib::Mocks::mock_preference('BiblioAddsAuthorities', 1); |
| 134 |
t::lib::Mocks::mock_preference('AutoCreateAuthorities', 1); |
| 135 |
t::lib::Mocks::mock_preference('marcflavour', 'MARC21'); |
| 136 |
my $linker = C4::Linker::Default->new({}); |
| 137 |
my $authorities_mod = Test::MockModule->new( 'C4::Heading' ); |
| 138 |
$authorities_mod->mock( |
| 139 |
'authorities', |
| 140 |
sub { |
| 141 |
my $results = [{ authid => 'original' },{ authid => 'duplicate' }]; |
| 142 |
return $results; |
| 143 |
} |
| 144 |
); |
| 145 |
my $marc_record = MARC::Record->new(); |
| 146 |
my $field = MARC::Field->new(655, ' ', ' ','a' => 'Magical realism'); |
| 147 |
$marc_record->append_fields( $field ); |
| 148 |
my ($num_changed,$results) = LinkBibHeadingsToAuthorities($linker, $marc_record, "",undef); |
| 149 |
is( $num_changed, 0, "We shouldn't link or create a new record"); |
| 150 |
ok( !defined $results->{added}, "If we have multiple matches, we shouldn't create a new record"); |
| 151 |
}; |
| 152 |
|
| 153 |
|
| 154 |
|
| 127 |
# Mocking variables |
155 |
# Mocking variables |
| 128 |
my $biblio_module = new Test::MockModule('C4::Biblio'); |
156 |
my $biblio_module = new Test::MockModule('C4::Biblio'); |
| 129 |
$biblio_module->mock( |
157 |
$biblio_module->mock( |
| 130 |
- |
|
|