|
Lines 17-23
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 20; |
20 |
use Test::More tests => 21; |
| 21 |
use Test::MockModule; |
21 |
use Test::MockModule; |
| 22 |
use Test::Warn; |
22 |
use Test::Warn; |
| 23 |
use List::MoreUtils qw( uniq ); |
23 |
use List::MoreUtils qw( uniq ); |
|
Lines 45-51
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
Link Here
|
| 45 |
my $builder = t::lib::TestBuilder->new; |
45 |
my $builder = t::lib::TestBuilder->new; |
| 46 |
|
46 |
|
| 47 |
subtest 'AddBiblio' => sub { |
47 |
subtest 'AddBiblio' => sub { |
| 48 |
plan tests => 9; |
48 |
plan tests => 10; |
| 49 |
|
49 |
|
| 50 |
my $marcflavour = 'MARC21'; |
50 |
my $marcflavour = 'MARC21'; |
| 51 |
t::lib::Mocks::mock_preference( 'marcflavour', $marcflavour ); |
51 |
t::lib::Mocks::mock_preference( 'marcflavour', $marcflavour ); |
|
Lines 99-104
subtest 'AddBiblio' => sub {
Link Here
|
| 99 |
warning_like { $builder->build_sample_biblio(); } |
99 |
warning_like { $builder->build_sample_biblio(); } |
| 100 |
qr/My biblionumber is \d+ and my frameworkcode is /, "The biblionumber is correctly passed to BiblioAutoLink"; |
100 |
qr/My biblionumber is \d+ and my frameworkcode is /, "The biblionumber is correctly passed to BiblioAutoLink"; |
| 101 |
|
101 |
|
|
|
102 |
subtest 'record_source_id param tests' => sub { |
| 103 |
|
| 104 |
plan tests => 2; |
| 105 |
|
| 106 |
my $source = $builder->build_object( { class => 'Koha::RecordSources' } ); |
| 107 |
|
| 108 |
my $record = MARC::Record->new; |
| 109 |
$record->append_fields( MARC::Field->new( '245', ' ', ' ', a => 'Some title' ) ); |
| 110 |
|
| 111 |
my ($biblio_id) = C4::Biblio::AddBiblio( $record, '', { record_source_id => undef } ); |
| 112 |
my $metadata = Koha::Biblios->find($biblio_id)->metadata; |
| 113 |
|
| 114 |
is( $metadata->record_source_id, undef, 'Record source is not defined' ); |
| 115 |
|
| 116 |
($biblio_id) = C4::Biblio::AddBiblio( $record, '', { record_source_id => $source->id } ); |
| 117 |
$metadata = Koha::Biblios->find($biblio_id)->metadata; |
| 118 |
|
| 119 |
is( $metadata->record_source_id, $source->id, 'Record source is stored as expected' ); |
| 120 |
}; |
| 102 |
}; |
121 |
}; |
| 103 |
|
122 |
|
| 104 |
subtest 'GetMarcSubfieldStructureFromKohaField' => sub { |
123 |
subtest 'GetMarcSubfieldStructureFromKohaField' => sub { |
|
Lines 1022-1027
subtest 'ModBiblio on invalid record' => sub {
Link Here
|
| 1022 |
); |
1041 |
); |
| 1023 |
}; |
1042 |
}; |
| 1024 |
|
1043 |
|
|
|
1044 |
subtest 'ModBiblio - record_source_id param tests' => sub { |
| 1045 |
|
| 1046 |
plan tests => 4; |
| 1047 |
|
| 1048 |
my $source = $builder->build_object( { class => 'Koha::RecordSources' } ); |
| 1049 |
|
| 1050 |
my $record = MARC::Record->new; |
| 1051 |
$record->append_fields( MARC::Field->new( '245', ' ', ' ', a => 'Some title' ) ); |
| 1052 |
|
| 1053 |
my ($biblio_id) = C4::Biblio::AddBiblio( $record, '', { record_source_id => undef } ); |
| 1054 |
my $metadata = Koha::Biblios->find($biblio_id)->metadata; |
| 1055 |
|
| 1056 |
is( $metadata->record_source_id, undef, 'Record source is not defined' ); |
| 1057 |
|
| 1058 |
C4::Biblio::ModBiblio( $record, $biblio_id, '', { record_source_id => $source->id } ); |
| 1059 |
$metadata->discard_changes; |
| 1060 |
|
| 1061 |
is( $metadata->record_source_id, $source->id, 'Record source is stored as expected' ); |
| 1062 |
|
| 1063 |
C4::Biblio::ModBiblio( $record, $biblio_id, '' ); |
| 1064 |
$metadata->discard_changes; |
| 1065 |
|
| 1066 |
is( $metadata->record_source_id, $source->id, 'Record source not passed, remains untouched' ); |
| 1067 |
|
| 1068 |
C4::Biblio::ModBiblio( $record, $biblio_id, '', { record_source_id => undef } ); |
| 1069 |
$metadata->discard_changes; |
| 1070 |
|
| 1071 |
is( $metadata->record_source_id, undef, 'Record source is not defined' ); |
| 1072 |
}; |
| 1073 |
|
| 1025 |
# Cleanup |
1074 |
# Cleanup |
| 1026 |
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); |
1075 |
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); |
| 1027 |
$schema->storage->txn_rollback; |
1076 |
$schema->storage->txn_rollback; |