Lines 27-33
use Test::MockModule;
Link Here
|
27 |
use MARC::Field; |
27 |
use MARC::Field; |
28 |
|
28 |
|
29 |
use C4::Items; |
29 |
use C4::Items; |
30 |
use C4::Biblio qw( AddBiblio ModBiblio ); |
30 |
use C4::Biblio qw( AddBiblio ModBiblio GetMarcFromKohaField ); |
31 |
use C4::Reserves qw( AddReserve ); |
31 |
use C4::Reserves qw( AddReserve ); |
32 |
|
32 |
|
33 |
use Koha::DateUtils qw( dt_from_string output_pref ); |
33 |
use Koha::DateUtils qw( dt_from_string output_pref ); |
Lines 200-219
subtest 'custom_cover_image_url' => sub {
Link Here
|
200 |
my $isbn = '0553573403 | 9780553573404 (pbk.).png'; |
200 |
my $isbn = '0553573403 | 9780553573404 (pbk.).png'; |
201 |
my $issn = 'my_issn'; |
201 |
my $issn = 'my_issn'; |
202 |
my $cf_value = 'from_control_field'; |
202 |
my $cf_value = 'from_control_field'; |
203 |
my $marc_record = MARC::Record->new; |
203 |
my $biblio = $builder->build_sample_biblio; |
204 |
my ( $biblionumber, undef ) = C4::Biblio::AddBiblio($marc_record, ''); |
204 |
my $marc_record = $biblio->metadata->record; |
|
|
205 |
my ( $isbn_tag, $isbn_subfield ) = GetMarcFromKohaField( 'biblioitems.isbn' ); |
206 |
my ( $issn_tag, $issn_subfield ) = GetMarcFromKohaField( 'biblioitems.issn' ); |
207 |
$marc_record->append_fields( |
208 |
MARC::Field->new( $isbn_tag, '', '', $isbn_subfield => $isbn ), |
209 |
MARC::Field->new( $issn_tag, '', '', $issn_subfield => $issn ), |
210 |
); |
211 |
C4::Biblio::ModBiblio( $marc_record, $biblio->biblionumber ); |
205 |
|
212 |
|
206 |
my $biblio = Koha::Biblios->find( $biblionumber ); |
213 |
is( $biblio->get_from_storage->custom_cover_image_url, "https://my_url/${isbn}_${issn}.png" ); |
207 |
my $biblioitem = $biblio->biblioitem->set( |
|
|
208 |
{ isbn => $isbn, issn => $issn }); |
209 |
is( $biblio->custom_cover_image_url, "https://my_url/${isbn}_${issn}.png" ); |
210 |
|
214 |
|
211 |
my $marc_024a = '710347104926'; |
215 |
my $marc_024a = '710347104926'; |
212 |
$marc_record->append_fields( MARC::Field->new( '024', '', '', a => $marc_024a ) ); |
216 |
$marc_record->append_fields( MARC::Field->new( '024', '', '', a => $marc_024a ) ); |
213 |
C4::Biblio::ModBiblio( $marc_record, $biblio->biblionumber ); |
217 |
C4::Biblio::ModBiblio( $marc_record, $biblio->biblionumber ); |
214 |
|
218 |
|
215 |
t::lib::Mocks::mock_preference( 'CustomCoverImagesURL', 'https://my_url/{024$a}.png' ); |
219 |
t::lib::Mocks::mock_preference( 'CustomCoverImagesURL', 'https://my_url/{024$a}.png' ); |
216 |
is( $biblio->custom_cover_image_url, "https://my_url/$marc_024a.png" ); |
220 |
is( $biblio->get_from_storage->custom_cover_image_url, "https://my_url/$marc_024a.png" ); |
217 |
|
221 |
|
218 |
t::lib::Mocks::mock_preference( 'CustomCoverImagesURL', 'https://my_url/{normalized_isbn}.png' ); |
222 |
t::lib::Mocks::mock_preference( 'CustomCoverImagesURL', 'https://my_url/{normalized_isbn}.png' ); |
219 |
my $normalized_isbn = C4::Koha::GetNormalizedISBN($isbn); |
223 |
my $normalized_isbn = C4::Koha::GetNormalizedISBN($isbn); |
Lines 226-232
subtest 'custom_cover_image_url' => sub {
Link Here
|
226 |
is( $biblio->custom_cover_image_url, undef, 'Record does not have 001' ); |
230 |
is( $biblio->custom_cover_image_url, undef, 'Record does not have 001' ); |
227 |
$marc_record->append_fields(MARC::Field->new('001', $cf_value)); |
231 |
$marc_record->append_fields(MARC::Field->new('001', $cf_value)); |
228 |
C4::Biblio::ModBiblio( $marc_record, $biblio->biblionumber ); |
232 |
C4::Biblio::ModBiblio( $marc_record, $biblio->biblionumber ); |
229 |
$biblio = Koha::Biblios->find( $biblionumber ); |
233 |
$biblio = Koha::Biblios->find( $biblio->biblionumber ); |
230 |
is( $biblio->get_from_storage->custom_cover_image_url, "https://my_url/$cf_value.png", 'URL generated using 001' ); |
234 |
is( $biblio->get_from_storage->custom_cover_image_url, "https://my_url/$cf_value.png", 'URL generated using 001' ); |
231 |
}; |
235 |
}; |
232 |
|
236 |
|
233 |
- |
|
|