1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
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;
|