# with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
-use C4::Context;
-use Test::More tests => 147;
+
+use Test::More tests => 144;
use Test::MockModule;
use Test::Warn;
+use MARC::Record;
+use Koha::Database;
+use C4::Biblio;
+use C4::OAI::Sets;
-BEGIN {
- use_ok('C4::OAI::Sets');
- use_ok('MARC::Record');
- use_ok('C4::Biblio');
-}
-can_ok(
- 'C4::OAI::Sets', qw(
- GetOAISets
- GetOAISet
- GetOAISetBySpec
- ModOAISet
- DelOAISet
- AddOAISet
- GetOAISetsMappings
- GetOAISetMappings
- ModOAISetMappings
- GetOAISetsBiblio
- DelOAISetsBiblio
- CalcOAISetsBiblio
- ModOAISetsBiblios
- UpdateOAISetsBiblio
- AddOAISetsBiblios )
-);
-
-
+my $schema = Koha::Database->new->schema;
+$schema->storage->txn_begin;
my $dbh = C4::Context->dbh;
-$dbh->{AutoCommit} = 0;
-$dbh->{RaiseError} = 1;
+
$dbh->do('DELETE FROM oai_sets');
$dbh->do('DELETE FROM oai_sets_descriptions');
$dbh->do('DELETE FROM oai_sets_mappings');
'name' => 'nameNoSpec',
'descriptions' => ['descNoSpecNoName'],
};
-warning_is { ModOAISet($new_set_without_id) }
+my $res;
+warning_is { $res = ModOAISet($new_set_without_id) }
'Set ID not defined, can\'t modify the set',
'ModOAISet raises warning if Set ID is not defined';
+ok(!defined($res), 'ModOAISet returns undef if Set ID is not defined');
my $new_set_without_spec_and_name = {
'id' => $set1_id,
my $biblionumberVH = create_helper_biblio('Victor Hugo');
#Update
-my $record = GetMarcBiblio($biblionumberVH);
+my $record = GetMarcBiblio({ biblionumber => $biblionumberVH });
UpdateOAISetsBiblio($biblionumberVH, $record);
#is biblio attached to setVH ?
my $biblionumberNotVH = create_helper_biblio('Sponge, Bob');
#Update
-$record = GetMarcBiblio($biblionumberNotVH);
+$record = GetMarcBiblio({ biblionumber => $biblionumberNotVH });
UpdateOAISetsBiblio($biblionumberNotVH, $record);
my @setsNotEq = CalcOAISetsBiblio($record);
return $biblionumber;
}
-$dbh->rollback;
\ No newline at end of file
+$schema->storage->txn_rollback;