diff options
55 files changed, 21 insertions, 233 deletions
diff --git a/perllib/FixMyStreet/TestMech.pm b/perllib/FixMyStreet/TestMech.pm index 166ba116f..094baab15 100644 --- a/perllib/FixMyStreet/TestMech.pm +++ b/perllib/FixMyStreet/TestMech.pm @@ -1,8 +1,16 @@ package FixMyStreet::TestMech; -use base qw(Test::WWW::Mechanize::Catalyst Test::Builder::Module); +use parent qw(Test::WWW::Mechanize::Catalyst Test::Builder::Module); use strict; -use warnings; +use warnings FATAL => 'all'; +use utf8; + +sub import { + strict->import; + warnings->import(FATAL => 'all'); + utf8->import; + Test::More->export_to_level(1); +} BEGIN { use FixMyStreet; diff --git a/t/app/controller/about.t b/t/app/controller/about.t index cec50abfa..8f3f25e27 100644 --- a/t/app/controller/about.t +++ b/t/app/controller/about.t @@ -1,11 +1,6 @@ -use utf8; -use strict; -use warnings; +use FixMyStreet::TestMech; -use Test::More; -use Test::WWW::Mechanize::Catalyst 'FixMyStreet::App'; - -ok( my $mech = Test::WWW::Mechanize::Catalyst->new, 'Created mech object' ); +ok( my $mech = FixMyStreet::TestMech->new, 'Created mech object' ); # check that we can get the page $mech->get_ok('/faq'); diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t index 5f8abe5a6..48a5edc44 100644 --- a/t/app/controller/admin.t +++ b/t/app/controller/admin.t @@ -1,7 +1,3 @@ -use strict; -use warnings; -use Test::More; - use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; diff --git a/t/app/controller/admin_permissions.t b/t/app/controller/admin_permissions.t index dd256173d..c79087639 100644 --- a/t/app/controller/admin_permissions.t +++ b/t/app/controller/admin_permissions.t @@ -1,7 +1,3 @@ -use strict; -use warnings; -use Test::More; - use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; diff --git a/t/app/controller/alert.t b/t/app/controller/alert.t index cb5949b8f..3ae71b7c1 100644 --- a/t/app/controller/alert.t +++ b/t/app/controller/alert.t @@ -1,6 +1,3 @@ -use strict; -use warnings; -use Test::More; use LWP::Protocol::PSGI; use FixMyStreet::TestMech; diff --git a/t/app/controller/alert_new.t b/t/app/controller/alert_new.t index ea38f7c25..f7d35f9a0 100644 --- a/t/app/controller/alert_new.t +++ b/t/app/controller/alert_new.t @@ -1,7 +1,3 @@ -use strict; -use warnings; -use Test::More; - use FixMyStreet::TestMech; use FixMyStreet::App; diff --git a/t/app/controller/around.t b/t/app/controller/around.t index c8aca04aa..fbb4e76cd 100644 --- a/t/app/controller/around.t +++ b/t/app/controller/around.t @@ -1,7 +1,3 @@ -use strict; -use warnings; -use Test::More; - use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; diff --git a/t/app/controller/auth.t b/t/app/controller/auth.t index 3a11cfc4a..d1e313df2 100644 --- a/t/app/controller/auth.t +++ b/t/app/controller/auth.t @@ -1,7 +1,3 @@ -use strict; -use warnings; - -use Test::More; use Test::MockModule; use FixMyStreet::TestMech; diff --git a/t/app/controller/auth_social.t b/t/app/controller/auth_social.t index 09fdf22d3..7a82fc813 100644 --- a/t/app/controller/auth_social.t +++ b/t/app/controller/auth_social.t @@ -1,6 +1,3 @@ -use strict; -use warnings; -use Test::More; use Test::MockModule; use LWP::Protocol::PSGI; use LWP::Simple; diff --git a/t/app/controller/contact.t b/t/app/controller/contact.t index 7c2769b9c..d98d81868 100644 --- a/t/app/controller/contact.t +++ b/t/app/controller/contact.t @@ -1,7 +1,3 @@ -use strict; -use warnings; -use Test::More; - use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; diff --git a/t/app/controller/dashboard.t b/t/app/controller/dashboard.t index c83902c48..9713d2d2c 100644 --- a/t/app/controller/dashboard.t +++ b/t/app/controller/dashboard.t @@ -1,6 +1,3 @@ -use strict; -use warnings; -use Test::More; use Test::MockTime ':all'; use FixMyStreet::TestMech; diff --git a/t/app/controller/index.t b/t/app/controller/index.t index 6b28a03d2..91d0a8fcb 100644 --- a/t/app/controller/index.t +++ b/t/app/controller/index.t @@ -1,7 +1,3 @@ -use strict; -use warnings; -use Test::More; - use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; diff --git a/t/app/controller/json.t b/t/app/controller/json.t index b2cea674f..f7410dbd0 100644 --- a/t/app/controller/json.t +++ b/t/app/controller/json.t @@ -1,8 +1,3 @@ -use strict; -use warnings; - -use Test::More; - use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; diff --git a/t/app/controller/moderate.t b/t/app/controller/moderate.t index 10287ab22..a4a7f3cb6 100644 --- a/t/app/controller/moderate.t +++ b/t/app/controller/moderate.t @@ -1,8 +1,3 @@ -use strict; -use warnings; -use Test::More; -use utf8; - use FixMyStreet::TestMech; use FixMyStreet::App; use Data::Dumper; diff --git a/t/app/controller/my.t b/t/app/controller/my.t index 00070ed81..8803e7877 100644 --- a/t/app/controller/my.t +++ b/t/app/controller/my.t @@ -1,8 +1,3 @@ -use strict; -use warnings; - -use Test::More; - use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; diff --git a/t/app/controller/my_planned.t b/t/app/controller/my_planned.t index 79ed0e72c..79d9e9e72 100644 --- a/t/app/controller/my_planned.t +++ b/t/app/controller/my_planned.t @@ -1,8 +1,3 @@ -use strict; -use warnings; - -use Test::More; - use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; diff --git a/t/app/controller/open311.t b/t/app/controller/open311.t index 9b0a6f8af..29cd38129 100644 --- a/t/app/controller/open311.t +++ b/t/app/controller/open311.t @@ -1,8 +1,3 @@ -use strict; -use warnings; - -use Test::More; - use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; diff --git a/t/app/controller/photo.t b/t/app/controller/photo.t index ad857b5e3..dbbc697d7 100644 --- a/t/app/controller/photo.t +++ b/t/app/controller/photo.t @@ -1,10 +1,3 @@ -use strict; -use utf8; # sign in error message has – in it -use warnings; -use feature 'say'; -use Test::More; -use utf8; - use FixMyStreet::TestMech; use FixMyStreet::App; use Web::Scraper; diff --git a/t/app/controller/questionnaire.t b/t/app/controller/questionnaire.t index f42908a3e..b046cec9b 100644 --- a/t/app/controller/questionnaire.t +++ b/t/app/controller/questionnaire.t @@ -1,6 +1,3 @@ -use strict; -use warnings; -use Test::More; use DateTime; use FixMyStreet::TestMech; diff --git a/t/app/controller/report_as_other.t b/t/app/controller/report_as_other.t index 551a59481..96c6df239 100644 --- a/t/app/controller/report_as_other.t +++ b/t/app/controller/report_as_other.t @@ -1,7 +1,3 @@ -use strict; -use warnings; -use Test::More; - use FixMyStreet::TestMech; use FixMyStreet::App; diff --git a/t/app/controller/report_display.t b/t/app/controller/report_display.t index b35a4a026..81b0ffb86 100644 --- a/t/app/controller/report_display.t +++ b/t/app/controller/report_display.t @@ -1,7 +1,3 @@ -use strict; -use warnings; -use Test::More; - use FixMyStreet::TestMech; use Web::Scraper; use Path::Class; diff --git a/t/app/controller/report_import.t b/t/app/controller/report_import.t index b956b61ae..25875b38a 100644 --- a/t/app/controller/report_import.t +++ b/t/app/controller/report_import.t @@ -1,7 +1,3 @@ -use strict; -use warnings; -use Test::More; - use FixMyStreet::TestMech; use FixMyStreet::App; use Web::Scraper; diff --git a/t/app/controller/report_inspect.t b/t/app/controller/report_inspect.t index e1723b0cd..8b375bfe4 100644 --- a/t/app/controller/report_inspect.t +++ b/t/app/controller/report_inspect.t @@ -1,7 +1,3 @@ -use strict; -use warnings; -use Test::More; - use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; diff --git a/t/app/controller/report_interest_count.t b/t/app/controller/report_interest_count.t index 3cb80ea5f..bd9660dea 100644 --- a/t/app/controller/report_interest_count.t +++ b/t/app/controller/report_interest_count.t @@ -1,6 +1,3 @@ -use strict; -use warnings; - package FixMyStreet::Cobrand::Tester; use parent 'FixMyStreet::Cobrand::Default'; @@ -11,8 +8,6 @@ sub can_support_problems { package main; -use Test::More; - use FixMyStreet::TestMech; use Web::Scraper; use Path::Class; diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t index 33324d210..36400ae81 100644 --- a/t/app/controller/report_new.t +++ b/t/app/controller/report_new.t @@ -1,8 +1,3 @@ -use strict; -use utf8; # sign in error message has – in it -use warnings; -use Test::More; - use FixMyStreet::TestMech; use FixMyStreet::App; use Web::Scraper; diff --git a/t/app/controller/report_new_mobile.t b/t/app/controller/report_new_mobile.t index 3dfb99b2f..7f71a2786 100644 --- a/t/app/controller/report_new_mobile.t +++ b/t/app/controller/report_new_mobile.t @@ -1,4 +1,3 @@ -use Test::More; use FixMyStreet::TestMech; use LWP::Protocol::PSGI; use t::Mock::MapItZurich; diff --git a/t/app/controller/report_new_open311.t b/t/app/controller/report_new_open311.t index e3a464f88..4c3fefc56 100644 --- a/t/app/controller/report_new_open311.t +++ b/t/app/controller/report_new_open311.t @@ -1,7 +1,3 @@ -use strict; -use warnings; -use Test::More; - use FixMyStreet::TestMech; use FixMyStreet::App; use Web::Scraper; diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t index a1e26476f..941989f24 100644 --- a/t/app/controller/report_updates.t +++ b/t/app/controller/report_updates.t @@ -1,7 +1,3 @@ -use strict; -use warnings; -use Test::More; - use FixMyStreet::TestMech; use Web::Scraper; use Path::Class; diff --git a/t/app/controller/reports.t b/t/app/controller/reports.t index 56b4cce8c..8e226de8c 100644 --- a/t/app/controller/reports.t +++ b/t/app/controller/reports.t @@ -1,6 +1,3 @@ -use strict; -use warnings; -use Test::More; use FixMyStreet::TestMech; use mySociety::MaPit; use FixMyStreet::App; diff --git a/t/app/controller/rss.t b/t/app/controller/rss.t index bec504760..2258c9f5b 100644 --- a/t/app/controller/rss.t +++ b/t/app/controller/rss.t @@ -1,7 +1,3 @@ -use strict; -use warnings; -use Test::More; - use FixMyStreet::TestMech; use FixMyStreet::App; diff --git a/t/app/controller/token.t b/t/app/controller/token.t index ac88f4f7a..858838865 100644 --- a/t/app/controller/token.t +++ b/t/app/controller/token.t @@ -1,8 +1,3 @@ -use strict; -use warnings; -use Test::More; -use utf8; - use FixMyStreet::TestMech; use FixMyStreet::App; diff --git a/t/app/helpers/send_email.t b/t/app/helpers/send_email.t index 66b771292..a692fb6bc 100644 --- a/t/app/helpers/send_email.t +++ b/t/app/helpers/send_email.t @@ -1,20 +1,10 @@ -use strict; -use warnings; -use utf8; - package FixMyStreet::Cobrand::Tester; use parent 'FixMyStreet::Cobrand::Default'; sub path_to_email_templates { [ FixMyStreet->path_to( 't', 'app', 'helpers', 'emails') ] } package main; -BEGIN { - use FixMyStreet; - FixMyStreet->test_mode(1); -} - use Email::MIME; -use Test::More; use Test::LongString; use Catalyst::Test 'FixMyStreet::App'; diff --git a/t/app/load_general_config.t b/t/app/load_general_config.t index 16ca2fc54..aace85c86 100644 --- a/t/app/load_general_config.t +++ b/t/app/load_general_config.t @@ -3,8 +3,8 @@ use warnings; use Test::More tests => 2; -use_ok 'FixMyStreet::App'; +use_ok 'FixMyStreet'; -is FixMyStreet::App->config->{GAZE_URL}, +is FixMyStreet->config('GAZE_URL'), 'https://gaze.mysociety.org/gaze', "check that known config param is loaded"; diff --git a/t/app/model/alert_type.t b/t/app/model/alert_type.t index 5e4fcec0a..2e1298134 100644 --- a/t/app/model/alert_type.t +++ b/t/app/model/alert_type.t @@ -1,6 +1,3 @@ -use strict; -use warnings; -use Test::More; use FixMyStreet::TestMech; mySociety::Locale::gettext_domain( 'FixMyStreet' ); diff --git a/t/app/model/defecttype.t b/t/app/model/defecttype.t index 0f66ac684..6a03deded 100644 --- a/t/app/model/defecttype.t +++ b/t/app/model/defecttype.t @@ -1,7 +1,3 @@ -use strict; -use warnings; -use Test::More; - use FixMyStreet::App; use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; diff --git a/t/app/model/extra.t b/t/app/model/extra.t index 3b46ce128..2d5c3d5e0 100644 --- a/t/app/model/extra.t +++ b/t/app/model/extra.t @@ -4,7 +4,6 @@ use Test::More; use utf8; use FixMyStreet::DB; -use Data::Dumper; use DateTime; my $db = FixMyStreet::DB->connect; diff --git a/t/app/model/moderation.t b/t/app/model/moderation.t index 8fa333db4..4dbda3f6c 100644 --- a/t/app/model/moderation.t +++ b/t/app/model/moderation.t @@ -5,7 +5,6 @@ use Test::Exception; use utf8; use FixMyStreet::DB; -use Data::Dumper; use DateTime; my $dt = DateTime->now; diff --git a/t/app/model/problem.t b/t/app/model/problem.t index 47f654236..d95aec98d 100644 --- a/t/app/model/problem.t +++ b/t/app/model/problem.t @@ -1,8 +1,3 @@ -use strict; -use warnings; - -use Test::More; - use FixMyStreet::TestMech; use FixMyStreet; use FixMyStreet::App; diff --git a/t/app/model/questionnaire.t b/t/app/model/questionnaire.t index 945a64633..9685c5345 100644 --- a/t/app/model/questionnaire.t +++ b/t/app/model/questionnaire.t @@ -1,8 +1,3 @@ -use strict; -use warnings; - -use Test::More; - use FixMyStreet; use FixMyStreet::TestMech; diff --git a/t/app/model/user.t b/t/app/model/user.t index dd8b8ca5d..76d395fdc 100644 --- a/t/app/model/user.t +++ b/t/app/model/user.t @@ -1,8 +1,3 @@ -use strict; -use warnings; - -use Test::More; - use FixMyStreet::TestMech; use FixMyStreet::DB; diff --git a/t/app/model/user_planned_report.t b/t/app/model/user_planned_report.t index 95a76615e..3473e1bbd 100644 --- a/t/app/model/user_planned_report.t +++ b/t/app/model/user_planned_report.t @@ -1,8 +1,3 @@ -use strict; -use warnings; - -use Test::More; - use FixMyStreet::TestMech; use FixMyStreet::DB; diff --git a/t/app/script/archive_old_enquiries.t b/t/app/script/archive_old_enquiries.t index e87d6a0f8..589aeceda 100644 --- a/t/app/script/archive_old_enquiries.t +++ b/t/app/script/archive_old_enquiries.t @@ -1,6 +1,3 @@ -use strict; -use warnings; -use Test::More; use FixMyStreet::TestMech; use FixMyStreet::Script::ArchiveOldEnquiries; diff --git a/t/app/sendreport/email.t b/t/app/sendreport/email.t index 471145dcb..a9bc9f2b1 100644 --- a/t/app/sendreport/email.t +++ b/t/app/sendreport/email.t @@ -1,8 +1,3 @@ -use strict; -use warnings; - -use Test::More; - use FixMyStreet; use FixMyStreet::DB; use FixMyStreet::SendReport::Email; diff --git a/t/app/sendreport/inspection_required.t b/t/app/sendreport/inspection_required.t index f9d40d39f..f588e00f1 100644 --- a/t/app/sendreport/inspection_required.t +++ b/t/app/sendreport/inspection_required.t @@ -1,8 +1,3 @@ -use strict; -use warnings; - -use Test::More; - use FixMyStreet; use FixMyStreet::DB; use FixMyStreet::TestMech; @@ -31,13 +26,13 @@ my @reports = $mech->create_problems_for_body( 1, $body->id, 'Test', { }); my $report = $reports[0]; -subtest 'Report isn’t sent if uninspected' => sub { +subtest "Report isn't sent if uninspected" => sub { $mech->clear_emails_ok; FixMyStreet::DB->resultset('Problem')->send_reports(); $mech->email_count_is( 0 ); - is $report->whensent, undef, 'Report hasn’t been sent'; + is $report->whensent, undef, "Report hasn't been sent"; }; subtest 'Report is sent when inspected' => sub { @@ -72,7 +67,7 @@ subtest 'Uninspected report is sent when made by trusted user' => sub { is $report->get_extra_metadata('inspected'), undef, 'Report not marked as inspected'; }; -subtest 'Uninspected report isn’t sent when user rep is too low' => sub { +subtest "Uninspected report isn't sent when user rep is too low" => sub { $mech->clear_emails_ok; $report->whensent( undef ); $report->update; @@ -88,7 +83,7 @@ subtest 'Uninspected report isn’t sent when user rep is too low' => sub { $report->discard_changes; $mech->email_count_is( 0 ); - is $report->whensent, undef, 'Report hasn’t been sent'; + is $report->whensent, undef, "Report hasn't been sent"; }; subtest 'Uninspected report is sent when user rep is high enough' => sub { diff --git a/t/cobrand/bromley.t b/t/cobrand/bromley.t index a7cc563dc..0a0ac5163 100644 --- a/t/cobrand/bromley.t +++ b/t/cobrand/bromley.t @@ -1,7 +1,3 @@ -use strict; -use warnings; -use Test::More; - use CGI::Simple; use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; diff --git a/t/cobrand/closest.t b/t/cobrand/closest.t index 8bb2d649b..a7d09842b 100644 --- a/t/cobrand/closest.t +++ b/t/cobrand/closest.t @@ -1,7 +1,3 @@ -use strict; -use warnings; - -use Test::More; use t::Mock::Bing; use mySociety::Locale; diff --git a/t/cobrand/councils.t b/t/cobrand/councils.t index 0e8b71f04..4de8bbf2e 100644 --- a/t/cobrand/councils.t +++ b/t/cobrand/councils.t @@ -1,7 +1,3 @@ -use strict; -use warnings; -use Test::More; - use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; diff --git a/t/cobrand/fixamingata.t b/t/cobrand/fixamingata.t index d6a1c2b34..1ae637229 100644 --- a/t/cobrand/fixamingata.t +++ b/t/cobrand/fixamingata.t @@ -1,13 +1,5 @@ -use strict; -use warnings; -use Test::More; use Test::MockModule; -BEGIN { - use FixMyStreet; - FixMyStreet->test_mode(1); -} - use mySociety::Locale; use FixMyStreet::TestMech; diff --git a/t/cobrand/form_extras.t b/t/cobrand/form_extras.t index 22a86ef21..e0727018f 100644 --- a/t/cobrand/form_extras.t +++ b/t/cobrand/form_extras.t @@ -1,6 +1,3 @@ -use strict; -use warnings; - package FixMyStreet::Cobrand::Tester; use parent 'FixMyStreet::Cobrand::FixMyStreet'; @@ -18,7 +15,6 @@ sub path_to_web_templates { package main; -use Test::More; use FixMyStreet::TestMech; # disable info logs for this test run diff --git a/t/cobrand/hart.t b/t/cobrand/hart.t index f4a2473eb..d1681a537 100644 --- a/t/cobrand/hart.t +++ b/t/cobrand/hart.t @@ -1,7 +1,3 @@ -use strict; -use warnings; -use Test::More; - use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; diff --git a/t/cobrand/oxfordshire.t b/t/cobrand/oxfordshire.t index d5effacae..fad41be31 100644 --- a/t/cobrand/oxfordshire.t +++ b/t/cobrand/oxfordshire.t @@ -1,7 +1,3 @@ -use strict; -use warnings; -use Test::More; - use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; @@ -61,7 +57,7 @@ subtest 'Exor RDI download appears on Oxfordshire cobrand admin' => sub { } }; -subtest 'Exor RDI download doesn’t appear outside of Oxfordshire cobrand admin' => sub { +subtest "Exor RDI download doesn't appear outside of Oxfordshire cobrand admin" => sub { FixMyStreet::override_config { ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ], }, sub { diff --git a/t/cobrand/restriction.t b/t/cobrand/restriction.t index 873a396b7..4d15cdc48 100644 --- a/t/cobrand/restriction.t +++ b/t/cobrand/restriction.t @@ -17,7 +17,6 @@ sub updates_restriction { package main; -use Test::More; use FixMyStreet::TestMech; my $c = FixMyStreet::App->new; diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t index 0a84d2d03..947baaec8 100644 --- a/t/cobrand/zurich.t +++ b/t/cobrand/zurich.t @@ -1,15 +1,14 @@ # TODO # Overdue alerts -use strict; -use warnings; use DateTime; use Email::MIME; use LWP::Protocol::PSGI; -use Test::More; use Test::LongString; use Path::Tiny; use t::Mock::MapItZurich; +use FixMyStreet::TestMech; +my $mech = FixMyStreet::TestMech->new; # Check that you have the required locale installed - the following # should return a line with de_CH.utf8 in. If not install that locale. @@ -53,9 +52,6 @@ sub reset_report_state { $report->update; } -use FixMyStreet::TestMech; -my $mech = FixMyStreet::TestMech->new; - # Front page test ok $mech->host("zurich.example.com"), "change host to Zurich"; FixMyStreet::override_config { diff --git a/t/map/tilma/original.t b/t/map/tilma/original.t index f16f5b244..a38c69e68 100644 --- a/t/map/tilma/original.t +++ b/t/map/tilma/original.t @@ -1,6 +1,3 @@ -use strict; -use warnings; -use Test::More; use FixMyStreet::DB; use FixMyStreet::Map; use FixMyStreet::TestMech; diff --git a/t/sendreport/open311.t b/t/sendreport/open311.t index c40b64d12..4dfbde5bd 100644 --- a/t/sendreport/open311.t +++ b/t/sendreport/open311.t @@ -1,7 +1,3 @@ -use strict; -use warnings; -use Test::More; - use CGI::Simple; use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; |