diff options
author | Struan Donald <struan@exo.org.uk> | 2013-09-12 18:05:35 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2013-09-12 18:05:35 +0100 |
commit | aeba8e0da58b8e04fbbe0e9923fe8c784f3d54e1 (patch) | |
tree | 6634864661b4e6e5ca6765700b85fba70696083d /t | |
parent | 1aca7d00c5a780824c9e0f1b1615d2fa96fa1506 (diff) |
switch to Sub::Override from Test::MockModule
This is for consistency as Sub::Override is used for another test and
also so we minimise the number of modules installed just for testing
Diffstat (limited to 't')
-rw-r--r-- | t/app/model/problem.t | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/t/app/model/problem.t b/t/app/model/problem.t index 156ad7fbb..9138c11a8 100644 --- a/t/app/model/problem.t +++ b/t/app/model/problem.t @@ -9,6 +9,7 @@ use FixMyStreet; use FixMyStreet::App; use FixMyStreet::TestMech; use mySociety::Locale; +use Sub::Override; mySociety::Locale::gettext_domain('FixMyStreet'); @@ -583,9 +584,10 @@ foreach my $test ( { } subtest 'check can turn on report sent email alerts' => sub { - eval 'use Test::MockModule; 1' or - plan skip_all => 'Skipping tests that rely on Test::MockModule'; - + my $send_confirmation_mail_override = Sub::Override->new( + "FixMyStreet::Cobrand::Default::report_sent_confirmation_email", + sub { return 1; } + ); $mech->clear_emails_ok; FixMyStreet::App->model('DB::Problem')->search( @@ -606,9 +608,6 @@ subtest 'check can turn on report sent email alerts' => sub { send_fail_count => 0, } ); - my $m = new Test::MockModule( - 'FixMyStreet::Cobrand::FixMyStreet' ); - $m->mock( report_sent_confirmation_email => 1 ); FixMyStreet::App->model('DB::Problem')->send_reports(); $mech->email_count_is( 2 ); @@ -628,6 +627,8 @@ subtest 'check can turn on report sent email alerts' => sub { $email = $emails[1]; like $email->header('Subject'), qr/Problem Report Sent/, 'report sent email title correct'; like $email->body, qr/Your report about/, 'report sent body correct'; + + $send_confirmation_mail_override->restore(); }; |