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

(-)a/t/lib/Mocks.pm (-1 / +56 lines)
Lines 21-27 use C4::Context; Link Here
21
use Test::MockModule;
21
use Test::MockModule;
22
use Test::MockObject;
22
use Test::MockObject;
23
23
24
=head1 NAME
25
26
t::lib::Mocks - A library to mock things for testing
27
28
=head1 API
29
30
=head2 Methods
31
32
=cut
33
24
my %configs;
34
my %configs;
35
36
=head3 mock_config
37
38
    t::lib::Mocks::mock_config( $config_entry, $value );
39
40
Mock the configuration I<$config_entry> with the specified I<$value>.
41
42
=cut
43
25
sub mock_config {
44
sub mock_config {
26
    my $context = Test::MockModule->new('C4::Context');
45
    my $context = Test::MockModule->new('C4::Context');
27
    my ( $conf, $value ) = @_;
46
    my ( $conf, $value ) = @_;
Lines 38-43 sub mock_config { Link Here
38
}
57
}
39
58
40
my %preferences;
59
my %preferences;
60
61
=head3 mock_preference
62
63
    t::lib::Mocks::mock_preference( $preference, $value );
64
65
Mock the I<$preference> with the specified I<value>.
66
67
=cut
68
41
sub mock_preference {
69
sub mock_preference {
42
    my ( $pref, $value ) = @_;
70
    my ( $pref, $value ) = @_;
43
71
Lines 56-61 sub mock_preference { Link Here
56
    });
84
    });
57
}
85
}
58
86
87
=head3 mock_userenv
88
89
    t::lib::Mocks::mock_userenv(
90
        {
91
          [ patron         => $patron,
92
            borrowernumber => $borrowernumber,
93
            userid         => $userid,
94
            cardnumber     => $cardnumber,
95
            firstname      => $firstname,
96
            surname        => $surname,
97
            branchcode     => $branchcode,
98
            branchname     => $branchname,
99
            flags          => $flags,
100
            emailaddress   => $emailaddress,
101
            desk_id        => $desk_id,
102
            desk_name      => $desk_name,
103
            register_id    => $register_id,
104
            register_name  => $register_name, ]
105
        }
106
    );
107
108
Mock userenv in the context of tests. A I<patron> param is usually expected, but
109
some other session attributes might be passed as well, that will override the patron's.
110
111
Also, some sane defaults are set if no parameters are passed.
112
113
=cut
114
59
sub mock_userenv {
115
sub mock_userenv {
60
    my ( $params ) = @_;
116
    my ( $params ) = @_;
61
117
62
- 

Return to bug 28615