aboutsummaryrefslogtreecommitdiffstats
path: root/bin/fixmystreet.com/fixture
blob: 93982af8a3e729f2bc2e45c801c9b68f023ed6a7 (plain)
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
#!/usr/bin/env perl
#
# This script will create a test body and its categories, covering the area of
# Westminster, and a user associated with that body, which should help testing
# of report interactions.

use strict;
use warnings;

BEGIN {
    use File::Basename qw(dirname);
    use File::Spec;
    my $d = dirname(File::Spec->rel2abs($0));
    require "$d/../../setenv.pl";
}

use FixMyStreet::DB;

my $body = FixMyStreet::DB->resultset("Body")->find_or_create({ name => 'Test City Council' });
$body->body_areas->find_or_create({ area_id => 2504 });
foreach ("Potholes", "Street lighting", "Graffiti") {
    (my $email = lc $_) =~ s/ /-/g;
    $body->contacts->find_or_create({
        category => $_,
        email => $email . '@example.net',
        confirmed => 't',
        deleted => 'f',
        whenedited => \'current_timestamp',
        editor => 'fixture',
        note => 'Created by fixture'
    });
}

FixMyStreet::DB->resultset("User")->find_or_create({
    email => 'council@example.net',
    name => 'Test City Council User',
    from_body => $body,
    password => 'password',
});