use Apache::Constants qw(OK DECLINED AUTH_REQUIRED); my $status = some_method(); return $status if ($status != OK); #### $INC{Apache/Constants.pm} = 1; my $constants = Test::MockObject->new(); $constants->fake_module('Apache::Constants'); $constants->mock('OK', sub { return 1 } ); warn "OK is " . OK . "\n";