1 package KohaTest::ImportBatch;
11 sub testing_class { 'C4::ImportBatch' };
14 sub routines : Test( 1 ) {
24 AddItemsToImportBiblio
25 BatchFindBibDuplicates
32 GetImportBatchRangeDesc
33 GetItemNumbersFromImportBatch
34 GetNumberOfNonZ3950ImportBatches
39 GetImportBatchOverlayAction
40 SetImportBatchOverlayAction
41 GetImportBatchNoMatchAction
42 SetImportBatchNoMatchAction
43 GetImportBatchItemAction
44 SetImportBatchItemAction
45 GetImportBatchItemAction
46 SetImportBatchItemAction
49 GetImportRecordOverlayStatus
50 SetImportRecordOverlayStatus
53 GetImportRecordMatches
54 SetImportRecordMatches
56 _update_import_record_marc
60 _update_batch_record_counts
65 can_ok($self->testing_class, @routines);
68 sub startup_50_add_matcher : Test( startup => 1 ) {
70 # create test MARC21 ISBN matcher
71 my $matcher = C4::Matcher->new('biblio');
72 $matcher->threshold(1000);
73 $matcher->code('TESTISBN');
74 $matcher->description('test MARC21 ISBN matcher');
75 $matcher->add_simple_matchpoint('isbn', 1000, '020', 'a', -1, 0, '');
76 my $matcher_id = $matcher->store();
77 like($matcher_id, qr/^\d+$/, "store new matcher and get back ID");
79 $self->{'matcher_id'} = $matcher_id;
82 sub shutdown_50_remove_matcher : Test( shutdown => 6) {
84 my @matchers = C4::Matcher::GetMatcherList();
85 cmp_ok(scalar(@matchers), ">=", 1, "at least one matcher present");
87 my $testisbn_count = 0;
89 foreach my $matcher (@matchers) {
90 if ($matcher->{'code'} eq 'TESTISBN') {
92 $matcher_id = $matcher->{'matcher_id'};
95 ok($testisbn_count == 1, "only one TESTISBN matcher");
96 like($matcher_id, qr/^\d+$/, "matcher ID is valid");
97 my $matcher = C4::Matcher->fetch($matcher_id);
98 ok(defined($matcher), "got back a matcher");
99 ok($matcher_id == $matcher->{'id'}, "got back the correct matcher");
100 C4::Matcher->delete($matcher_id);
101 my $matcher2 = C4::Matcher->fetch($matcher_id);
102 ok(not(defined($matcher2)), "matcher removed");
104 delete $self->{'matcher_id'};
107 =head2 UTILITY METHODS
111 sub add_import_batch {
113 my $test_batch = shift
115 overlay_action => 'create_new',
116 import_status => 'staging',
117 batch_type => 'batch',
119 comments => 'inserted during automated testing',
121 my $batch_id = AddImportBatch( $test_batch->{'overlay_action'},
122 $test_batch->{'import_status'},
123 $test_batch->{'batch_type'},
124 $test_batch->{'file_name'},
125 $test_batch->{'comments'}, );