I am trying to write some testing code to mock Apache::Constants which is exporting some methods to the script. I know how to Mock a OO module, but not a module that is exporting just methods. This is the code I am mocking,
use Apache::Constants qw(OK DECLINED AUTH_REQUIRED); my $status = some_method(); return $status if ($status != OK);
I have tried this but this is not working so is probalbly just wrong.
$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";
gives me "Undefined subroutine &Apache::Constants::OK called"
The reason I tried Test::MockObject is that the Apache::Constants is being used in the module that I am testing so I need to be able to export this mock object to that other module.
In reply to Mocking Apache::Constants by Herkum
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |