From 2ea55daf33f3b8b82502a7ce18cbdf2c8a678d27 Mon Sep 17 00:00:00 2001 From: piratefinn Date: Thu, 20 Apr 2017 18:15:34 +0100 Subject: [PATCH] Fixed texts now with strict# Please enter the commit message for your changes. Lines starting --- t/admin-approve.t | 23 ++++++++++++----------- t/admin-merge.t | 23 ++++++++++++----------- t/basic.t | 1 + t/search.t | 19 ++++++++++--------- t/user-history.t | 1 + 5 files changed, 36 insertions(+), 31 deletions(-) diff --git a/t/admin-approve.t b/t/admin-approve.t index 9320a2b..db3edd2 100644 --- a/t/admin-approve.t +++ b/t/admin-approve.t @@ -1,3 +1,4 @@ +use Mojo::Base -strict; use Test::More; use Test::Mojo; use Mojo::JSON; @@ -19,7 +20,7 @@ for (split ';', $sqlDeployment){ $dbh->do($_) or die $dbh->errstr; } -my $sqlDeployment = Mojo::File->new("$FindBin::Bin/../schema.sql")->slurp; +$sqlDeployment = Mojo::File->new("$FindBin::Bin/../schema.sql")->slurp; for (split ';', $sqlDeployment){ $dbh->do($_) or die $dbh->errstr; } @@ -53,7 +54,7 @@ $t->post_ok('/api/register' => json => $testJson) print "test 2 - Create organisation user account (Choco Billy)\n"; my $emailBilly = 'choco.billy@chocofarm.org'; my $passwordBilly = 'Choco'; -my $testJson = { +$testJson = { 'usertype' => 'organisation', 'token' => shift(@accountTokens), 'username' => 'ChocoBillysGreens', @@ -70,7 +71,7 @@ $t->post_ok('/api/register' => json => $testJson) print "test 3 - Create admin account\n"; my $emailAdmin = 'admin@foodloop.net'; my $passwordAdmin = 'ethics'; -my $testJson = { +$testJson = { 'usertype' => 'customer', 'token' => shift(@accountTokens), 'username' => 'admin', @@ -112,7 +113,7 @@ is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM PendingTransactions", is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Organisations", undef, ())}[0],1,"1 verified organisation (choco billy)" ; is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Transactions", undef, ())}[0],0,"No verified transactions." ; my $nameToTestTurtle = 'Turtle\'s Paradise'; -$json = { +my $json = { transaction_value => 20, transaction_type => 3, organisation_name => $nameToTestTurtle, @@ -180,7 +181,7 @@ $json = { postcode => "NW11 7GZ", session_key => $session_key, }; -my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; +$upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; $t->post_ok('/api/upload' => form => $upload ) ->status_is(200) ->json_is('/success', Mojo::JSON->true); @@ -200,7 +201,7 @@ $json = { organisation_id => $newPendingKalmOrgId, session_key => $session_key, }; -my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; +$upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; $t->post_ok('/api/upload' => form => $upload ) ->status_is(200) ->json_is('/success', Mojo::JSON->true); @@ -220,7 +221,7 @@ $json = { postcode => "NW1W 7GF", session_key => $session_key, }; -my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; +$upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; $t->post_ok('/api/upload' => form => $upload) ->status_is(200) ->json_is('/success', Mojo::JSON->true); @@ -241,7 +242,7 @@ $json = { organisation_id => $newPendingJunonOrgId, session_key => $session_key, }; -my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; +$upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; $t->post_ok('/api/upload' => form => $upload ) ->status_is(200) ->json_is('/success', Mojo::JSON->true) @@ -259,7 +260,7 @@ $json = { organisation_id => $newPendingJunonOrgId, session_key => $session_key, }; -my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; +$upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; $t->post_ok('/api/upload' => form => $upload ) ->status_is(200) ->json_is('/success', Mojo::JSON->true) @@ -301,7 +302,7 @@ $t->post_ok('/api/login' => json => $testJson) $session_key = $t->tx->res->json('/session_key'); print "test 18 - JSON is missing.\n"; -$t->post_ok('/api/admin-approve' => json) +$t->post_ok('/api/admin-approve' => json => {}) ->status_is(400) ->json_is('/success', Mojo::JSON->false) ->json_like('/message', qr/JSON is missing/i); @@ -383,7 +384,7 @@ is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Organisations WHERE N print "test 24 - valid approval (modify some).\n"; #TODO if we implement constraints on the input data this will fail -my $testName = "Change testing junon name"; +$testName = "Change testing junon name"; $json = { unvalidatedOrganisationId => $newPendingJunonOrgId, name => $testName, diff --git a/t/admin-merge.t b/t/admin-merge.t index dfd750d..bc3308f 100644 --- a/t/admin-merge.t +++ b/t/admin-merge.t @@ -1,3 +1,4 @@ +use Mojo::Base -strict; use Test::More; use Test::Mojo; use Mojo::JSON; @@ -19,7 +20,7 @@ for (split ';', $sqlDeployment){ $dbh->do($_) or die $dbh->errstr; } -my $sqlDeployment = Mojo::File->new("$FindBin::Bin/../schema.sql")->slurp; +$sqlDeployment = Mojo::File->new("$FindBin::Bin/../schema.sql")->slurp; for (split ';', $sqlDeployment){ $dbh->do($_) or die $dbh->errstr; } @@ -53,7 +54,7 @@ $t->post_ok('/api/register' => json => $testJson) print "test 2 - Create organisation user account (Choco Billy)\n"; my $emailBilly = 'choco.billy@chocofarm.org'; my $passwordBilly = 'Choco'; -my $testJson = { +$testJson = { 'usertype' => 'organisation', 'token' => shift(@accountTokens), 'username' => 'ChocoBillysGreens', @@ -70,7 +71,7 @@ $t->post_ok('/api/register' => json => $testJson) print "test 3 - Create admin account\n"; my $emailAdmin = 'admin@foodloop.net'; my $passwordAdmin = 'ethics'; -my $testJson = { +$testJson = { 'usertype' => 'customer', 'token' => shift(@accountTokens), 'username' => 'admin', @@ -110,7 +111,7 @@ is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM PendingTransactions", is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Organisations", undef, ())}[0],1,"1 verified organisation (choco billy)" ; is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Transactions", undef, ())}[0],0,"No verified transactions." ; my $nameToTestTurtle = 'Turtle\'s Paradise'; -$json = { +my $json = { transaction_value => 20, transaction_type => 3, organisation_name => $nameToTestTurtle, @@ -169,7 +170,7 @@ $json = { postcode => "", session_key => $session_key, }; -my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; +$upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; $t->post_ok('/api/upload' => form => $upload ) ->status_is(200) ->json_is('/success', Mojo::JSON->true); @@ -192,7 +193,7 @@ $json = { organisation_id => $newPendingTurtleOrgIdPartial, session_key => $session_key, }; -my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; +$upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; $t->post_ok('/api/upload' => form => $upload ) ->status_is(200) ->json_is('/success', Mojo::JSON->true); @@ -213,7 +214,7 @@ $json = { postcode => "NW9 5EB", session_key => $session_key, }; -my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; +$upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; $t->post_ok('/api/upload' => form => $upload) ->status_is(200) ->json_is('/success', Mojo::JSON->true); @@ -234,7 +235,7 @@ $json = { organisation_id => $newPendingJunonOrgId, session_key => $session_key, }; -my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; +$upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; $t->post_ok('/api/upload' => form => $upload ) ->status_is(200) ->json_is('/success', Mojo::JSON->true); @@ -251,7 +252,7 @@ $json = { organisation_id => $newPendingJunonOrgId, session_key => $session_key, }; -my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; +$upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; $t->post_ok('/api/upload' => form => $upload ) ->status_is(200) ->json_is('/success', Mojo::JSON->true); @@ -287,7 +288,7 @@ is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM PendingOrganisations" is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM PendingTransactions", undef, ())}[0],6,"6 unverified transactions." ; is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Organisations", undef, ())}[0],1,"1 verified organisation (choco billy)" ; is @{$t->app->db->selectrow_arrayref("SELECT COUNT(*) FROM Transactions", undef, ())}[0],0,"No verified transactions."; -my $json = { +$json = { unvalidatedOrganisationId => $newPendingTurtleOrgId, session_key => $session_key, }; @@ -355,7 +356,7 @@ $t->post_ok('/api/login' => json => $testJson) $session_key = $t->tx->res->json('/session_key'); print "test 22 - JSON is missing.\n"; -$t->post_ok('/api/admin-merge' => json) +$t->post_ok('/api/admin-merge' => json => {}) ->status_is(400) ->json_is('/success', Mojo::JSON->false) ->json_like('/message', qr/JSON is missing/); diff --git a/t/basic.t b/t/basic.t index 676340c..3a84078 100644 --- a/t/basic.t +++ b/t/basic.t @@ -1,3 +1,4 @@ +use Mojo::Base -strict; use Test::More; use Test::Mojo; diff --git a/t/search.t b/t/search.t index 3145c63..e414785 100644 --- a/t/search.t +++ b/t/search.t @@ -1,3 +1,4 @@ +use Mojo::Base -strict; use Test::More; use Test::Mojo; use Mojo::JSON; @@ -21,7 +22,7 @@ for (split ';', $sqlDeployment){ $dbh->do($_) or die $dbh->errstr; } -my $sqlDeployment = Mojo::File->new("$FindBin::Bin/../schema.sql")->slurp; +$sqlDeployment = Mojo::File->new("$FindBin::Bin/../schema.sql")->slurp; for (split ';', $sqlDeployment){ $dbh->do($_) or die $dbh->errstr; } @@ -40,19 +41,19 @@ my ($name, $address, $postcode) = ("Avanti Bar & Restaurant","57 Main St, Kirkby $statement->execute($value, $name, $address, $postcode); $value++; -my ($name, $address, $postcode) = ("Full House Noodle Bar","21 Common Garden St, Lancaster, Lancashire","LA1 1XD"); +($name, $address, $postcode) = ("Full House Noodle Bar","21 Common Garden St, Lancaster, Lancashire","LA1 1XD"); $statement->execute($value, $name, $address, $postcode); $value++; -my ($name, $address, $postcode) = ("The Quay's Fishbar","1 Adcliffe Rd, Lancaster","LA1 1SS"); +($name, $address, $postcode) = ("The Quay's Fishbar","1 Adcliffe Rd, Lancaster","LA1 1SS"); $statement->execute($value, $name, $address, $postcode); $value++; -my ($name, $address, $postcode) = ("Dan's Fishop","56 North Rd, Lancaster","LA1 1LT"); +($name, $address, $postcode) = ("Dan's Fishop","56 North Rd, Lancaster","LA1 1LT"); $statement->execute($value, $name, $address, $postcode); $value++; -my ($name, $address, $postcode) = ("Hodgeson's Chippy","96 Prospect St, Lancaster","LA1 3BH"); +($name, $address, $postcode) = ("Hodgeson's Chippy","96 Prospect St, Lancaster","LA1 3BH"); $statement->execute($value, $name, $address, $postcode); @@ -79,7 +80,7 @@ $t->post_ok('/api/register' => json => $testJson) print "test 2 - Create organisation user account (Choco Billy)\n"; my $emailBilly = 'choco.billy@chocofarm.org'; my $passwordBilly = 'Choco'; -my $testJson = { +$testJson = { 'usertype' => 'organisation', 'token' => shift(@accountTokens), 'username' => 'ChocoBillysGreens', @@ -131,7 +132,7 @@ print "test 3 - Login - Rufus (cookies, customer)\n"; login_rufus(); print "test 4 - Added something containing 'fish'\n"; -$json = { +my $json = { transaction_value => 10, transaction_type => 3, organisation_name => 'Shoreway Fisheries', @@ -167,7 +168,7 @@ $json = { postcode => "LA4 5BZ", session_key => $session_key, }; -my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; +$upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; $t->post_ok('/api/upload' => form => $upload ) ->status_is(200) ->json_is('/success', Mojo::JSON->true); @@ -182,7 +183,7 @@ $json = { postcode => "LA1 1ET", session_key => $session_key, }; -my $upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; +$upload = {json => Mojo::JSON::encode_json($json), file => {file => './t/test.jpg'}}; $t->post_ok('/api/upload' => form => $upload ) ->status_is(200) ->json_is('/success', Mojo::JSON->true); diff --git a/t/user-history.t b/t/user-history.t index 1ce05a0..3ff1ea2 100644 --- a/t/user-history.t +++ b/t/user-history.t @@ -1,3 +1,4 @@ +use Mojo::Base -strict; use Test::More skip_all => 'User History needs reworking'; use Test::Mojo; use Mojo::JSON qw(encode_json);;