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

(-)a/t/db_dependent/Acquisition/FillWithDefaultValues.t (-3 / +3 lines)
Lines 7-16 use MARC::Field; Link Here
7
7
8
use C4::Context;
8
use C4::Context;
9
use C4::Acquisition qw( FillWithDefaultValues );
9
use C4::Acquisition qw( FillWithDefaultValues );
10
use Koha::Database;
10
11
11
my $dbh = C4::Context->dbh;
12
my $schema = Koha::Database->new->schema;
12
$dbh->{AutoCommit} = 0;
13
$schema->storage->txn_begin;
13
$dbh->{RaiseError} = 1;
14
14
15
my $biblio_module  = Test::MockModule->new('C4::Biblio');
15
my $biblio_module  = Test::MockModule->new('C4::Biblio');
16
my $default_author = 'default author';
16
my $default_author = 'default author';
(-)a/t/db_dependent/AdditionalField.t (-5 / +3 lines)
Lines 5-14 use Test::More tests => 40; Link Here
5
5
6
use C4::Context;
6
use C4::Context;
7
use Koha::AdditionalField;
7
use Koha::AdditionalField;
8
use Koha::Database;
8
9
10
my $schema = Koha::Database->new->schema;
11
$schema->storage->txn_begin;
9
my $dbh = C4::Context->dbh;
12
my $dbh = C4::Context->dbh;
10
$dbh->{AutoCommit} = 0;
11
$dbh->{RaiseError} = 1;
12
13
13
$dbh->do( q|DELETE FROM additional_fields| );
14
$dbh->do( q|DELETE FROM additional_fields| );
14
$dbh->do( q|DELETE FROM additional_field_values| );
15
$dbh->do( q|DELETE FROM additional_field_values| );
Lines 290-295 is_deeply ( $af1->values, {$subscriptionid2 => qq|value_for_af1_$subscriptionid2 Link Here
290
$af1->delete_values;
291
$af1->delete_values;
291
$af1->fetch_values;
292
$af1->fetch_values;
292
is_deeply ( $af1->values, {}, "fetch_values: no values" );
293
is_deeply ( $af1->values, {}, "fetch_values: no values" );
293
294
295
$dbh->rollback;
(-)a/t/db_dependent/Auth_with_cas.t (-8 / +3 lines)
Lines 22-27 use CGI; Link Here
22
22
23
use t::lib::Mocks;
23
use t::lib::Mocks;
24
use C4::Context;
24
use C4::Context;
25
use Koha::Database;
25
26
26
BEGIN {
27
BEGIN {
27
    use_ok('C4::Auth_with_cas');
28
    use_ok('C4::Auth_with_cas');
Lines 34-43 BEGIN { Link Here
34
            /);
35
            /);
35
}
36
}
36
37
38
my $schema = Koha::Database->new->schema;
39
$schema->storage->txn_begin;
37
my $dbh = C4::Context->dbh;
40
my $dbh = C4::Context->dbh;
38
# Start transaction
39
$dbh->{ AutoCommit } = 0;
40
$dbh->{ RaiseError } = 1;
41
41
42
C4::Context->disable_syspref_cache();
42
C4::Context->disable_syspref_cache();
43
t::lib::Mocks::mock_preference('OPACBaseURL','http://localhost');
43
t::lib::Mocks::mock_preference('OPACBaseURL','http://localhost');
Lines 63-70 $ENV{SCRIPT_NAME} = '/cgi-bin/koha/circ/circulation-home.pl'; Link Here
63
is(C4::Auth_with_cas::_url_with_get_params($cgi, 'intranet'),
63
is(C4::Auth_with_cas::_url_with_get_params($cgi, 'intranet'),
64
    "$staff_base_url/cgi-bin/koha/circ/circulation-home.pl?bar=baz",
64
    "$staff_base_url/cgi-bin/koha/circ/circulation-home.pl?bar=baz",
65
   "Intranet URL should be returned when using intranet login (Bug 13507)");
65
   "Intranet URL should be returned when using intranet login (Bug 13507)");
66
67
68
69
$dbh->rollback;
70
(-)a/t/db_dependent/BackgroundJob.t (-4 / +4 lines)
Lines 5-19 use C4::Auth; Link Here
5
use CGI qw ( -utf8 );
5
use CGI qw ( -utf8 );
6
use Test::More tests => 18;
6
use Test::More tests => 18;
7
7
8
use Koha::Database;
9
8
BEGIN {
10
BEGIN {
9
    use_ok('C4::BackgroundJob');
11
    use_ok('C4::BackgroundJob');
10
}
12
}
11
my $query = new CGI;
13
my $query = new CGI;
12
14
13
# Generate a session id
15
my $schema = Koha::Database->new->schema;
14
my $dbh     = C4::Context->dbh;
16
$schema->storage->txn_begin;
15
$dbh->{AutoCommit} = 0;
16
$dbh->{RaiseError} = 1;
17
17
18
my $session = C4::Auth::get_session;
18
my $session = C4::Auth::get_session;
19
$session->flush;
19
$session->flush;
(-)a/t/db_dependent/Charset.t (-4 / +4 lines)
Lines 6-14 use C4::Biblio qw( AddBiblio GetMarcFromKohaField ); Link Here
6
use C4::Context;
6
use C4::Context;
7
use C4::Charset qw( SanitizeRecord );
7
use C4::Charset qw( SanitizeRecord );
8
8
9
use Koha::Database;
10
11
my $schema = Koha::Database->new->schema;
12
$schema->storage->txn_begin;
9
my $dbh = C4::Context->dbh;
13
my $dbh = C4::Context->dbh;
10
$dbh->{RaiseError} = 1;
11
$dbh->{AutoCommit} = 0;
12
14
13
my $frameworkcode = q||;
15
my $frameworkcode = q||;
14
16
Lines 47-51 $record->append_fields( Link Here
47
( $sanitized_record, $has_been_modified ) = C4::Charset::SanitizeRecord( $record, $biblionumber );
49
( $sanitized_record, $has_been_modified ) = C4::Charset::SanitizeRecord( $record, $biblionumber );
48
is( $has_been_modified, 1, 'SanitizeRecord: the record has been modified' );
50
is( $has_been_modified, 1, 'SanitizeRecord: the record has been modified' );
49
is( $url, $sanitized_record->subfield($url_field, $url_subfield), 'SanitizeRecord: the url has not been modified');
51
is( $url, $sanitized_record->subfield($url_field, $url_subfield), 'SanitizeRecord: the url has not been modified');
50
51
$dbh->rollback;
(-)a/t/db_dependent/Circulation/CheckIfIssuedToPatron.t (-7 / +1 lines)
Lines 30-42 use MARC::Record; Link Here
30
30
31
my $schema = Koha::Database->schema;
31
my $schema = Koha::Database->schema;
32
$schema->storage->txn_begin;
32
$schema->storage->txn_begin;
33
my $dbh = C4::Context->dbh;
33
34
34
my $builder = t::lib::TestBuilder->new;
35
my $builder = t::lib::TestBuilder->new;
35
36
36
my $dbh = C4::Context->dbh;
37
$dbh->{AutoCommit} = 0;
38
$dbh->{RaiseError} = 1;
39
40
$dbh->do(q|DELETE FROM issues|);
37
$dbh->do(q|DELETE FROM issues|);
41
$dbh->do(q|DELETE FROM items|);
38
$dbh->do(q|DELETE FROM items|);
42
$dbh->do(q|DELETE FROM borrowers|);
39
$dbh->do(q|DELETE FROM borrowers|);
Lines 125-130 $check_if_issued = C4::Circulation::CheckIfIssuedToPatron($borrowernumber2, $bib Link Here
125
is( $check_if_issued, undef, 'CheckIfIssuedToPatron returns undef' );
122
is( $check_if_issued, undef, 'CheckIfIssuedToPatron returns undef' );
126
$check_if_issued = C4::Circulation::CheckIfIssuedToPatron($borrowernumber2, $biblionumber2);
123
$check_if_issued = C4::Circulation::CheckIfIssuedToPatron($borrowernumber2, $biblionumber2);
127
is( $check_if_issued, 1, 'CheckIfIssuedToPatron returns true' );
124
is( $check_if_issued, 1, 'CheckIfIssuedToPatron returns true' );
128
129
$dbh->rollback();
130
(-)a/t/db_dependent/Circulation/CheckValidBarcode.t (-5 / +3 lines)
Lines 22-27 use Test::More tests => 10; Link Here
22
use C4::Circulation;
22
use C4::Circulation;
23
use C4::Biblio;
23
use C4::Biblio;
24
use C4::Items;
24
use C4::Items;
25
use Koha::Database;
25
use Koha::Library;
26
use Koha::Library;
26
27
27
28
Lines 29-37 BEGIN { Link Here
29
    use_ok('C4::Circulation');
30
    use_ok('C4::Circulation');
30
}
31
}
31
32
33
my $schema = Koha::Database->new->schema;
34
$schema->storage->txn_begin;
32
my $dbh = C4::Context->dbh;
35
my $dbh = C4::Context->dbh;
33
$dbh->{AutoCommit} = 0;
34
$dbh->{RaiseError} = 1;
35
36
36
$dbh->do(q|DELETE FROM issues|);
37
$dbh->do(q|DELETE FROM issues|);
37
$dbh->do(q|DELETE FROM items|);
38
$dbh->do(q|DELETE FROM items|);
Lines 81-86 $check_valid_barcode = C4::Circulation::CheckValidBarcode($barcode3); Link Here
81
is( $check_valid_barcode, 1, 'CheckValidBarcode returns true' );
82
is( $check_valid_barcode, 1, 'CheckValidBarcode returns true' );
82
$check_valid_barcode = C4::Circulation::CheckValidBarcode('wrong barcode');
83
$check_valid_barcode = C4::Circulation::CheckValidBarcode('wrong barcode');
83
is( $check_valid_barcode, 0, 'CheckValidBarcode with an invalid barcode returns false' );
84
is( $check_valid_barcode, 0, 'CheckValidBarcode with an invalid barcode returns false' );
84
85
$dbh->rollback();
86
(-)a/t/db_dependent/Circulation/GetHardDueDate.t (-6 / +3 lines)
Lines 3-8 Link Here
3
use Modern::Perl;
3
use Modern::Perl;
4
use C4::Context;
4
use C4::Context;
5
use DateTime;
5
use DateTime;
6
use Koha::Database;
6
use Koha::DateUtils;
7
use Koha::DateUtils;
7
use Koha::IssuingRules;
8
use Koha::IssuingRules;
8
use Koha::Library;
9
use Koha::Library;
Lines 20-29 can_ok( Link Here
20
      )
21
      )
21
);
22
);
22
23
23
#Start transaction
24
my $schema = Koha::Database->new->schema;
25
$schema->storage->txn_begin;
24
my $dbh = C4::Context->dbh;
26
my $dbh = C4::Context->dbh;
25
$dbh->{RaiseError} = 1;
26
$dbh->{AutoCommit} = 0;
27
27
28
$dbh->do(q|DELETE FROM issues|);
28
$dbh->do(q|DELETE FROM issues|);
29
$dbh->do(q|DELETE FROM items|);
29
$dbh->do(q|DELETE FROM items|);
Lines 397-402 is_deeply( Link Here
397
    ],
397
    ],
398
    "GetHardDueDate returns the duedate and the duedatecompare"
398
    "GetHardDueDate returns the duedate and the duedatecompare"
399
);
399
);
400
401
#End transaction
402
$dbh->rollback;
(-)a/t/db_dependent/Circulation/OfflineOperation.t (-6 / +3 lines)
Lines 3-8 Link Here
3
use Modern::Perl;
3
use Modern::Perl;
4
use C4::Circulation;
4
use C4::Circulation;
5
5
6
use Koha::Database;
6
use Koha::DateUtils qw( dt_from_string output_pref );
7
use Koha::DateUtils qw( dt_from_string output_pref );
7
use Koha::Library;
8
use Koha::Library;
8
9
Lines 21-30 can_ok( Link Here
21
      )
22
      )
22
);
23
);
23
24
24
#Start transaction
25
my $schema = Koha::Database->new->schema;
26
$schema->storage->txn_begin;
25
my $dbh = C4::Context->dbh;
27
my $dbh = C4::Context->dbh;
26
$dbh->{RaiseError} = 1;
27
$dbh->{AutoCommit} = 0;
28
28
29
$dbh->do(q|DELETE FROM issues|);
29
$dbh->do(q|DELETE FROM issues|);
30
$dbh->do(q|DELETE FROM borrowers|);
30
$dbh->do(q|DELETE FROM borrowers|);
Lines 99-104 is( DeleteOfflineOperation($offline_id), Link Here
99
99
100
#is (DeleteOfflineOperation(), undef, 'DeleteOfflineOperation without id returns undef');
100
#is (DeleteOfflineOperation(), undef, 'DeleteOfflineOperation without id returns undef');
101
#is (DeleteOfflineOperation(-1),undef, 'DeleteOfflineOperation with a wrong id returns undef');#FIXME
101
#is (DeleteOfflineOperation(-1),undef, 'DeleteOfflineOperation with a wrong id returns undef');#FIXME
102
103
#End transaction
104
$dbh->rollback;
(-)a/t/db_dependent/ColumnsSettings.t (-4 / +4 lines)
Lines 6-14 use Test::MockModule; Link Here
6
6
7
use C4::Context;
7
use C4::Context;
8
use C4::Utils::DataTables::ColumnsSettings;
8
use C4::Utils::DataTables::ColumnsSettings;
9
use Koha::Database;
10
11
my $schema = Koha::Database->new->schema;
12
$schema->storage->txn_begin;
9
my $dbh = C4::Context->dbh;
13
my $dbh = C4::Context->dbh;
10
$dbh->{AutoCommit} = 0;
11
$dbh->{RaiseError} = 1;
12
14
13
$dbh->do(q|DELETE FROM columns_settings|);
15
$dbh->do(q|DELETE FROM columns_settings|);
14
16
Lines 180-184 for my $m ( keys %$modules ) { Link Here
180
        }
182
        }
181
    }
183
    }
182
}
184
}
183
184
$dbh->rollback;
(-)a/t/db_dependent/Contract.t (-4 / +3 lines)
Lines 20-25 Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use C4::Context;
22
use C4::Context;
23
use Koha::Database;
23
use Koha::DateUtils;
24
use Koha::DateUtils;
24
use Koha::Acquisition::Booksellers;
25
use Koha::Acquisition::Booksellers;
25
26
Lines 31-39 BEGIN { Link Here
31
    use_ok('C4::Contract');
32
    use_ok('C4::Contract');
32
}
33
}
33
34
35
my $schema = Koha::Database->new->schema;
36
$schema->storage->txn_begin;
34
my $dbh = C4::Context->dbh;
37
my $dbh = C4::Context->dbh;
35
$dbh->{AutoCommit} = 0;
36
$dbh->{RaiseError} = 1;
37
38
38
$dbh->do(q|DELETE FROM aqbasket|);
39
$dbh->do(q|DELETE FROM aqbasket|);
39
$dbh->do(q|DELETE FROM aqcontract|);
40
$dbh->do(q|DELETE FROM aqcontract|);
Lines 148-152 $del_status = DelContract( { contractnumber => $my_contract_id2 } ); Link Here
148
is( $del_status, 1, 'DelContract returns true' );
149
is( $del_status, 1, 'DelContract returns true' );
149
$contracts = GetContracts();
150
$contracts = GetContracts();
150
is( @$contracts, 0, 'DelContract deletes a contract' );
151
is( @$contracts, 0, 'DelContract deletes a contract' );
151
152
$dbh->rollback;
(-)a/t/db_dependent/Fines.t (-5 / +2 lines)
Lines 9-20 use Koha::DateUtils; Link Here
9
9
10
use Test::More tests => 5;
10
use Test::More tests => 5;
11
11
12
#Start transaction
12
my $schema = Koha::Database->new->schema;
13
$schema->storage->txn_begin;
13
my $dbh = C4::Context->dbh;
14
my $dbh = C4::Context->dbh;
14
my $schema = Koha::Database->new()->schema();
15
16
$dbh->{RaiseError} = 1;
17
$dbh->{AutoCommit} = 0;
18
15
19
$dbh->do(q|DELETE FROM issuingrules|);
16
$dbh->do(q|DELETE FROM issuingrules|);
20
17
(-)a/t/db_dependent/Koha/GetDailyQuote.t (-6 / +3 lines)
Lines 21-26 use Test::More tests => 12; Link Here
21
21
22
use C4::Koha qw( GetDailyQuote );
22
use C4::Koha qw( GetDailyQuote );
23
use DateTime::Format::MySQL;
23
use DateTime::Format::MySQL;
24
use Koha::Database;
24
use Koha::DateUtils qw(dt_from_string);
25
use Koha::DateUtils qw(dt_from_string);
25
26
26
BEGIN {
27
BEGIN {
Lines 29-40 BEGIN { Link Here
29
30
30
can_ok('C4::Koha', qw( GetDailyQuote ));
31
can_ok('C4::Koha', qw( GetDailyQuote ));
31
32
33
my $schema = Koha::Database->new->schema;
34
$schema->storage->txn_begin;
32
my $dbh = C4::Context->dbh;
35
my $dbh = C4::Context->dbh;
33
36
34
# Start transaction
35
$dbh->{AutoCommit} = 0;
36
$dbh->{RaiseError} = 1;
37
38
# Setup stage
37
# Setup stage
39
$dbh->do("DELETE FROM quotes");
38
$dbh->do("DELETE FROM quotes");
40
39
Lines 83-87 $dbh->do(q|INSERT INTO `quotes` VALUES Link Here
83
82
84
$quote = GetDailyQuote();
83
$quote = GetDailyQuote();
85
is( $quote->{id}, 6, ' GetDailyQuote returns the only existing quote' );
84
is( $quote->{id}, 6, ' GetDailyQuote returns the only existing quote' );
86
87
$dbh->rollback;
(-)a/t/db_dependent/Koha/Item/Search/Field.t (-4 / +3 lines)
Lines 4-16 use Modern::Perl; Link Here
4
use Test::More tests => 11;
4
use Test::More tests => 11;
5
5
6
use C4::Context;
6
use C4::Context;
7
use Koha::Database;
7
8
8
use_ok('Koha::Item::Search::Field');
9
use_ok('Koha::Item::Search::Field');
9
import Koha::Item::Search::Field qw(AddItemSearchField ModItemSearchField
10
import Koha::Item::Search::Field qw(AddItemSearchField ModItemSearchField
10
    DelItemSearchField GetItemSearchField GetItemSearchFields);
11
    DelItemSearchField GetItemSearchField GetItemSearchFields);
11
12
12
my $dbh = C4::Context->dbh;
13
my $schema = Koha::Database->new->schema;
13
$dbh->{AutoCommit} = 0;
14
$schema->storage->txn_begin;
14
15
15
# Start with empty table.
16
# Start with empty table.
16
foreach my $field (GetItemSearchFields()) {
17
foreach my $field (GetItemSearchFields()) {
Lines 35-39 is_deeply($field, {name => 'foo', label => 'Foo', tagfield => '001', tagsubfield Link Here
35
ok((defined ModItemSearchField({name => 'foo', label => 'Foobar', tagfield => '100', 'tagsubfield' => 'a'})), "successful mod");
36
ok((defined ModItemSearchField({name => 'foo', label => 'Foobar', tagfield => '100', 'tagsubfield' => 'a'})), "successful mod");
36
$field = GetItemSearchField('foo');
37
$field = GetItemSearchField('foo');
37
is_deeply($field, {name => 'foo', label => 'Foobar', tagfield => '100', tagsubfield => 'a', authorised_values_category => undef});
38
is_deeply($field, {name => 'foo', label => 'Foobar', tagfield => '100', tagsubfield => 'a', authorised_values_category => undef});
38
39
$dbh->rollback;
(-)a/t/db_dependent/Koha_Misc_Files.t (-5 / +3 lines)
Lines 5-19 Link Here
5
5
6
use Modern::Perl;
6
use Modern::Perl;
7
use C4::Context;
7
use C4::Context;
8
use Koha::Database;
8
use Test::More tests => 30;
9
use Test::More tests => 30;
9
10
10
BEGIN {
11
BEGIN {
11
    use_ok('Koha::Misc::Files');
12
    use_ok('Koha::Misc::Files');
12
}
13
}
13
14
15
my $schema = Koha::Database->new->schema;
16
$schema->storage->txn_begin;
14
my $dbh = C4::Context->dbh;
17
my $dbh = C4::Context->dbh;
15
$dbh->{AutoCommit} = 0;
16
$dbh->{RaiseError} = 1;
17
18
18
## new() parameter handling check
19
## new() parameter handling check
19
is(Koha::Misc::Files->new(), undef, "new() param check test/0");
20
is(Koha::Misc::Files->new(), undef, "new() param check test/0");
Lines 84-89 is(scalar @$files_a_123_infos, 0, "GetFilesInfo() result count after DelAllFiles Link Here
84
my $number_of_deleted_files_b_221 = $mf_b_221->DelAllFiles();
85
my $number_of_deleted_files_b_221 = $mf_b_221->DelAllFiles();
85
is( $number_of_deleted_files_b_221, 1, "DelAllFiles returns the number of deleted files/2" );
86
is( $number_of_deleted_files_b_221, 1, "DelAllFiles returns the number of deleted files/2" );
86
is(scalar @{$mf_b_221->GetFilesInfo()}, 0, "GetFilesInfo() result count after DelAllFiles()/2");
87
is(scalar @{$mf_b_221->GetFilesInfo()}, 0, "GetFilesInfo() result count after DelAllFiles()/2");
87
88
$dbh->rollback;
89
(-)a/t/db_dependent/Labels/t_Batch.t (-5 / +3 lines)
Lines 29-44 use t::lib::TestBuilder; Link Here
29
use C4::Context;
29
use C4::Context;
30
use C4::Items;
30
use C4::Items;
31
use C4::Biblio;
31
use C4::Biblio;
32
use Koha::Database;
32
use Koha::Libraries;
33
use Koha::Libraries;
33
34
34
BEGIN {
35
BEGIN {
35
    use_ok('C4::Labels::Batch');
36
    use_ok('C4::Labels::Batch');
36
}
37
}
37
38
38
# Start transaction
39
my $schema = Koha::Database->new->schema;
40
$schema->storage->txn_begin;
39
my $dbh = C4::Context->dbh;
41
my $dbh = C4::Context->dbh;
40
$dbh->{AutoCommit} = 0;
41
$dbh->{RaiseError} = 1;
42
42
43
my $builder = t::lib::TestBuilder->new;
43
my $builder = t::lib::TestBuilder->new;
44
$builder->build({ source => 'Branch', value => { branchcode => 'CPL' } })
44
$builder->build({ source => 'Branch', value => { branchcode => 'CPL' } })
Lines 120-124 is_deeply($updated_batch, $batch, "Updated batch object is correct."); Link Here
120
# Testing Batch->delete() method.
120
# Testing Batch->delete() method.
121
my $del_results = $batch->delete();
121
my $del_results = $batch->delete();
122
ok($del_results eq 0, "Batch->delete() success.");
122
ok($del_results eq 0, "Batch->delete() success.");
123
124
$dbh->rollback;
(-)a/t/db_dependent/Languages.t (-6 / +4 lines)
Lines 3-24 Link Here
3
# This Koha test module is a stub!  
3
# This Koha test module is a stub!  
4
# Add more tests here!!!
4
# Add more tests here!!!
5
5
6
use strict;
6
use Modern::Perl;
7
use warnings;
8
7
9
use Test::More tests => 17;
8
use Test::More tests => 17;
10
use List::Util qw(first);
9
use List::Util qw(first);
11
use Data::Dumper;
10
use Data::Dumper;
12
use Test::Warn;
11
use Test::Warn;
13
use t::lib::Mocks;
12
use t::lib::Mocks;
13
use Koha::Database;
14
14
15
BEGIN {
15
BEGIN {
16
    use_ok('C4::Languages');
16
    use_ok('C4::Languages');
17
}
17
}
18
18
19
my $schema = Koha::Database->new->schema;
20
$schema->storage->txn_begin;
19
my $dbh = C4::Context->dbh;
21
my $dbh = C4::Context->dbh;
20
$dbh->{AutoCommit} = 0;
21
$dbh->{RaiseError} = 1;
22
22
23
isnt(C4::Languages::_get_themes(), undef, 'testing _get_themes doesnt return undef');
23
isnt(C4::Languages::_get_themes(), undef, 'testing _get_themes doesnt return undef');
24
24
Lines 94-98 $sth->execute(); Link Here
94
my $LangRfc4646 = $sth->fetchall_arrayref({});
94
my $LangRfc4646 = $sth->fetchall_arrayref({});
95
95
96
is(scalar(@$LangRfc4646),scalar(@$DistinctLangRfc4646),"No unexpected language_rfc4646_to_iso639 duplicates.");
96
is(scalar(@$LangRfc4646),scalar(@$DistinctLangRfc4646),"No unexpected language_rfc4646_to_iso639 duplicates.");
97
98
$dbh->rollback;
(-)a/t/db_dependent/Letters/GetLetterTemplates.t (-2 / +3 lines)
Lines 3-12 use Test::More tests => 7; Link Here
3
3
4
use C4::Context;
4
use C4::Context;
5
use C4::Letters qw( GetLetterTemplates );
5
use C4::Letters qw( GetLetterTemplates );
6
use Koha::Database;
6
7
8
my $schema = Koha::Database->new->schema;
9
$schema->storage->txn_begin;
7
my $dbh = C4::Context->dbh;
10
my $dbh = C4::Context->dbh;
8
$dbh->{RaiseError} = 1;
9
$dbh->{AutoCommit} = 0;
10
11
11
$dbh->do(q|DELETE FROM letter|);
12
$dbh->do(q|DELETE FROM letter|);
12
13
(-)a/t/db_dependent/Letters/GetLettersAvailableForALibrary.t (-2 / +3 lines)
Lines 3-12 use Test::More tests => 19; Link Here
3
3
4
use C4::Context;
4
use C4::Context;
5
use C4::Letters qw( GetLettersAvailableForALibrary DelLetter );
5
use C4::Letters qw( GetLettersAvailableForALibrary DelLetter );
6
use Koha::Database;
6
7
8
my $schema = Koha::Database->new->schema;
9
$schema->storage->txn_begin;
7
my $dbh = C4::Context->dbh;
10
my $dbh = C4::Context->dbh;
8
$dbh->{RaiseError} = 1;
9
$dbh->{AutoCommit} = 0;
10
11
11
$dbh->do(q|DELETE FROM letter|);
12
$dbh->do(q|DELETE FROM letter|);
12
13
(-)a/t/db_dependent/LibraryGroups.t (-3 / +4 lines)
Lines 7-12 use List::MoreUtils 'any'; Link Here
7
use Test::More tests => 20;
7
use Test::More tests => 20;
8
8
9
use t::lib::TestBuilder;
9
use t::lib::TestBuilder;
10
use Koha::Database;
10
11
11
BEGIN {
12
BEGIN {
12
    use FindBin;
13
    use FindBin;
Lines 15-23 BEGIN { Link Here
15
    use_ok('Koha::Library::Groups');
16
    use_ok('Koha::Library::Groups');
16
}
17
}
17
18
18
our $dbh = C4::Context->dbh;
19
my $schema = Koha::Database->new->schema;
19
$dbh->{AutoCommit} = 0;
20
$schema->storage->txn_begin;
20
$dbh->{RaiseError} = 1;
21
my $dbh = C4::Context->dbh;
21
22
22
$dbh->do(q|DELETE FROM issues|);
23
$dbh->do(q|DELETE FROM issues|);
23
$dbh->do(q|DELETE FROM library_groups|);
24
$dbh->do(q|DELETE FROM library_groups|);
(-)a/t/db_dependent/MarcModificationTemplates.t (-2 / +3 lines)
Lines 2-16 use Modern::Perl; Link Here
2
2
3
use Test::More tests => 115;
3
use Test::More tests => 115;
4
4
5
use Koha::Database;
5
use Koha::SimpleMARC;
6
use Koha::SimpleMARC;
6
7
7
use_ok("MARC::Field");
8
use_ok("MARC::Field");
8
use_ok("MARC::Record");
9
use_ok("MARC::Record");
9
use_ok("C4::MarcModificationTemplates");
10
use_ok("C4::MarcModificationTemplates");
10
11
12
my $schema = Koha::Database->new->schema;
13
$schema->storage->txn_begin;
11
my $dbh = C4::Context->dbh;
14
my $dbh = C4::Context->dbh;
12
$dbh->{AutoCommit} = 0;
13
$dbh->{RaiseError} = 1;
14
15
15
$dbh->do(q|DELETE FROM marc_modification_templates|);
16
$dbh->do(q|DELETE FROM marc_modification_templates|);
16
17
(-)a/t/db_dependent/MungeMarcPrice.t (-9 / +4 lines)
Lines 1-20 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
use strict;
3
use Modern::Perl;
4
use warnings;
5
use C4::Biblio;
4
use C4::Biblio;
5
use Koha::Database;
6
use Koha::Acquisition::Currencies;
6
use Koha::Acquisition::Currencies;
7
use Test::More;
7
use Test::More;
8
use utf8;
9
8
10
# work around wide character warnings
9
# work around wide character warnings
11
binmode Test::More->builder->output, ":encoding(UTF-8)";
10
binmode Test::More->builder->output, ":encoding(UTF-8)";
12
binmode Test::More->builder->failure_output, ":encoding(UTF-8)";
11
binmode Test::More->builder->failure_output, ":encoding(UTF-8)";
13
12
14
# start transaction
13
my $schema = Koha::Database->new->schema;
14
$schema->storage->txn_begin;
15
my $dbh = C4::Context->dbh;
15
my $dbh = C4::Context->dbh;
16
$dbh->{AutoCommit} = 0;
17
$dbh->{RaiseError} = 1;
18
16
19
# set some test price strings and expected output
17
# set some test price strings and expected output
20
my @prices2test=( { string => '25,5 £, $34,55, $LD35',       expected => '34.55' },
18
my @prices2test=( { string => '25,5 £, $34,55, $LD35',       expected => '34.55' },
Lines 69-74 foreach my $price (@prices2test) { Link Here
69
        "got expected price from $price->{'string'} (using ISO code as currency name)",
67
        "got expected price from $price->{'string'} (using ISO code as currency name)",
70
    );
68
    );
71
}
69
}
72
73
# Cleanup
74
$dbh->rollback;
(-)a/t/db_dependent/NewsChannels.t (-6 / +3 lines)
Lines 1-6 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
use Koha::Database;
4
use Koha::DateUtils;
5
use Koha::DateUtils;
5
use Koha::Libraries;
6
use Koha::Libraries;
6
7
Lines 10-21 BEGIN { Link Here
10
    use_ok('C4::NewsChannels');
11
    use_ok('C4::NewsChannels');
11
}
12
}
12
13
14
my $schema = Koha::Database->new->schema;
15
$schema->storage->txn_begin;
13
my $dbh = C4::Context->dbh;
16
my $dbh = C4::Context->dbh;
14
17
15
# Start transaction
16
$dbh->{AutoCommit} = 0;
17
$dbh->{RaiseError} = 1;
18
19
# Add LIB1, if it doesn't exist.
18
# Add LIB1, if it doesn't exist.
20
my $addbra = 'LIB1';
19
my $addbra = 'LIB1';
21
unless ( Koha::Libraries->find($addbra) ) {
20
unless ( Koha::Libraries->find($addbra) ) {
Lines 226-230 subtest 'Regression tests on author title, firstname, and surname.', sub { Link Here
226
    ok($check==3,'Both with and without author data tested');
225
    ok($check==3,'Both with and without author data tested');
227
    done_testing();
226
    done_testing();
228
};
227
};
229
230
$dbh->rollback;
(-)a/t/db_dependent/Overdues.t (-2 / +3 lines)
Lines 4-17 use Modern::Perl; Link Here
4
use Test::More tests => 16;
4
use Test::More tests => 16;
5
5
6
use C4::Context;
6
use C4::Context;
7
use Koha::Database;
7
use Koha::Libraries;
8
use Koha::Libraries;
8
use_ok('C4::Overdues');
9
use_ok('C4::Overdues');
9
can_ok('C4::Overdues', 'GetOverdueMessageTransportTypes');
10
can_ok('C4::Overdues', 'GetOverdueMessageTransportTypes');
10
can_ok('C4::Overdues', 'GetBranchcodesWithOverdueRules');
11
can_ok('C4::Overdues', 'GetBranchcodesWithOverdueRules');
11
12
13
my $schema = Koha::Database->new->schema;
14
$schema->storage->txn_begin;
12
my $dbh = C4::Context->dbh;
15
my $dbh = C4::Context->dbh;
13
$dbh->{AutoCommit} = 0;
14
$dbh->{RaiseError} = 1;
15
16
16
$dbh->do(q|DELETE FROM letter|);
17
$dbh->do(q|DELETE FROM letter|);
17
$dbh->do(q|DELETE FROM message_queue|);
18
$dbh->do(q|DELETE FROM message_queue|);
(-)a/t/db_dependent/Record.t (-4 / +3 lines)
Lines 7-21 use MARC::Record; Link Here
7
7
8
use t::lib::Mocks;
8
use t::lib::Mocks;
9
use C4::Context;
9
use C4::Context;
10
use Koha::Database;
10
11
11
BEGIN {
12
BEGIN {
12
        use_ok('C4::Record');
13
        use_ok('C4::Record');
13
}
14
}
14
15
15
my $dbh = C4::Context->dbh;
16
my $schema = Koha::Database->new->schema;
16
# Start transaction
17
$schema->storage->txn_begin;
17
$dbh->{AutoCommit} = 0;
18
$dbh->{RaiseError} = 1;
19
18
20
t::lib::Mocks::mock_preference( "BibtexExportAdditionalFields", q{} );
19
t::lib::Mocks::mock_preference( "BibtexExportAdditionalFields", q{} );
21
20
(-)a/t/db_dependent/Record/marcrecord2csv.t (-2 / +3 lines)
Lines 10-21 use Text::CSV::Encoded; Link Here
10
use C4::Biblio qw( AddBiblio );
10
use C4::Biblio qw( AddBiblio );
11
use C4::Context;
11
use C4::Context;
12
use C4::Record;
12
use C4::Record;
13
use Koha::Database;
13
14
14
use t::lib::TestBuilder;
15
use t::lib::TestBuilder;
15
16
17
my $schema = Koha::Database->new->schema;
18
$schema->storage->txn_begin;
16
my $dbh = C4::Context->dbh;
19
my $dbh = C4::Context->dbh;
17
$dbh->{AutoCommit} = 0;
18
$dbh->{RaiseError} = 1;
19
20
20
my $builder = t::lib::TestBuilder->new;
21
my $builder = t::lib::TestBuilder->new;
21
my $module_biblio = Test::MockModule->new('C4::Biblio');
22
my $module_biblio = Test::MockModule->new('C4::Biblio');
(-)a/t/db_dependent/RotatingCollections.t (-7 / +3 lines)
Lines 21-26 use Test::More tests => 51; Link Here
21
use C4::Context;
21
use C4::Context;
22
use C4::RotatingCollections;
22
use C4::RotatingCollections;
23
use C4::Biblio;
23
use C4::Biblio;
24
use Koha::Database;
24
use Koha::Library;
25
use Koha::Library;
25
26
26
BEGIN {
27
BEGIN {
Lines 44-53 can_ok( Link Here
44
      )
45
      )
45
);
46
);
46
47
47
#Start transaction
48
my $schema = Koha::Database->new->schema;
49
$schema->storage->txn_begin;
48
my $dbh = C4::Context->dbh;
50
my $dbh = C4::Context->dbh;
49
$dbh->{RaiseError} = 1;
50
$dbh->{AutoCommit} = 0;
51
51
52
#Start Tests
52
#Start Tests
53
$dbh->do(q|DELETE FROM issues |);
53
$dbh->do(q|DELETE FROM issues |);
Lines 330-336 is( Link Here
330
    $countcollection + 1,
330
    $countcollection + 1,
331
    "Two Collections have been deleted"
331
    "Two Collections have been deleted"
332
);
332
);
333
334
#End transaction
335
$dbh->rollback;
336
(-)a/t/db_dependent/Serials.t (-7 / +3 lines)
Lines 6-12 Link Here
6
use Modern::Perl;
6
use Modern::Perl;
7
use YAML;
7
use YAML;
8
8
9
use CGI qw ( -utf8 );
10
use C4::Serials;
9
use C4::Serials;
11
use C4::Serials::Frequency;
10
use C4::Serials::Frequency;
12
use C4::Serials::Numberpattern;
11
use C4::Serials::Numberpattern;
Lines 14-19 use C4::Debug; Link Here
14
use C4::Biblio;
13
use C4::Biblio;
15
use C4::Budgets;
14
use C4::Budgets;
16
use C4::Items;
15
use C4::Items;
16
use Koha::Database;
17
use Koha::DateUtils;
17
use Koha::DateUtils;
18
use Koha::Acquisition::Booksellers;
18
use Koha::Acquisition::Booksellers;
19
use t::lib::Mocks;
19
use t::lib::Mocks;
Lines 24-35 BEGIN { Link Here
24
    use_ok('C4::Serials');
24
    use_ok('C4::Serials');
25
}
25
}
26
26
27
my $schema = Koha::Database->new->schema;
28
$schema->storage->txn_begin;
27
my $dbh = C4::Context->dbh;
29
my $dbh = C4::Context->dbh;
28
30
29
# Start transaction
30
$dbh->{AutoCommit} = 0;
31
$dbh->{RaiseError} = 1;
32
33
my $builder = t::lib::TestBuilder->new();
31
my $builder = t::lib::TestBuilder->new();
34
32
35
# This could/should be used for all untested methods
33
# This could/should be used for all untested methods
Lines 348-355 subtest "Do not generate an expected if one already exists" => sub { Link Here
348
    is( @serialsByStatus, 1, "ModSerialStatus delete corectly serial expected and not create another if exists" );
346
    is( @serialsByStatus, 1, "ModSerialStatus delete corectly serial expected and not create another if exists" );
349
};
347
};
350
348
351
$dbh->rollback;
352
353
sub get_biblio {
349
sub get_biblio {
354
    my $bib = MARC::Record->new();
350
    my $bib = MARC::Record->new();
355
    $bib->append_fields(
351
    $bib->append_fields(
(-)a/t/db_dependent/Serials/Claims.t (-2 / +3 lines)
Lines 3-16 use Test::More tests => 17; Link Here
3
3
4
use C4::Acquisition;
4
use C4::Acquisition;
5
use C4::Budgets;
5
use C4::Budgets;
6
use Koha::Database;
6
use Koha::Acquisition::Booksellers;
7
use Koha::Acquisition::Booksellers;
7
use_ok('C4::Serials');
8
use_ok('C4::Serials');
8
9
9
use Koha::DateUtils qw( dt_from_string output_pref );
10
use Koha::DateUtils qw( dt_from_string output_pref );
10
11
12
my $schema = Koha::Database->new->schema;
13
$schema->storage->txn_begin;
11
my $dbh = C4::Context->dbh;
14
my $dbh = C4::Context->dbh;
12
$dbh->{AutoCommit} = 0;
13
$dbh->{RaiseError} = 1;
14
15
15
$dbh->do(q|DELETE FROM issues|);
16
$dbh->do(q|DELETE FROM issues|);
16
$dbh->do(q|DELETE FROM subscription|);
17
$dbh->do(q|DELETE FROM subscription|);
(-)a/t/db_dependent/Serials/Frequency.t (-4 / +3 lines)
Lines 1-12 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
use C4::Context;
3
use C4::Context;
4
use Koha::Database;
4
use Test::More tests => 27;
5
use Test::More tests => 27;
5
use Modern::Perl;
6
use Modern::Perl;
6
7
8
my $schema = Koha::Database->new->schema;
9
$schema->storage->txn_begin;
7
my $dbh = C4::Context->dbh;
10
my $dbh = C4::Context->dbh;
8
$dbh->{RaiseError} = 1;
9
$dbh->{AutoCommit} = 0;
10
11
11
use C4::Serials::Frequency;
12
use C4::Serials::Frequency;
12
13
Lines 86-90 is(scalar @frequencies, 1, "There is one frequency"); Link Here
86
DelSubscriptionFrequency($id2);
87
DelSubscriptionFrequency($id2);
87
@frequencies = GetSubscriptionFrequencies();
88
@frequencies = GetSubscriptionFrequencies();
88
is(scalar @frequencies, 0, "There is no frequency");
89
is(scalar @frequencies, 0, "There is no frequency");
89
90
$dbh->rollback;
(-)a/t/db_dependent/Serials/GetNextSeq.t (-5 / +3 lines)
Lines 3-12 Link Here
3
use C4::Context;
3
use C4::Context;
4
use Test::More tests => 32;
4
use Test::More tests => 32;
5
use Modern::Perl;
5
use Modern::Perl;
6
use Koha::Database;
6
7
8
my $schema = Koha::Database->new->schema;
9
$schema->storage->txn_begin;
7
my $dbh = C4::Context->dbh;
10
my $dbh = C4::Context->dbh;
8
$dbh->{RaiseError} = 1;
9
$dbh->{AutoCommit} = 0;
10
11
11
use C4::Serials::Frequency;
12
use C4::Serials::Frequency;
12
use C4::Serials;
13
use C4::Serials;
Lines 264-272 $publisheddate = GetNextDate($subscription, $publisheddate); Link Here
264
$seq = _next_seq($subscription, $pattern, $publisheddate);
265
$seq = _next_seq($subscription, $pattern, $publisheddate);
265
is($seq, 'Z: 4, Y: 5, X: 1');
266
is($seq, 'Z: 4, Y: 5, X: 1');
266
267
267
268
$dbh->rollback;
269
270
sub _next_seq {
268
sub _next_seq {
271
    my ($subscription, $pattern, $publisheddate) = @_;
269
    my ($subscription, $pattern, $publisheddate) = @_;
272
    my $seq;
270
    my $seq;
(-)a/t/db_dependent/Serials/Numberpattern.t (-6 / +6 lines)
Lines 1-12 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
use C4::Context;
4
use Test::More tests => 95;
5
use Modern::Perl;
3
use Modern::Perl;
4
use Test::More tests => 95;
6
5
6
use C4::Context;
7
use Koha::Database;
8
9
my $schema = Koha::Database->new->schema;
10
$schema->storage->txn_begin;
7
my $dbh = C4::Context->dbh;
11
my $dbh = C4::Context->dbh;
8
$dbh->{RaiseError} = 1;
9
$dbh->{AutoCommit} = 0;
10
12
11
use C4::Serials::Numberpattern;
13
use C4::Serials::Numberpattern;
12
14
Lines 99-103 is(scalar @numberpatterns, 1, "There is one numberpattern"); Link Here
99
DelSubscriptionNumberpattern($id2);
101
DelSubscriptionNumberpattern($id2);
100
@numberpatterns = GetSubscriptionNumberpatterns();
102
@numberpatterns = GetSubscriptionNumberpatterns();
101
is(scalar @numberpatterns, 0, "There is no numberpattern");
103
is(scalar @numberpatterns, 0, "There is no numberpattern");
102
103
$dbh->rollback;
(-)a/t/db_dependent/Stats.t (-6 / +3 lines)
Lines 2-7 Link Here
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
use C4::Stats;
4
use C4::Stats;
5
use Koha::Database;
5
6
6
use Test::More tests => 19;
7
use Test::More tests => 19;
7
8
Lines 13-22 can_ok( Link Here
13
    qw(UpdateStats)
14
    qw(UpdateStats)
14
);
15
);
15
16
16
#Start transaction
17
my $schema = Koha::Database->new->schema;
18
$schema->storage->txn_begin;
17
my $dbh = C4::Context->dbh;
19
my $dbh = C4::Context->dbh;
18
$dbh->{RaiseError} = 1;
19
$dbh->{AutoCommit} = 0;
20
20
21
#
21
#
22
# Test UpdateStats
22
# Test UpdateStats
Lines 163-168 is( $line->{location}, undef, Link Here
163
    "UpdateStats sets location to NULL if undef is passed in." );
163
    "UpdateStats sets location to NULL if undef is passed in." );
164
164
165
# More tests to write!
165
# More tests to write!
166
167
#End transaction
168
$dbh->rollback;
(-)a/t/db_dependent/Virtualshelves.t (-1 / +3 lines)
Lines 5-10 use Test::More tests => 6; Link Here
5
use DateTime::Duration;
5
use DateTime::Duration;
6
6
7
use C4::Context;
7
use C4::Context;
8
use Koha::Database;
8
use Koha::DateUtils;
9
use Koha::DateUtils;
9
use Koha::Virtualshelves;
10
use Koha::Virtualshelves;
10
use Koha::Virtualshelfshares;
11
use Koha::Virtualshelfshares;
Lines 15-22 use t::lib::TestBuilder; Link Here
15
16
16
my $builder = t::lib::TestBuilder->new;
17
my $builder = t::lib::TestBuilder->new;
17
18
19
my $schema = Koha::Database->new->schema;
20
$schema->storage->txn_begin;
18
my $dbh = C4::Context->dbh;
21
my $dbh = C4::Context->dbh;
19
$dbh->{AutoCommit} = 0;
20
teardown();
22
teardown();
21
23
22
subtest 'CRUD' => sub {
24
subtest 'CRUD' => sub {
(-)a/t/db_dependent/XISBN.t (-5 / +3 lines)
Lines 11-16 use C4::Biblio; Link Here
11
use C4::XISBN;
11
use C4::XISBN;
12
use C4::Context;
12
use C4::Context;
13
use C4::Search;
13
use C4::Search;
14
use Koha::Database;
14
use t::lib::Mocks;
15
use t::lib::Mocks;
15
use Test::MockModule;
16
use Test::MockModule;
16
17
Lines 18-26 BEGIN { Link Here
18
    use_ok('C4::XISBN');
19
    use_ok('C4::XISBN');
19
}
20
}
20
21
21
my $dbh = C4::Context->dbh;
22
my $schema = Koha::Database->new->schema;
22
$dbh->{RaiseError} = 1;
23
$schema->storage->txn_begin;
23
$dbh->{AutoCommit} = 0;
24
24
25
my $search_module = new Test::MockModule('C4::Search');
25
my $search_module = new Test::MockModule('C4::Search');
26
26
Lines 62-69 SKIP: { Link Here
62
        "Gets correct biblionumber from a book with a similar isbn using ThingISBN." );
62
        "Gets correct biblionumber from a book with a similar isbn using ThingISBN." );
63
}
63
}
64
64
65
$dbh->rollback;
66
67
# Util subs
65
# Util subs
68
66
69
# Add new biblio with isbn and return biblionumber
67
# Add new biblio with isbn and return biblionumber
(-)a/t/db_dependent/sysprefs.t (-6 / +3 lines)
Lines 21-31 Link Here
21
use Modern::Perl;
21
use Modern::Perl;
22
use Test::More tests => 8;
22
use Test::More tests => 8;
23
use C4::Context;
23
use C4::Context;
24
use Koha::Database;
24
25
25
# Start transaction
26
my $schema = Koha::Database->new->schema;
27
$schema->storage->txn_begin;
26
my $dbh = C4::Context->dbh;
28
my $dbh = C4::Context->dbh;
27
$dbh->{RaiseError} = 1;
28
$dbh->{AutoCommit} = 0;
29
29
30
my $opacheader    = C4::Context->preference('opacheader');
30
my $opacheader    = C4::Context->preference('opacheader');
31
my $newopacheader = "newopacheader";
31
my $newopacheader = "newopacheader";
Lines 59-63 $dbh->do("DELETE FROM systempreferences WHERE variable='testpreference'"); Link Here
59
is(C4::Context->preference('testpreference'), 'def', 'caching preferences');
59
is(C4::Context->preference('testpreference'), 'def', 'caching preferences');
60
C4::Context->clear_syspref_cache();
60
C4::Context->clear_syspref_cache();
61
is(C4::Context->preference('testpreference'), undef, 'clearing preference cache');
61
is(C4::Context->preference('testpreference'), undef, 'clearing preference cache');
62
63
$dbh->rollback;
64
- 

Return to bug 14334