Bug 19040: Refactor GetMarcBiblio parameters
[koha.git] / t / db_dependent / OAI / Sets.t
index 932e457..88f14bf 100644 (file)
 # 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');
@@ -201,9 +181,11 @@ my $new_set_without_id =  {
     '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,
@@ -538,7 +520,7 @@ ModOAISetMappings($setVH_id, $mappingsVH);
 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 ?
@@ -593,7 +575,7 @@ ModOAISetMappings($setNotVH_id, $mappingsNotVH);
 my $biblionumberNotVH = create_helper_biblio('Sponge, Bob');
 
 #Update
-$record = GetMarcBiblio($biblionumberNotVH);
+$record = GetMarcBiblio({ biblionumber => $biblionumberNotVH });
 UpdateOAISetsBiblio($biblionumberNotVH, $record);
 
 my @setsNotEq = CalcOAISetsBiblio($record);
@@ -630,4 +612,4 @@ sub create_helper_biblio {
     return $biblionumber;
 }
 
-$dbh->rollback;
\ No newline at end of file
+$schema->storage->txn_rollback;