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

(-)a/t/db_dependent/DecreaseLoanHighHolds.t (-20 / +22 lines)
Lines 38-48 my $builder = t::lib::TestBuilder->new; Link Here
38
$dbh->{RaiseError} = 1;
38
$dbh->{RaiseError} = 1;
39
$schema->storage->txn_begin();
39
$schema->storage->txn_begin();
40
40
41
$dbh->do('DELETE FROM issues');
42
$dbh->do('DELETE FROM issuingrules');
43
$dbh->do('DELETE FROM borrowers');
44
$dbh->do('DELETE FROM items');
45
46
my $now_value       = DateTime->now();
41
my $now_value       = DateTime->now();
47
my $mocked_datetime = Test::MockModule->new('DateTime');
42
my $mocked_datetime = Test::MockModule->new('DateTime');
48
$mocked_datetime->mock( 'now', sub { return $now_value->clone; } );
43
$mocked_datetime->mock( 'now', sub { return $now_value->clone; } );
Lines 54-82 my $itemtype = $builder->build( { source => 'Itemtype' } )->{itemtype}; Link Here
54
t::lib::Mocks::mock_userenv({ branchcode => $library->{branchcode} });
49
t::lib::Mocks::mock_userenv({ branchcode => $library->{branchcode} });
55
is( C4::Context->userenv->{branch}, $library->{branchcode}, 'userenv set' );
50
is( C4::Context->userenv->{branch}, $library->{branchcode}, 'userenv set' );
56
51
57
my $patron_category = $builder->build({ source => 'Category', value => { category_type => 'P', enrolmentfee => 0 } });
52
my $patron_category = $builder->build({
53
    source => 'Category',
54
    value => {
55
        category_type => 'P',
56
        enrolmentfee => 0
57
    }
58
});
59
58
my @patrons;
60
my @patrons;
59
for my $i ( 1 .. 20 ) {
61
for my $i ( 1 .. 20 ) {
60
    my $patron = Koha::Patron->new(
62
    my $patron = Koha::Patron->new({
61
        { cardnumber => $i, firstname => 'Kyle', surname => 'Hall', categorycode => $category->{categorycode}, branchcode => $library->{branchcode}, categorycode => $patron_category->{categorycode}, } )
63
        firstname => 'Kyle',
62
      ->store();
64
        surname => 'Hall',
65
        categorycode => $category->{categorycode},
66
        branchcode => $library->{branchcode},
67
        categorycode => $patron_category->{categorycode},
68
    })->store();
63
    push( @patrons, $patron );
69
    push( @patrons, $patron );
64
}
70
}
65
71
66
my $biblio = Koha::Biblio->new()->store();
72
my $biblio = $builder->build_sample_biblio();
67
my $biblioitem =
68
  $schema->resultset('Biblioitem')->new( { biblionumber => $biblio->biblionumber } )->insert();
69
73
70
my @items;
74
my @items;
71
for my $i ( 1 .. 10 ) {
75
for my $i ( 1 .. 10 ) {
72
    my $item = Koha::Item->new(
76
    my $item = $builder->build_sample_item(
73
        {
77
        {
74
            biblionumber     => $biblio->id(),
78
            biblionumber     => $biblio->id(),
75
            biblioitemnumber => $biblioitem->id(),
76
            barcode          => $i,
77
            itype            => $itemtype
79
            itype            => $itemtype
78
        }
80
        }
79
    )->store();
81
    );
80
    push( @items, $item );
82
    push( @items, $item );
81
}
83
}
82
84
Lines 91-103 for my $i ( 0 .. 5 ) { Link Here
91
    )->store();
93
    )->store();
92
}
94
}
93
95
96
my $item   = pop(@items);
97
my $patron = pop(@patrons);
98
94
$builder->build(
99
$builder->build(
95
    {
100
    {
96
        source => 'Issuingrule',
101
        source => 'Issuingrule',
97
        value => {
102
        value => {
98
            branchcode => '*',
103
            branchcode => '*',
99
            categorycode => '*',
104
            categorycode => '*',
100
            itemtype => '*',
105
            itemtype => $item->itype,
101
            issuelength => '14',
106
            issuelength => '14',
102
            lengthunit => 'days',
107
            lengthunit => 'days',
103
            reservesallowed => '99',
108
            reservesallowed => '99',
Lines 105-112 $builder->build( Link Here
105
    }
110
    }
106
);
111
);
107
112
108
my $item   = pop(@items);
109
my $patron = pop(@patrons);
110
113
111
my $orig_due = C4::Circulation::CalcDateDue(
114
my $orig_due = C4::Circulation::CalcDateDue(
112
    DateTime->now(time_zone => C4::Context->tz()),
115
    DateTime->now(time_zone => C4::Context->tz()),
113
- 

Return to bug 22493