-my $context = new Test::MockModule('C4::Context');
-sub set_solr {
- $context->mock('preference', sub { &t::lib::Mocks::Context::MockPreference( @_, "Solr", $context ) });
-}
-sub set_zebra {
- $context->mock('preference', sub { &t::lib::Mocks::Context::MockPreference( @_, "Zebra", $context ) });
+my %preferences;
+sub mock_preference {
+ my $context = new Test::MockModule('C4::Context');
+ my ( $pref, $value ) = @_;
+ $preferences{$pref} = $value;
+ $context->mock('preference', sub {
+ my ( $self, $pref ) = @_;
+ if ( exists $preferences{$pref} ) {
+ return $preferences{$pref}
+ } else {
+ my $method = $context->original('preference');
+ return $method->($self, $pref);
+ }
+ });