|
Lines 19-28
Link Here
|
| 19 |
|
19 |
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 3; |
22 |
use Test::More tests => 5; |
|
|
23 |
use MARC::Field; |
| 24 |
use MARC::File::XML; |
| 25 |
use MARC::Record; |
| 26 |
use Test::Deep; |
| 23 |
|
27 |
|
| 24 |
use Koha::Authority; |
28 |
use Koha::Authority; |
| 25 |
use Koha::Authorities; |
29 |
use Koha::Authorities; |
|
|
30 |
use Koha::Authority::MergeRequests; |
| 26 |
use Koha::Authority::Type; |
31 |
use Koha::Authority::Type; |
| 27 |
use Koha::Authority::Types; |
32 |
use Koha::Authority::Types; |
| 28 |
use Koha::Database; |
33 |
use Koha::Database; |
|
Lines 51-55
is( Koha::Authorities->search->count, $nb_of_authorities + 2, 'The 2 au
Link Here
|
| 51 |
$new_authority_1->delete; |
56 |
$new_authority_1->delete; |
| 52 |
is( Koha::Authorities->search->count, $nb_of_authorities + 1, 'Delete should have deleted the authority' ); |
57 |
is( Koha::Authorities->search->count, $nb_of_authorities + 1, 'Delete should have deleted the authority' ); |
| 53 |
|
58 |
|
|
|
59 |
subtest 'Add merge request' => sub { |
| 60 |
plan tests => 2; |
| 61 |
|
| 62 |
my $count = Koha::Authority::MergeRequests->count; |
| 63 |
$new_authority_2->add_merge_request; |
| 64 |
is( Koha::Authority::MergeRequests->count, |
| 65 |
$count+1, |
| 66 |
'Merge request added' ); |
| 67 |
my $new_authority_3 = Koha::Authority->new; |
| 68 |
$new_authority_3->add_merge_request; |
| 69 |
is( Koha::Authority::MergeRequests->count, |
| 70 |
$count+1, |
| 71 |
'No additional merge request added (not in storage)' ); |
| 72 |
}; |
| 73 |
|
| 74 |
subtest 'Testing reporting_tag_xml in MergeRequests' => sub { |
| 75 |
plan tests => 2; |
| 76 |
|
| 77 |
my $record = MARC::Record->new; |
| 78 |
$record->append_fields( |
| 79 |
MARC::Field->new( '024', '', '', a => 'aaa' ), |
| 80 |
MARC::Field->new( '100', '', '', a => 'Best author' ), |
| 81 |
MARC::Field->new( '234', '', '', a => 'Just a field' ), |
| 82 |
); |
| 83 |
my $xml = Koha::Authority::MergeRequests->reporting_tag_xml({ |
| 84 |
record => $record, tag => '110', |
| 85 |
}); |
| 86 |
is( $xml, undef, 'Expected no result for wrong tag' ); |
| 87 |
$xml = Koha::Authority::MergeRequests->reporting_tag_xml({ |
| 88 |
record => $record, tag => '100', |
| 89 |
}); |
| 90 |
my $newrecord = MARC::Record->new_from_xml( |
| 91 |
$xml, 'UTF-8', |
| 92 |
C4::Context->preference('marcflavour') eq 'UNIMARC' ? |
| 93 |
'UNIMARCAUTH' : |
| 94 |
'MARC21', |
| 95 |
); # MARC format does not actually matter here |
| 96 |
cmp_deeply( $record->field('100')->subfields, |
| 97 |
$newrecord->field('100')->subfields, |
| 98 |
'Compare reporting tag in both records', |
| 99 |
); |
| 100 |
}; |
| 101 |
|
| 54 |
$schema->storage->txn_rollback; |
102 |
$schema->storage->txn_rollback; |
| 55 |
1; |
|
|
| 56 |
- |