use MARC::Record;
use t::lib::Mocks;
+use t::lib::TestBuilder;
use Koha::Database;
+use Koha::Authority::Types;
BEGIN {
use_ok('C4::AuthoritiesMarc');
my $schema = Koha::Database->new->schema;
$schema->storage->txn_begin;
my $dbh = C4::Context->dbh;
+my $builder = t::lib::TestBuilder->new;
t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
+# Authority type GEOGR_NAME is hardcoded here
+if( ! Koha::Authority::Types->find('GEOGR_NAME') ) {
+ $builder->build({ source => 'AuthType', value => { authtypecode => 'GEOGR_NAME' }});
+};
+
is(BuildAuthHierarchies(3, 1), '1,2,3', "Built linked authtrees hierarchy string");
my $expectedhierarchy = [ [ {
);
subtest 'AddAuthority should respect AUTO_INCREMENT (BZ 18104)' => sub {
- plan tests => 1;
+ plan tests => 3;
t::lib::Mocks::mock_preference( 'marcflavour', 'MARC21' );
my $record = C4::AuthoritiesMarc::GetAuthority(1);
my $id1 = AddAuthority( $record, undef, 'GEOGR_NAME' );
- DelAuthority( $id1 );
+ DelAuthority({ authid => $id1 });
my $id2 = AddAuthority( $record, undef, 'GEOGR_NAME' );
- is( $id1, $id2, 'FIXME: Got the same id back, let\'s fix that behavior' );
-
+ isnt( $id1, $id2, 'Do not return the same id again' );
+ t::lib::Mocks::mock_preference( 'marcflavour', 'UNIMARC' );
+ my $id3 = AddAuthority( $record, undef, 'GEOGR_NAME' );
+ ok( $id3 > 0, 'Tested AddAuthority with UNIMARC' );
+ is( $record->field('001')->data, $id3, 'Check updated 001' );
};
$schema->storage->txn_rollback;