use Modern::Perl;
use Koha::Database;
+use C4::Biblio;
+use Koha::Biblios;
use Bytes::Random::Secure;
use Carp;
sub gimme_a_biblio {
my ( $self, $args ) = @_;
- my $itemtype = $args->{itemtype} || $self->build_object({ class => 'Koha::ItemTypes' })->itemtype;
- my $title = $args->{title} || 'Some boring read';
+ my $title = $args->{title} || 'Some boring read';
+ my $author = $args->{author} || 'Some boring author';
+ my $frameworkcode = $args->{frameworkcode} || '';
+ my $itemtype = $args->{itemtype}
+ || $self->build_object( { class => 'Koha::ItemTypes' } )->itemtype;
+
+ my $marcflavour = C4::Context->preference('marcflavour');
my $record = MARC::Record->new();
+ my ( $tag, $subfield ) = $marcflavour eq 'UNIMARC' ? ( 200, 'a' ) : ( 245, 'a' );
+ $record->append_fields(
+ MARC::Field->new( $tag, ' ', ' ', $subfield => $title ),
+ );
+
+ ( $tag, $subfield ) = $marcflavour eq 'UNIMARC' ? ( 200, 'f' ) : ( 100, 'a' );
+ $record->append_fields(
+ MARC::Field->new( $tag, ' ', ' ', $subfield => $author ),
+ );
+
+ ( $tag, $subfield ) = $marcflavour eq 'UNIMARC' ? ( 995, 'r' ) : ( 942, 'c' );
$record->append_fields(
- MARC::Field->new( '245', ' ', ' ', a => $title ),
- MARC::Field->new( '942', ' ', ' ', c => $itemtype )
+ MARC::Field->new( $tag, ' ', ' ', $subfield => $itemtype )
);
- my ($biblio_id) = AddBiblio( $record, '' );
+ my ($biblio_id) = C4::Biblio::AddBiblio( $record, $frameworkcode );
return Koha::Biblios->find($biblio_id);
}