Lines 17-22
Link Here
|
17 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
17 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
18 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
18 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
19 |
|
19 |
|
|
|
20 |
# Main object of this unit test is the Breeding module and its subroutines |
21 |
# A start has been made to define tests for subroutines of Z3950Search. |
22 |
# These subroutines are actually internal, but these tests may pave the way for |
23 |
# a more comprehensive test of Z3950Search itself. |
24 |
# |
25 |
# TODO We need additional tests for Z3950SearchAuth, BreedingSearch |
26 |
|
20 |
use Modern::Perl; |
27 |
use Modern::Perl; |
21 |
|
28 |
|
22 |
use FindBin; |
29 |
use FindBin; |
Lines 26-40
use t::lib::Mocks qw( mock_preference );
Link Here
|
26 |
|
33 |
|
27 |
use C4::Context; |
34 |
use C4::Context; |
28 |
use C4::Breeding; |
35 |
use C4::Breeding; |
|
|
36 |
use Koha::Database; |
29 |
use Koha::XSLT_Handler; |
37 |
use Koha::XSLT_Handler; |
30 |
|
38 |
|
31 |
#Main object of this unit test is the Breeding module and its subroutines |
39 |
my $schema = Koha::Database->new->schema; |
32 |
#A start has been made to define tests for subroutines of Z3950Search. |
40 |
$schema->storage->txn_begin; |
33 |
#These subroutines are actually internal, but these tests may pave the way for |
|
|
34 |
#a more comprehensive test of Z3950Search itself. |
35 |
#TODO |
36 |
#Furthermore, we need additional tests for: |
37 |
#Z3950SearchAuth, BreedingSearch, ImportBreedingAuth |
38 |
|
41 |
|
39 |
#Group 1: testing _build_query and _translate_query (part of Z3950Search) |
42 |
#Group 1: testing _build_query and _translate_query (part of Z3950Search) |
40 |
subtest '_build_query' => sub { |
43 |
subtest '_build_query' => sub { |
Lines 66-86
subtest ImportBreedingAuth => sub {
Link Here
|
66 |
MARC::Field->new('100', ' ', ' ', a => 'Jansson, Tove'), |
69 |
MARC::Field->new('100', ' ', ' ', a => 'Jansson, Tove'), |
67 |
); |
70 |
); |
68 |
|
71 |
|
69 |
my $breedingid = C4::Breeding::ImportBreedingAuth($record,"kidclamp","UTF8"); |
72 |
my $breedingid = C4::Breeding::ImportBreedingAuth($record,"kidclamp","UTF-8",'Jansson, Tove' ); |
70 |
ok( $breedingid, "We got a breeding id back"); |
73 |
ok( $breedingid, "We got a breeding id back"); |
71 |
my $breedingid_1 = C4::Breeding::ImportBreedingAuth($record,"kidclamp","UTF8"); |
74 |
my $breedingid_1 = C4::Breeding::ImportBreedingAuth($record,"kidclamp","UTF-8",'Jansson, Tove' ); |
72 |
is( $breedingid, $breedingid_1, "For the same record, we get the same id"); |
75 |
is( $breedingid, $breedingid_1, "For the same record, we get the same id"); |
73 |
$breedingid_1 = C4::Breeding::ImportBreedingAuth($record,"marcelr","UTF8"); |
76 |
$breedingid_1 = C4::Breeding::ImportBreedingAuth($record,"marcelr","UTF-8",'Jansson, Tove' ); |
74 |
is( $breedingid, $breedingid_1, "For the same record in a different file, we get a new id"); |
77 |
is( $breedingid, $breedingid_1, "For the same record in a different file, we get a new id"); |
75 |
my $record_1 = MARC::Record->new(); |
78 |
my $record_1 = MARC::Record->new(); |
76 |
$record_1->append_fields( |
79 |
$record_1->append_fields( |
77 |
MARC::Field->new('001', '8675309'), |
80 |
MARC::Field->new('001', '8675309'), |
78 |
MARC::Field->new('100', ' ', ' ', a => 'Cooper, Susan'), |
81 |
MARC::Field->new('100', ' ', ' ', a => 'Cooper, Susan'), |
79 |
); |
82 |
); |
80 |
my $breedingid_2 = C4::Breeding::ImportBreedingAuth($record_1,"kidclamp","UTF8"); |
83 |
my $breedingid_2 = C4::Breeding::ImportBreedingAuth($record_1,"kidclamp","UTF-8",'Cooper, Susan' ); |
81 |
isnt( $breedingid, $breedingid_2, "For a new record, we get a new id"); |
84 |
isnt( $breedingid, $breedingid_2, "For a new record, we get a new id"); |
82 |
}; |
85 |
}; |
83 |
|
86 |
|
|
|
87 |
$schema->storage->txn_rollback; |
88 |
|
84 |
#------------------------------------------------------------------------------- |
89 |
#------------------------------------------------------------------------------- |
85 |
|
90 |
|
86 |
sub test_build_translate_query { |
91 |
sub test_build_translate_query { |
87 |
- |
|
|