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

(-)a/t/db_dependent/Accounts.t (-2 / +2 lines)
Lines 103-110 my @test_data = ( Link Here
103
    { amount => -5    , days_ago => $days     , description =>'purge_zero_balance_fees should not delete fees with negative amout owed on threshold day'     , delete => 0 } ,
103
    { amount => -5    , days_ago => $days     , description =>'purge_zero_balance_fees should not delete fees with negative amout owed on threshold day'     , delete => 0 } ,
104
    { amount => -5    , days_ago => $days + 1 , description =>'purge_zero_balance_fees should not delete fees with negative amout owed after threshold day'  , delete => 0 }
104
    { amount => -5    , days_ago => $days + 1 , description =>'purge_zero_balance_fees should not delete fees with negative amout owed after threshold day'  , delete => 0 }
105
);
105
);
106
106
my $categorycode = $builder->build({ source => 'Category' })->{categorycode};
107
my $borrower = Koha::Patron->new( { firstname => 'Test', surname => 'Patron', categorycode => 'PT', branchcode => $branchcode } )->store();
107
my $borrower = Koha::Patron->new( { firstname => 'Test', surname => 'Patron', categorycode => $categorycode, branchcode => $branchcode } )->store();
108
108
109
for my $data ( @test_data ) {
109
for my $data ( @test_data ) {
110
    $sth->execute($borrower->borrowernumber, $data->{amount}, $data->{days_ago}, $data->{description});
110
    $sth->execute($borrower->borrowernumber, $data->{amount}, $data->{days_ago}, $data->{description});
(-)a/t/db_dependent/Acquisition/OrderFromSubscription.t (-1 / +6 lines)
Lines 2-7 use Modern::Perl; Link Here
2
2
3
use Test::More tests => 12;
3
use Test::More tests => 12;
4
4
5
use t::lib::TestBuilder;
6
5
use_ok('C4::Acquisition');
7
use_ok('C4::Acquisition');
6
use_ok('C4::Biblio');
8
use_ok('C4::Biblio');
7
use_ok('C4::Budgets');
9
use_ok('C4::Budgets');
Lines 13-21 use Koha::Database; Link Here
13
# Start transaction
15
# Start transaction
14
my $schema = Koha::Database->new()->schema();
16
my $schema = Koha::Database->new()->schema();
15
$schema->storage->txn_begin();
17
$schema->storage->txn_begin();
18
my $builder = t::lib::TestBuilder->new;
16
my $dbh = C4::Context->dbh;
19
my $dbh = C4::Context->dbh;
17
$dbh->{RaiseError} = 1;
20
$dbh->{RaiseError} = 1;
18
21
22
my $curcode = $builder->build({ source => 'Currency' })->{currencycode};
23
19
my $bookseller = Koha::Acquisition::Bookseller->new(
24
my $bookseller = Koha::Acquisition::Bookseller->new(
20
    {
25
    {
21
        name => "my vendor",
26
        name => "my vendor",
Lines 61-67 my $order = Koha::Acquisition::Order->new({ Link Here
61
    biblionumber => $subscription->{biblionumber},
66
    biblionumber => $subscription->{biblionumber},
62
    entrydate => '01-01-2013',
67
    entrydate => '01-01-2013',
63
    quantity => 1,
68
    quantity => 1,
64
    currency => 'USD',
69
    currency => $curcode,
65
    listprice => $cost,
70
    listprice => $cost,
66
    notes => "This is a note",
71
    notes => "This is a note",
67
    basketno => $basketno,
72
    basketno => $basketno,
(-)a/t/db_dependent/Acquisition/StandingOrders.t (-1 / +2 lines)
Lines 22-27 my $branch = $builder->build( { source => 'Branch' } ); Link Here
22
my $bookseller = $builder->build( { source => 'Aqbookseller' } );
22
my $bookseller = $builder->build( { source => 'Aqbookseller' } );
23
my $budget = $builder->build( { source => 'Aqbudget' } );
23
my $budget = $builder->build( { source => 'Aqbudget' } );
24
my $staffmember = $builder->build( { source => 'Borrower' } );
24
my $staffmember = $builder->build( { source => 'Borrower' } );
25
my $curcode = $builder->build( { source => 'Currency' })->{currencycode};
25
26
26
# Create baskets and orders
27
# Create baskets and orders
27
28
Lines 61-67 my $ordernumber = Koha::Acquisition::Order->new( Link Here
61
        basketno                 => $basketno,
62
        basketno                 => $basketno,
62
        biblionumber             => $biblionumber,
63
        biblionumber             => $biblionumber,
63
        budget_id                => $budget->{budget_id},
64
        budget_id                => $budget->{budget_id},
64
        currency                 => 'USD',
65
        currency                 => $curcode,
65
        quantity                 => 0,
66
        quantity                 => 0,
66
        rrp                      => 42,
67
        rrp                      => 42,
67
        rrp_tax_included         => 42,
68
        rrp_tax_included         => 42,
(-)a/t/db_dependent/ArticleRequests.t (-6 / +10 lines)
Lines 20-27 use Modern::Perl; Link Here
20
use POSIX qw(strftime);
20
use POSIX qw(strftime);
21
21
22
use Test::More tests => 49;
22
use Test::More tests => 49;
23
use Koha::Database;
24
23
24
use t::lib::TestBuilder;
25
26
use Koha::Database;
25
use Koha::Biblio;
27
use Koha::Biblio;
26
use Koha::Patron;
28
use Koha::Patron;
27
use Koha::Library;
29
use Koha::Library;
Lines 34-39 BEGIN { Link Here
34
36
35
my $schema = Koha::Database->new()->schema();
37
my $schema = Koha::Database->new()->schema();
36
$schema->storage->txn_begin();
38
$schema->storage->txn_begin();
39
my $builder = t::lib::TestBuilder->new;
37
40
38
my $dbh = C4::Context->dbh;
41
my $dbh = C4::Context->dbh;
39
$dbh->{RaiseError} = 1;
42
$dbh->{RaiseError} = 1;
Lines 50-70 my $biblioitem = $schema->resultset('Biblioitem')->new( Link Here
50
)->insert();
53
)->insert();
51
ok( $biblioitem->id, 'biblioitem created' );
54
ok( $biblioitem->id, 'biblioitem created' );
52
55
56
my $itype = $builder->build({ source => 'Itemtype' });
53
my $item = Koha::Item->new(
57
my $item = Koha::Item->new(
54
    {
58
    {
55
        biblionumber     => $biblio->id,
59
        biblionumber     => $biblio->id,
56
        biblioitemnumber => $biblioitem->id,
60
        biblioitemnumber => $biblioitem->id,
57
        itype => $schema->resultset('Itemtype')->search()->next()->itemtype(),
61
        itype => $itype->{itype},
58
    }
62
    }
59
)->store();
63
)->store();
60
ok( $item->id, 'Koha::Item created' );
64
ok( $item->id, 'Koha::Item created' );
61
65
62
my $branch   = Koha::Libraries->search()->next();
66
my $branch   = $builder->build({ source => 'Branch' });
63
my $category = $schema->resultset('Category')->next();
67
my $category = $builder->build({ source => 'Category' });
64
my $patron   = Koha::Patron->new(
68
my $patron   = Koha::Patron->new(
65
    {
69
    {
66
        categorycode => $category->id,
70
        categorycode => $category->{categorycode},
67
        branchcode   => $branch->id,
71
        branchcode   => $branch->{branchcode},
68
    }
72
    }
69
)->store();
73
)->store();
70
ok( $patron->id, 'Koha::Patron created' );
74
ok( $patron->id, 'Koha::Patron created' );
(-)a/t/db_dependent/AuthorisedValues.t (-10 / +12 lines)
Lines 3-20 Link Here
3
use Modern::Perl;
3
use Modern::Perl;
4
use Test::More tests => 15;
4
use Test::More tests => 15;
5
5
6
use t::lib::TestBuilder;
7
8
use Koha::Database;
6
use C4::Context;
9
use C4::Context;
7
use Koha::AuthorisedValue;
10
use Koha::AuthorisedValue;
8
use Koha::AuthorisedValues;
11
use Koha::AuthorisedValues;
9
use Koha::AuthorisedValueCategories;
12
use Koha::AuthorisedValueCategories;
10
use Koha::MarcSubfieldStructures;
13
use Koha::MarcSubfieldStructures;
11
14
12
my $dbh = C4::Context->dbh;
15
my $schema  = Koha::Database->new->schema;
13
$dbh->{AutoCommit} = 0;
16
$schema->storage->txn_begin;
14
$dbh->{RaiseError} = 1;
17
my $builder = t::lib::TestBuilder->new;
15
18
16
$dbh->do("DELETE FROM authorised_values");
19
Koha::AuthorisedValues->delete;
17
$dbh->do("DELETE FROM authorised_value_categories");
20
Koha::AuthorisedValueCategories->delete;
18
21
19
# insert
22
# insert
20
Koha::AuthorisedValueCategory->new({ category_name => 'av_for_testing' })->store;
23
Koha::AuthorisedValueCategory->new({ category_name => 'av_for_testing' })->store;
Lines 89-99 my @authorised_values = Link Here
89
  Koha::AuthorisedValues->new()->search( { category => 'av_for_testing' } );
92
  Koha::AuthorisedValues->new()->search( { category => 'av_for_testing' } );
90
is( @authorised_values, 3, "Get correct number of values" );
93
is( @authorised_values, 3, "Get correct number of values" );
91
94
92
my $branches_rs = Koha::Database->new()->schema()->resultset('Branch')->search();
95
my $branchcode1 = $builder->build({ source => 'Branch' })->{branchcode};
93
my $branch1 = $branches_rs->next();
96
my $branchcode2 = $builder->build({ source => 'Branch' })->{branchcode};
94
my $branchcode1 = $branch1->branchcode();
95
my $branch2 = $branches_rs->next();
96
my $branchcode2 = $branch2->branchcode();
97
97
98
$av1->add_branch_limitation( $branchcode1 );
98
$av1->add_branch_limitation( $branchcode1 );
99
99
Lines 225-227 subtest 'search_by_*_field + find_by_koha_field + get_description' => sub { Link Here
225
        );
225
        );
226
    };
226
    };
227
};
227
};
228
229
$schema->storage->txn_rollback;
(-)a/t/db_dependent/AuthoritiesMarc.t (+8 lines)
Lines 11-17 use Test::Warn; Link Here
11
use MARC::Record;
11
use MARC::Record;
12
12
13
use t::lib::Mocks;
13
use t::lib::Mocks;
14
use t::lib::TestBuilder;
14
use Koha::Database;
15
use Koha::Database;
16
use Koha::Authority::Types;
15
17
16
BEGIN {
18
BEGIN {
17
        use_ok('C4::AuthoritiesMarc');
19
        use_ok('C4::AuthoritiesMarc');
Lines 61-69 $module->mock('GetAuthority', sub { Link Here
61
my $schema  = Koha::Database->new->schema;
63
my $schema  = Koha::Database->new->schema;
62
$schema->storage->txn_begin;
64
$schema->storage->txn_begin;
63
my $dbh = C4::Context->dbh;
65
my $dbh = C4::Context->dbh;
66
my $builder = t::lib::TestBuilder->new;
64
67
65
t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
68
t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
66
69
70
# Authority type GEOGR_NAME is hardcoded here
71
if( ! Koha::Authority::Types->find('GEOGR_NAME') ) {
72
    $builder->build({ source => 'AuthType', value => { authtypecode => 'GEOGR_NAME' }});
73
};
74
67
is(BuildAuthHierarchies(3, 1), '1,2,3', "Built linked authtrees hierarchy string");
75
is(BuildAuthHierarchies(3, 1), '1,2,3', "Built linked authtrees hierarchy string");
68
76
69
my $expectedhierarchy = [ [ {
77
my $expectedhierarchy = [ [ {
(-)a/t/db_dependent/Bookseller.t (-5 / +10 lines)
Lines 6-11 use Test::More tests => 86; Link Here
6
use Test::MockModule;
6
use Test::MockModule;
7
use Test::Warn;
7
use Test::Warn;
8
8
9
use t::lib::TestBuilder;
10
9
use C4::Context;
11
use C4::Context;
10
use Koha::DateUtils;
12
use Koha::DateUtils;
11
use DateTime::Duration;
13
use DateTime::Duration;
Lines 35-42 my $dbh = C4::Context->dbh; Link Here
35
my $database = Koha::Database->new();
37
my $database = Koha::Database->new();
36
my $schema = $database->schema();
38
my $schema = $database->schema();
37
$schema->storage->txn_begin();
39
$schema->storage->txn_begin();
38
39
$dbh->{RaiseError} = 1;
40
$dbh->{RaiseError} = 1;
41
my $builder = t::lib::TestBuilder->new;
40
42
41
#Start tests
43
#Start tests
42
$dbh->do(q|DELETE FROM aqorders|);
44
$dbh->do(q|DELETE FROM aqorders|);
Lines 44-49 $dbh->do(q|DELETE FROM aqbasket|); Link Here
44
$dbh->do(q|DELETE FROM aqbooksellers|);
46
$dbh->do(q|DELETE FROM aqbooksellers|);
45
$dbh->do(q|DELETE FROM subscription|);
47
$dbh->do(q|DELETE FROM subscription|);
46
48
49
# Add currency
50
my $curcode = $builder->build({ source => 'Currency' })->{currencycode};
51
47
#Test AddBookseller
52
#Test AddBookseller
48
my $count            = Koha::Acquisition::Booksellers->search()->count();
53
my $count            = Koha::Acquisition::Booksellers->search()->count();
49
my $sample_supplier1 = {
54
my $sample_supplier1 = {
Lines 350-356 my $order1 = Koha::Acquisition::Order->new( Link Here
350
        biblionumber     => $biblionumber,
355
        biblionumber     => $biblionumber,
351
        budget_id        => $id_budget,
356
        budget_id        => $id_budget,
352
        entrydate        => '01-01-2013',
357
        entrydate        => '01-01-2013',
353
        currency         => 'EUR',
358
        currency         => $curcode,
354
        notes            => "This is a note1",
359
        notes            => "This is a note1",
355
        tax_rate          => 0.0500,
360
        tax_rate          => 0.0500,
356
        orderstatus      => 1,
361
        orderstatus      => 1,
Lines 370-376 my $order2 = Koha::Acquisition::Order->new( Link Here
370
        biblionumber   => $biblionumber,
375
        biblionumber   => $biblionumber,
371
        budget_id      => $id_budget,
376
        budget_id      => $id_budget,
372
        entrydate      => '01-01-2013',
377
        entrydate      => '01-01-2013',
373
        currency       => 'EUR',
378
        currency       => $curcode,
374
        notes          => "This is a note2",
379
        notes          => "This is a note2",
375
        tax_rate        => 0.0500,
380
        tax_rate        => 0.0500,
376
        orderstatus    => 1,
381
        orderstatus    => 1,
Lines 388-394 my $order3 = Koha::Acquisition::Order->new( Link Here
388
        biblionumber   => $biblionumber,
393
        biblionumber   => $biblionumber,
389
        budget_id      => $id_budget,
394
        budget_id      => $id_budget,
390
        entrydate      => '02-02-2013',
395
        entrydate      => '02-02-2013',
391
        currency       => 'EUR',
396
        currency       => $curcode,
392
        notes          => "This is a note3",
397
        notes          => "This is a note3",
393
        tax_rate        => 0.0500,
398
        tax_rate        => 0.0500,
394
        orderstatus    => 2,
399
        orderstatus    => 2,
Lines 406-412 my $order4 = Koha::Acquisition::Order->new( Link Here
406
        biblionumber     => $biblionumber,
411
        biblionumber     => $biblionumber,
407
        budget_id        => $id_budget,
412
        budget_id        => $id_budget,
408
        entrydate        => '02-02-2013',
413
        entrydate        => '02-02-2013',
409
        currency         => 'EUR',
414
        currency         => $curcode,
410
        notes            => "This is a note3",
415
        notes            => "This is a note3",
411
        tax_rate          => 0.0500,
416
        tax_rate          => 0.0500,
412
        orderstatus      => 2,
417
        orderstatus      => 2,
(-)a/t/db_dependent/Koha.t (-9 / +15 lines)
Lines 4-25 Link Here
4
# It requires a working Koha database with the sample data
4
# It requires a working Koha database with the sample data
5
5
6
use Modern::Perl;
6
use Modern::Perl;
7
use DateTime::Format::MySQL;
8
use Test::More tests => 7;
9
10
use t::lib::TestBuilder;
11
7
use C4::Context;
12
use C4::Context;
13
use Koha::Database;
8
use Koha::DateUtils qw(dt_from_string);
14
use Koha::DateUtils qw(dt_from_string);
9
use Koha::AuthorisedValue;
15
use Koha::AuthorisedValue;
10
use Koha::AuthorisedValueCategories;
16
use Koha::AuthorisedValueCategories;
11
17
12
use Test::More tests => 7;
13
use DateTime::Format::MySQL;
14
15
BEGIN {
18
BEGIN {
16
    use_ok('C4::Koha', qw( :DEFAULT GetDailyQuote GetItemTypesCategorized));
19
    use_ok('C4::Koha', qw( :DEFAULT GetDailyQuote GetItemTypesCategorized));
17
    use_ok('C4::Members');
20
    use_ok('C4::Members');
18
}
21
}
19
22
23
my $schema  = Koha::Database->new->schema;
24
$schema->storage->txn_begin;
25
my $builder = t::lib::TestBuilder->new;
20
my $dbh = C4::Context->dbh;
26
my $dbh = C4::Context->dbh;
21
$dbh->{AutoCommit} = 0;
27
22
$dbh->{RaiseError} = 1;
28
our $itype_1 = $builder->build({ source => 'Itemtype' });
23
29
24
subtest 'Authorized Values Tests' => sub {
30
subtest 'Authorized Values Tests' => sub {
25
    plan tests => 3;
31
    plan tests => 3;
Lines 152-160 subtest 'Authorized Values Tests' => sub { Link Here
152
};
158
};
153
159
154
subtest 'Itemtype info Tests' => sub {
160
subtest 'Itemtype info Tests' => sub {
155
    like ( getitemtypeinfo('BK')->{'imageurl'}, qr/intranet-tmpl/, 'getitemtypeinfo on unspecified interface returns intranet imageurl (legacy behavior)' );
161
    like ( getitemtypeinfo( $itype_1->{itemtype} )->{'imageurl'}, qr/intranet-tmpl/, 'getitemtypeinfo on unspecified interface returns intranet imageurl (legacy behavior)' );
156
    like ( getitemtypeinfo('BK', 'intranet')->{'imageurl'}, qr/intranet-tmpl/, 'getitemtypeinfo on "intranet" interface returns intranet imageurl' );
162
    like ( getitemtypeinfo( $itype_1->{itemtype}, 'intranet')->{'imageurl'}, qr/intranet-tmpl/, 'getitemtypeinfo on "intranet" interface returns intranet imageurl' );
157
    like ( getitemtypeinfo('BK', 'opac')->{'imageurl'}, qr/opac-tmpl/, 'getitemtypeinfo on "opac" interface returns opac imageurl' );
163
    like ( getitemtypeinfo( $itype_1->{itemtype}, 'opac')->{'imageurl'}, qr/opac-tmpl/, 'getitemtypeinfo on "opac" interface returns opac imageurl' );
158
};
164
};
159
165
160
### test for C4::Koha->GetDailyQuote()
166
### test for C4::Koha->GetDailyQuote()
Lines 294-297 subtest 'GetItemTypesCategorized test' => sub{ Link Here
294
    is_deeply(\@results,\@expected, 'GetItemTypesCategorized: grouped and ungrouped items returned as expected.');
300
    is_deeply(\@results,\@expected, 'GetItemTypesCategorized: grouped and ungrouped items returned as expected.');
295
};
301
};
296
302
297
$dbh->rollback();
303
$schema->storage->txn_rollback;
(-)a/t/db_dependent/UsageStats.t (-6 / +7 lines)
Lines 17-22 Link Here
17
use Modern::Perl;
17
use Modern::Perl;
18
use Test::More tests => 57;
18
use Test::More tests => 57;
19
use t::lib::Mocks qw(mock_preference);
19
use t::lib::Mocks qw(mock_preference);
20
use t::lib::TestBuilder;
20
use POSIX qw(strftime);
21
use POSIX qw(strftime);
21
use Data::Dumper;
22
use Data::Dumper;
22
use Koha::Biblios;
23
use Koha::Biblios;
Lines 41-49 can_ok( Link Here
41
      _count )
42
      _count )
42
);
43
);
43
44
45
my $schema  = Koha::Database->new->schema;
46
$schema->storage->txn_begin;
47
my $builder = t::lib::TestBuilder->new;
44
my $dbh = C4::Context->dbh;
48
my $dbh = C4::Context->dbh;
45
$dbh->{AutoCommit} = 0;
46
$dbh->{RaiseError} = 1;
47
49
48
$dbh->do('DELETE FROM issues');
50
$dbh->do('DELETE FROM issues');
49
$dbh->do('DELETE FROM biblio');
51
$dbh->do('DELETE FROM biblio');
Lines 213-220 sub construct_objects_needed { Link Here
213
    my $cardnumber1  = 'test_card1';
215
    my $cardnumber1  = 'test_card1';
214
    my $cardnumber2  = 'test_card2';
216
    my $cardnumber2  = 'test_card2';
215
    my $cardnumber3  = 'test_card3';
217
    my $cardnumber3  = 'test_card3';
216
    my $categorycode = Koha::Database->new()->schema()->resultset('Category')->first()->categorycode();
218
    my $categorycode = $builder->build({ source => 'Category' })->{categorycode};
217
    my $branchcode   = Koha::Database->new()->schema()->resultset('Branch')->first()->branchcode();
219
    my $branchcode = $builder->build({ source => 'Branch' })->{branchcode};
218
220
219
    my $query = '
221
    my $query = '
220
    INSERT INTO borrowers
222
    INSERT INTO borrowers
Lines 613-616 sub verif_systempreferences_values { Link Here
613
    }
615
    }
614
}
616
}
615
617
616
$dbh->rollback;
618
$schema->storage->txn_rollback;
617
- 

Return to bug 18448