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

(-)a/t/db_dependent/Circulation/IsItemIssued.t (-7 / +27 lines)
Lines 1-5 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
1
use Modern::Perl;
18
use Modern::Perl;
19
2
use Test::More tests => 5;
20
use Test::More tests => 5;
21
use Test::MockModule;
3
22
4
use C4::Biblio;
23
use C4::Biblio;
5
use C4::Circulation;
24
use C4::Circulation;
Lines 12-28 use t::lib::TestBuilder; Link Here
12
31
13
use MARC::Record;
32
use MARC::Record;
14
33
15
*C4::Context::userenv = \&Mock_userenv;
16
17
my $schema = Koha::Database->schema;
34
my $schema = Koha::Database->schema;
18
$schema->storage->txn_begin;
35
$schema->storage->txn_begin;
19
my $builder = t::lib::TestBuilder->new;
36
my $builder = t::lib::TestBuilder->new;
20
my $dbh = C4::Context->dbh;
21
37
22
my $library = $builder->build({
38
my $library = $builder->build({
23
    source => 'Branch',
39
    source => 'Branch',
24
});
40
});
25
41
42
my $module = new Test::MockModule('C4::Context');
43
$module->mock('userenv', sub {
44
    {
45
       branch => $library->{branchcode}
46
    }
47
});
48
26
my $borrowernumber = AddMember(
49
my $borrowernumber = AddMember(
27
    firstname =>  'my firstname',
50
    firstname =>  'my firstname',
28
    surname => 'my surname',
51
    surname => 'my surname',
Lines 60-66 is( Link Here
60
83
61
$schema->storage->txn_rollback;
84
$schema->storage->txn_rollback;
62
85
63
# C4::Context->userenv
86
1;
64
sub Mock_userenv {
65
    return { branch => $library->{branchcode} };
66
}
(-)a/t/db_dependent/Items_DelItemCheck.t (-10 / +31 lines)
Lines 1-21 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
1
use Modern::Perl;
18
use Modern::Perl;
2
19
3
use C4::Circulation;
20
use C4::Circulation;
21
use Koha::Database;
4
22
5
use t::lib::TestBuilder;
23
use t::lib::TestBuilder;
6
use t::lib::Mocks;
24
use t::lib::Mocks;
7
25
8
use Test::More tests => 9;
26
use Test::More tests => 9;
9
27
use Test::MockModule;
10
*C4::Context::userenv = \&Mock_userenv;
11
28
12
BEGIN {
29
BEGIN {
13
    use_ok('C4::Items');
30
    use_ok('C4::Items');
14
}
31
}
15
32
16
my $dbh = C4::Context->dbh;
17
18
my $builder = t::lib::TestBuilder->new();
33
my $builder = t::lib::TestBuilder->new();
34
my $schema = Koha::Database->new->schema;
35
# Begin transaction
36
$schema->storage->txn_begin;
19
37
20
my $branch = $builder->build(
38
my $branch = $builder->build(
21
    {
39
    {
Lines 23-28 my $branch = $builder->build( Link Here
23
    }
41
    }
24
);
42
);
25
43
44
my $module = new Test::MockModule('C4::Context');
45
$module->mock('userenv', sub {
46
    {  flags  => 0,
47
       branch => $branch->{branchcode}
48
    }
49
});
50
26
my $branch2 = $builder->build(
51
my $branch2 = $builder->build(
27
    {
52
    {
28
        source => 'Branch',
53
        source => 'Branch',
Lines 140-148 is( $test_item->{itemnumber}, undef, Link Here
140
    "DelItemCheck should delete item if ItemSafeToDelete returns true"
165
    "DelItemCheck should delete item if ItemSafeToDelete returns true"
141
);
166
);
142
167
143
# End of testing
168
$schema->storage->txn_rollback;
144
169
145
# C4::Context->userenv
170
1;
146
sub Mock_userenv {
147
    return { flags => 0, branch => $branch->{branchcode} };
148
}
149
- 

Return to bug 14504