Bug 12927: Problems with item information tab on acq order from staged page
[koha.git] / t / lib / Mocks.pm
blob3f834d27c90c6a8d2ea8680a7cc8de5b1c8ec3fb
1 package t::lib::Mocks;
3 use Modern::Perl;
4 use C4::Context;
5 use Test::MockModule;
7 my %configs;
8 sub mock_config {
9 my $context = new Test::MockModule('C4::Context');
10 my ( $conf, $value ) = @_;
11 $configs{$conf} = $value;
12 $context->mock('config', sub {
13 my ( $self, $conf ) = @_;
14 if ( exists $configs{$conf} ) {
15 return $configs{$conf}
16 } else {
17 my $method = $context->original('config');
18 return $method->($self, $conf);
20 });
23 my %preferences;
24 sub mock_preference {
25 my $context = new Test::MockModule('C4::Context');
26 my ( $pref, $value ) = @_;
27 $preferences{$pref} = $value;
28 $context->mock('preference', sub {
29 my ( $self, $pref ) = @_;
30 if ( exists $preferences{$pref} ) {
31 return $preferences{$pref}
32 } else {
33 my $method = $context->original('preference');
34 return $method->($self, $pref);
36 });