Make fake_config() available to all plugin tests
This commit is contained in:
parent
4f4e19ba0a
commit
0d5ec185a8
@ -84,4 +84,27 @@ sub validate_password {
|
||||
return $deny, "$file - wrong password";
|
||||
}
|
||||
|
||||
sub fake_config {
|
||||
my $self = shift;
|
||||
my $fake_config = {@_};
|
||||
$self->qp->hooks->{config} = [
|
||||
{
|
||||
name => '___FakeHook___',
|
||||
code => sub {
|
||||
my ( $self, $txn, $conf ) = @_;
|
||||
return DECLINED if ! exists $fake_config->{$conf};
|
||||
return OK, $fake_config->{$conf};
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
sub unfake_config {
|
||||
my ( $self ) = @_;
|
||||
$self->qp->hooks->{config} = [
|
||||
grep { $_->{name} ne '___FakeHook___' }
|
||||
@{ $self->qp->hooks->{config} || [] }
|
||||
];
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -75,29 +75,6 @@ sub test_content_log_enabled {
|
||||
$self->unfake_config;
|
||||
}
|
||||
|
||||
sub fake_config {
|
||||
my $self = shift;
|
||||
my $fake_config = {@_};
|
||||
$self->qp->hooks->{config} = [
|
||||
{
|
||||
name => '___FakeHook___',
|
||||
code => sub {
|
||||
my ( $self, $txn, $conf ) = @_;
|
||||
return DECLINED if ! exists $fake_config->{$conf};
|
||||
return OK, $fake_config->{$conf};
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
sub unfake_config {
|
||||
my ( $self ) = @_;
|
||||
$self->qp->hooks->{config} = [
|
||||
grep { $_->{name} ne '___FakeHook___' }
|
||||
@{ $self->qp->hooks->{config} || [] }
|
||||
];
|
||||
}
|
||||
|
||||
sub test_exclude {
|
||||
my ( $self ) = @_;
|
||||
ok( ! $self->exclude, 'exclude() default method returns false' );
|
||||
|
Loading…
Reference in New Issue
Block a user