in reply to How to mock Mail::Mailer
maybe you could wrap Mail::Mailer::new and force the testfile backend:
use strict; use warnings; use Mail::Mailer; package Mail::Mailer; my $basic_new; BEGIN{ $basic_new = *Mail::Mailer::new{CODE}; } sub new($@){ my @args = @_; $args[1] = 'testfile';# override type passed in use Data::Dumper; print Dumper \@args; return $basic_new->(@args); } package main; my $m = Mail::Mailer->new('smtp'); $m->open({To => 'me@here.com'}); print $m "hi\n";
I'm not sure if this would be considered to be a sane way of doing this by the experts. So please comment if I'm suggesting something stupid...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to mock Mail::Mailer
by SilasTheMonk (Chaplain) on Oct 13, 2009 at 17:55 UTC |