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

(-)a/t/db_dependent/Accounts.t (-22 / +4 lines)
Lines 55-64 my $dbh = C4::Context->dbh; Link Here
55
my $builder = t::lib::TestBuilder->new;
55
my $builder = t::lib::TestBuilder->new;
56
my $library = $builder->build( { source => 'Branch' } );
56
my $library = $builder->build( { source => 'Branch' } );
57
57
58
$dbh->do(q|DELETE FROM accountlines|);
59
$dbh->do(q|DELETE FROM issues|);
60
$dbh->do(q|DELETE FROM borrowers|);
61
62
my $branchcode = $library->{branchcode};
58
my $branchcode = $library->{branchcode};
63
59
64
my $context = Test::MockModule->new('C4::Context');
60
my $context = Test::MockModule->new('C4::Context');
Lines 1104-1126 subtest "Payment notice tests" => sub { Link Here
1104
1100
1105
    plan tests => 8;
1101
    plan tests => 8;
1106
1102
1107
    Koha::Account::Lines->delete();
1108
    Koha::Patrons->delete();
1109
    Koha::Notice::Messages->delete();
1103
    Koha::Notice::Messages->delete();
1110
    # Create a borrower
1104
    # Create a patron
1111
    my $categorycode = $builder->build({ source => 'Category' })->{ categorycode };
1105
    my $patron = $builder->build_object({ class => 'Koha::Patrons' });
1112
    my $branchcode   = $builder->build({ source => 'Branch' })->{ branchcode };
1113
1114
    my $borrower = Koha::Patron->new(
1115
        {
1116
            cardnumber   => 'chelseahall',
1117
            surname      => 'Hall',
1118
            firstname    => 'Chelsea',
1119
            email        => 'chelsea@example.com',
1120
            categorycode => $categorycode,
1121
            branchcode   => $branchcode,
1122
        }
1123
    )->store();
1124
1106
1125
    my $manager = $builder->build_object({ class => "Koha::Patrons" });
1107
    my $manager = $builder->build_object({ class => "Koha::Patrons" });
1126
    my $context = Test::MockModule->new('C4::Context');
1108
    my $context = Test::MockModule->new('C4::Context');
Lines 1130-1140 subtest "Payment notice tests" => sub { Link Here
1130
            branch     => $manager->branchcode,
1112
            branch     => $manager->branchcode,
1131
        };
1113
        };
1132
    });
1114
    });
1133
    my $account = Koha::Account->new({ patron_id => $borrower->id });
1115
    my $account = Koha::Account->new({ patron_id => $patron->borrowernumber });
1134
1116
1135
    my $line = Koha::Account::Line->new(
1117
    my $line = Koha::Account::Line->new(
1136
        {
1118
        {
1137
            borrowernumber    => $borrower->borrowernumber,
1119
            borrowernumber    => $patron->borrowernumber,
1138
            amountoutstanding => 27,
1120
            amountoutstanding => 27,
1139
            interface         => 'commandline',
1121
            interface         => 'commandline',
1140
            debit_type_code   => 'LOST'
1122
            debit_type_code   => 'LOST'
(-)a/t/db_dependent/Koha/Biblio.t (-11 / +9 lines)
Lines 185-203 subtest 'is_serial() tests' => sub { Link Here
185
};
185
};
186
186
187
subtest 'pickup_locations' => sub {
187
subtest 'pickup_locations' => sub {
188
    plan tests => 29;
188
    plan tests => 8;
189
189
190
    $schema->storage->txn_begin;
190
    $schema->storage->txn_begin;
191
191
192
    my $dbh = C4::Context->dbh;
192
    my $nb_libraries = Koha::Libraries->count;
193
194
    # Cleanup database
195
    Koha::Holds->search->delete;
196
    Koha::Patrons->search->delete;
197
    Koha::Items->search->delete;
198
    Koha::Libraries->search->delete;
199
    Koha::CirculationRules->search->delete;
193
    Koha::CirculationRules->search->delete;
200
    $dbh->do('DELETE FROM issues');
201
    Koha::CirculationRules->set_rules(
194
    Koha::CirculationRules->set_rules(
202
        {
195
        {
203
            categorycode => undef,
196
            categorycode => undef,
Lines 222-227 subtest 'pickup_locations' => sub { Link Here
222
    my $library7 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } );
215
    my $library7 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } );
223
    my $library8 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 0 } } );
216
    my $library8 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 0 } } );
224
217
218
    our @branchcodes = map { $_->branchcode } ($library1, $library2, $library3, $library4, $library5, $library6, $library7, $library8);
219
225
    Koha::CirculationRules->set_rules(
220
    Koha::CirculationRules->set_rules(
226
        {
221
        {
227
            branchcode => $library1->branchcode,
222
            branchcode => $library1->branchcode,
Lines 373-383 subtest 'pickup_locations' => sub { Link Here
373
    my $patron8 = $builder->build_object( { class => 'Koha::Patrons', value => { firstname=>'8', branchcode => $library8->branchcode } } );
368
    my $patron8 = $builder->build_object( { class => 'Koha::Patrons', value => { firstname=>'8', branchcode => $library8->branchcode } } );
374
369
375
    my $results = {
370
    my $results = {
376
        "ItemHomeLibrary-1-1" => 6,
371
        "ItemHomeLibrary-1-1" => 6  + $nb_libraries,
377
        "ItemHomeLibrary-1-8" => 1,
372
        "ItemHomeLibrary-1-8" => 1,
378
        "ItemHomeLibrary-2-1" => 2,
373
        "ItemHomeLibrary-2-1" => 2,
379
        "ItemHomeLibrary-2-8" => 0,
374
        "ItemHomeLibrary-2-8" => 0,
380
        "PatronLibrary-1-1" => 6,
375
        "PatronLibrary-1-1" => 6 + $nb_libraries,
381
        "PatronLibrary-1-8" => 3,
376
        "PatronLibrary-1-8" => 3,
382
        "PatronLibrary-2-1" => 0,
377
        "PatronLibrary-2-1" => 0,
383
        "PatronLibrary-2-8" => 3,
378
        "PatronLibrary-2-8" => 3,
Lines 390-395 subtest 'pickup_locations' => sub { Link Here
390
        my @pl = @{ $biblio->pickup_locations( { patron => $patron} ) };
385
        my @pl = @{ $biblio->pickup_locations( { patron => $patron} ) };
391
386
392
        foreach my $pickup_location (@pl) {
387
        foreach my $pickup_location (@pl) {
388
            next
389
              unless grep { $pickup_location eq $_ } @branchcodes;
390
393
            is( ref($pickup_location), 'Koha::Library', 'Object type is correct' );
391
            is( ref($pickup_location), 'Koha::Library', 'Object type is correct' );
394
        }
392
        }
395
393
(-)a/t/db_dependent/Koha/Objects.t (+1 lines)
Lines 263-268 subtest '->is_paged and ->pager tests' => sub { Link Here
263
    $schema->storage->txn_begin;
263
    $schema->storage->txn_begin;
264
264
265
    # Delete existing patrons
265
    # Delete existing patrons
266
    t::lib::Mocks::mock_preference('AnonymousPatron', '');
266
    Koha::Checkouts->delete;
267
    Koha::Checkouts->delete;
267
    Koha::Patrons->delete;
268
    Koha::Patrons->delete;
268
    # Create 10 patrons
269
    # Create 10 patrons
(-)a/t/db_dependent/Template/Plugin/Categories.t (-11 / +4 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 5;
20
use Test::More tests => 4;
21
use t::lib::Mocks;
21
use t::lib::Mocks;
22
use t::lib::TestBuilder;
22
use t::lib::TestBuilder;
23
23
Lines 30-53 use Koha::Template::Plugin::Categories; Link Here
30
my $schema = Koha::Database->new->schema;
30
my $schema = Koha::Database->new->schema;
31
$schema->storage->txn_begin;
31
$schema->storage->txn_begin;
32
32
33
# Delete all categories
34
Koha::Checkouts->search->delete;
35
Koha::Patrons->search->delete;
36
Koha::Patron::Categories->search->delete;
37
38
my $builder = t::lib::TestBuilder->new;
33
my $builder = t::lib::TestBuilder->new;
39
34
40
is( Koha::Template::Plugin::Categories->new->all->count,
35
my $nb_categories = Koha::Patron::Categories->count;
41
    0, '->all returns 0 results if no categories defined' );
42
36
43
# Create sample categories
37
# Create sample categories
44
my $category_1 = $builder->build( { source => 'Category' } );
38
my $category_1 = $builder->build( { source => 'Category' } );
45
my @categories = Koha::Template::Plugin::Categories->new->all;
39
my @categories = Koha::Template::Plugin::Categories->new->all;
46
is( scalar(@categories), 1, '->all returns all defined categories' );
40
is( scalar(@categories), 1 + $nb_categories, '->all returns all defined categories' );
47
41
48
my $category_2 = $builder->build( { source => 'Category' } );
42
my $category_2 = $builder->build( { source => 'Category' } );
49
@categories = Koha::Template::Plugin::Categories->new->all;
43
@categories = Koha::Template::Plugin::Categories->new->all;
50
is( scalar(@categories), 2, '->all returns all defined categories' );
44
is( scalar(@categories), 2 + $nb_categories, '->all returns all defined categories' );
51
45
52
is( Koha::Template::Plugin::Categories->GetName(
46
is( Koha::Template::Plugin::Categories->GetName(
53
        $category_1->{categorycode}
47
        $category_1->{categorycode}
54
- 

Return to bug 26984