|
Lines 39-58
my %configs;
Link Here
|
| 39 |
|
39 |
|
| 40 |
Mock the configuration I<$config_entry> with the specified I<$value>. |
40 |
Mock the configuration I<$config_entry> with the specified I<$value>. |
| 41 |
|
41 |
|
|
|
42 |
NOTE: We are only mocking config entries here, so no entries from other |
| 43 |
sections of koha-conf.xml. Bug 33718 fixed the section parameter of |
| 44 |
mocked Koha::Config->get calls for other sections (not cached). |
| 45 |
|
| 42 |
=cut |
46 |
=cut |
| 43 |
|
47 |
|
| 44 |
sub mock_config { |
48 |
sub mock_config { |
|
|
49 |
my ( $config_entry, $value ) = @_; |
| 45 |
my $koha_config = Test::MockModule->new('Koha::Config'); |
50 |
my $koha_config = Test::MockModule->new('Koha::Config'); |
| 46 |
my ( $conf, $value ) = @_; |
51 |
$configs{$config_entry} = $value; |
| 47 |
$configs{$conf} = $value; |
|
|
| 48 |
$koha_config->mock('get', sub { |
52 |
$koha_config->mock('get', sub { |
| 49 |
my ( $self, $conf ) = @_; |
53 |
my ( $self, $key, $section ) = @_; |
| 50 |
if ( exists $configs{$conf} ) { |
54 |
$section ||= 'config'; |
| 51 |
return $configs{$conf} |
55 |
if( $section eq 'config' && exists $configs{$key} ) { |
| 52 |
} else { |
56 |
return $configs{$key}; |
| 53 |
my $method = $koha_config->original('get'); |
|
|
| 54 |
return $method->($self, $conf); |
| 55 |
} |
57 |
} |
|
|
58 |
my $method = $koha_config->original('get'); |
| 59 |
return $method->( $self, $key, $section ); |
| 56 |
}); |
60 |
}); |
| 57 |
} |
61 |
} |
| 58 |
|
62 |
|
| 59 |
- |
|
|