10 my $context = Test
::MockModule
->new('C4::Context');
11 my ( $conf, $value ) = @_;
12 $configs{$conf} = $value;
13 $context->mock('config', sub {
14 my ( $self, $conf ) = @_;
15 if ( exists $configs{$conf} ) {
16 return $configs{$conf}
18 my $method = $context->original('config');
19 return $method->($self, $conf);
26 my ( $pref, $value ) = @_;
28 $preferences{lc($pref)} = $value;
30 my $context = Test
::MockModule
->new('C4::Context');
31 $context->mock('preference', sub {
32 my ( $self, $pref ) = @_;
34 if ( exists $preferences{$pref} ) {
35 return $preferences{$pref}
37 my $method = $context->original('preference');
38 return $method->($self, $pref);
46 C4
::Context
->_new_userenv(42);
49 if ( $params and my $patron = $params->{patron
} ) {
50 $userenv = $patron->unblessed;
51 $userenv->{branchcode
} = $params->{branchcode
} || $patron->library->branchcode;
52 $userenv->{branchname
} = $params->{branchname
} || $patron->library->branchname;
54 my $usernum = $params->{borrowernumber
} || $userenv->{borrowernumber
} || 51;
55 my $userid = $params->{userid
} || $userenv->{userid
} || 'userid4tests';
56 my $cardnumber = $params->{cardnumber
} || $userenv->{cardnumber
};
57 my $firstname = $params->{firstname
} || $userenv->{firstname
} || 'firstname';
58 my $surname = $params->{surname
} || $userenv->{surname
} || 'surname';
59 my $branchcode = $params->{branchcode
} || $userenv->{branchcode
} || 'Branch4T';
60 my $branchname = $params->{branchname
} || $userenv->{branchname
};
61 my $flags = $params->{flags
} || $userenv->{flags
} || 0;
62 my $emailaddress = $params->{emailaddress
} || $userenv->{emailaddress
};
63 my $desk_id = $params->{desk_id
} || $userenv->{desk_id
};
64 my $desk_name = $params->{desk_name
} || $userenv->{desk_name
};
65 my $register_id = $params->{register_id
} || $userenv->{register_id
};
66 my $register_name = $params->{register_name
} || $userenv->{register_name
};
69 C4
::Context
->set_userenv(
70 $usernum, $userid, $cardnumber, $firstname,
71 $surname, $branchcode, $branchname, $flags,
72 $emailaddress, $shibboleth, $desk_id, $desk_name,
73 $register_id, $register_name