View | Details | Raw Unified | Return to bug 26589
Collapse All | Expand All

(-)a/t/db_dependent/OAI/Sets.t (-3 / +28 lines)
Lines 18-24 Link Here
18
18
19
use Modern::Perl;
19
use Modern::Perl;
20
20
21
use Test::More tests => 147;
21
use Test::More tests => 152;
22
use Test::MockModule;
22
use Test::MockModule;
23
use Test::Warn;
23
use Test::Warn;
24
use MARC::Record;
24
use MARC::Record;
Lines 28-33 use C4::Biblio; Link Here
28
use C4::OAI::Sets;
28
use C4::OAI::Sets;
29
29
30
use t::lib::TestBuilder;
30
use t::lib::TestBuilder;
31
use t::lib::Mocks;
31
32
32
my $schema  = Koha::Database->new->schema;
33
my $schema  = Koha::Database->new->schema;
33
$schema->storage->txn_begin;
34
$schema->storage->txn_begin;
Lines 349-359 is ($mappings->{$set2_id}->[0]->{operator}, 'equal', 'operator field is "equal"' Link Here
349
is ($mappings->{$set2_id}->[0]->{marcvalue}, 'myOtherMarcValue', 'marcvalue field is "myOtherMarcValue"');
350
is ($mappings->{$set2_id}->[0]->{marcvalue}, 'myOtherMarcValue', 'marcvalue field is "myOtherMarcValue"');
350
351
351
352
352
# ---------- Testing AddOAISetsBiblios ----------
353
# ---------- Testing AddOAISetsBiblios with OAI-PMH:AutoUpdateSets disabled ----------
353
ok (!defined(AddOAISetsBiblios), 'AddOAISetsBiblios without argument is undef');
354
ok (!defined(AddOAISetsBiblios), 'AddOAISetsBiblios without argument is undef');
354
ok (!defined(AddOAISetsBiblios(my $arg=[])), 'AddOAISetsBiblios with a no HASH argument is undef');
355
ok (!defined(AddOAISetsBiblios(my $arg=[])), 'AddOAISetsBiblios with a no HASH argument is undef');
355
ok (defined(AddOAISetsBiblios($arg={})), 'AddOAISetsBiblios with a HASH argument is def');
356
ok (defined(AddOAISetsBiblios($arg={})), 'AddOAISetsBiblios with a HASH argument is def');
356
357
358
t::lib::Mocks::mock_preference( 'OAI-PMH:AutoUpdateSets', 0 );
359
357
# Create a biblio instance for testing
360
# Create a biblio instance for testing
358
my $biblio_1 = $builder->build_sample_biblio({ author => 'Moffat, Steven' });
361
my $biblio_1 = $builder->build_sample_biblio({ author => 'Moffat, Steven' });
359
my $biblionumber1 = $biblio_1->biblionumber;
362
my $biblionumber1 = $biblio_1->biblionumber;
Lines 394-399 $sth->execute($set2_id); Link Here
394
$count = $sth->rows;
397
$count = $sth->rows;
395
is ($count, '0', '$set_id2 has 0 biblio');
398
is ($count, '0', '$set_id2 has 0 biblio');
396
399
400
# ---------- Testing AddOAISetsBiblios with OAI-PMH:AutoUpdateSets enabled ----------
401
402
t::lib::Mocks::mock_preference( 'OAI-PMH:AutoUpdateSets', 1 );
403
404
my $biblio_3 = $builder->build_sample_biblio({ author => 'Moffat, Steven' });
405
my $biblionumber3 = $biblio_3->biblionumber;
406
isa_ok(\$biblionumber3, 'SCALAR', '$biblionumber3 is a SCALAR');
407
408
$sth = $dbh->prepare("SELECT count(*) FROM oai_sets_biblios");
409
$sth->execute;
410
$bibliosCount = $sth->fetchrow_array;
411
is ($bibliosCount, 3, 'There are 3 biblios in oai_sets_biblios');
412
413
#testing biblio for set1_id
414
$sth = $dbh->prepare("SELECT * FROM oai_sets_biblios WHERE set_id = ?");
415
$sth->execute($set1_id);
416
$count = $sth->rows;
417
is ($count, '3', '$set_id1 has 3 biblio');
418
419
$sth->execute($set1_id);
420
$line = ${ $sth->fetchall_arrayref( {} ) }[2];
421
is($line->{set_id}, $set1_id, "set_id is good");
422
is($line->{biblionumber}, $biblionumber3, "biblionumber is good");
397
423
398
# ---------- Testing GetOAISetsBiblio -----------
424
# ---------- Testing GetOAISetsBiblio -----------
399
$oai_sets = GetOAISetsBiblio($biblionumber1);
425
$oai_sets = GetOAISetsBiblio($biblionumber1);
400
- 

Return to bug 26589