use Test::MockModule; use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; FixMyStreet::override_config { ALLOWED_COBRANDS => ['bromley', 'fixmystreet'], COBRAND_FEATURES => { echo => { bromley => { sample_data => 1 } }, waste => { bromley => 1 } }, }, sub { $mech->host('bromley.fixmystreet.com'); subtest 'Missing address lookup' => sub { $mech->get_ok('/waste'); $mech->submit_form_ok({ with_fields => { postcode => 'BR1 1AA' } }); $mech->submit_form_ok({ with_fields => { address => 'missing' } }); $mech->content_contains('can’t find your address'); }; subtest 'Address lookup' => sub { $mech->get_ok('/waste'); $mech->submit_form_ok({ with_fields => { postcode => 'BR1 1AA' } }); $mech->submit_form_ok({ with_fields => { address => '1000000002' } }); $mech->content_contains('2 Example Street'); $mech->content_contains('Food Waste'); }; }; package SOAP::Result; sub result { return $_[0]->{result}; } sub new { my $c = shift; bless { @_ }, $c; } package main; FixMyStreet::override_config { ALLOWED_COBRANDS => 'bromley', COBRAND_FEATURES => { echo => { bromley => { url => 'http://example.org' } }, waste => { bromley => 1 } }, }, sub { subtest 'Address lookup, mocking SOAP call' => sub { my $integ = Test::MockModule->new('SOAP::Lite'); $integ->mock(call => sub { return SOAP::Result->new(result => { PointInfo => [ { Description => '1 Example Street', SharedRef => { Value => { anyType => 1000000001 } } }, { Description => '2 Example Street', SharedRef => { Value => { anyType => 1000000002 } } }, ], }); }); $mech->get_ok('/waste'); $mech->submit_form_ok({ with_fields => { postcode => 'BR1 1AA' } }); $mech->content_contains('2 Example Street'); }; }; done_testing;