I have a module that uses to Mail::Mailer to send out emails. Now I could really do with a test script to lock its fairly basic functionality in place. I don't want to change the code of this module at the moment as it is in use in production. I just want to build a test script around it.
I have tried using Test::MockObject and this works as far as it goes. So I can see that in my test script I can set up my mockup of Mail::Mailer in a BEGIN function. Then when I load the module under test and debug it - lo and behold the created $mailer object is a Test::MockObject rather than a Mail::Mailer. I can mock the open and close methods. The issue is that the code calls
so $mailer needs to be a GLOB reference. Fine I can pass a GLOB reference into the Test::MockObject constructor and yes the mock object is at root a GLOB reference. But I am still a lost. It is as if I have opened up a telephone exchange box and I know more or less how the cabling works, but I have lost the colour coding of the cables. Could anyone advise me how you actually connect the print cable up with the glob cable?print {$mailer} $body || croak "couldn't send whole message: $!\n";
In reply to How to mock Mail::Mailer by SilasTheMonk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |