10 my $context = new Test::MockModule('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 = new Test::MockModule('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 ( $branchprinter, $shibboleth );
65 C4::Context->set_userenv($usernum, $userid, $cardnumber, $firstname, $surname, $branchcode, $branchname, $flags, $emailaddress, $branchprinter, $shibboleth );