diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2019-02-22 11:29:22 +0000 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2019-02-25 12:29:47 +0000 |
commit | fd5a8de180bd67fef7ce14c476ef0fd94c29ce19 (patch) | |
tree | 5b70ae898cfdce635edc58b7fd8fb05654750939 /perllib/FixMyStreet/TestMech.pm | |
parent | e481c2fd127c46024b1b15587981dca00eada44c (diff) |
Factor out test CSV content function.
Diffstat (limited to 'perllib/FixMyStreet/TestMech.pm')
-rw-r--r-- | perllib/FixMyStreet/TestMech.pm | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/TestMech.pm b/perllib/FixMyStreet/TestMech.pm index bb4a48d65..3ecb13b6a 100644 --- a/perllib/FixMyStreet/TestMech.pm +++ b/perllib/FixMyStreet/TestMech.pm @@ -716,4 +716,15 @@ sub encoded_content { return encode_utf8($self->content); } +sub content_as_csv { + my $self = shift; + open my $data_handle, '<', \$self->content; + my $csv = Text::CSV->new({ binary => 1 }); + my @rows; + while (my $row = $csv->getline($data_handle)) { + push @rows, $row; + } + return @rows; +} + 1; |