Bug 13799: Rename t/.../v1/borrowers.t to t/.../v1/patrons.t
authorJulian Maurice <julian.maurice@biblibre.com>
Fri, 30 Oct 2015 07:49:23 +0000 (08:49 +0100)
committerTomas Cohen Arazi <tomascohen@theke.io>
Wed, 4 Nov 2015 16:47:33 +0000 (13:47 -0300)
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
t/db_dependent/api/v1/borrowers.t [deleted file]
t/db_dependent/api/v1/patrons.t [new file with mode: 0644]

diff --git a/t/db_dependent/api/v1/borrowers.t b/t/db_dependent/api/v1/borrowers.t
deleted file mode 100644 (file)
index ae3e4a4..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-#!/usr/bin/env perl
-
-# This file is part of Koha.
-#
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 3 of the License, or (at your option) any later
-# version.
-#
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-use Modern::Perl;
-
-use Test::More tests => 10;
-use Test::Mojo;
-use t::lib::TestBuilder;
-
-use C4::Auth;
-use C4::Context;
-
-use Koha::Database;
-use Koha::Borrower;
-
-my $builder = t::lib::TestBuilder->new();
-
-my $dbh = C4::Context->dbh;
-$dbh->{AutoCommit} = 0;
-$dbh->{RaiseError} = 1;
-
-$ENV{REMOTE_ADDR} = '127.0.0.1';
-my $t = Test::Mojo->new('Koha::REST::V1');
-
-my $categorycode = $builder->build({ source => 'Category' })->{ categorycode };
-my $branchcode = $builder->build({ source => 'Branch' })->{ branchcode };
-my $borrower = $builder->build({
-    source => 'Borrower',
-    value => {
-        branchcode   => $branchcode,
-        categorycode => $categorycode
-    }
-});
-
-$t->get_ok('/api/v1/borrowers')
-  ->status_is(403);
-
-$t->get_ok("/api/v1/borrowers/" . $borrower->{ borrowernumber })
-  ->status_is(403);
-
-my $loggedinuser = $builder->build({
-    source => 'Borrower',
-    value => {
-        branchcode   => $branchcode,
-        categorycode => $categorycode,
-        flags        => 16 # borrowers flag
-    }
-});
-
-my $session = C4::Auth::get_session('');
-$session->param('number', $loggedinuser->{ borrowernumber });
-$session->param('id', $loggedinuser->{ userid });
-$session->param('ip', '127.0.0.1');
-$session->param('lasttime', time());
-$session->flush;
-
-my $tx = $t->ua->build_tx(GET => '/api/v1/borrowers');
-$tx->req->cookies({name => 'CGISESSID', value => $session->id});
-$tx->req->env({REMOTE_ADDR => '127.0.0.1'});
-$t->request_ok($tx)
-  ->status_is(200);
-
-$tx = $t->ua->build_tx(GET => "/api/v1/borrowers/" . $borrower->{ borrowernumber });
-$tx->req->cookies({name => 'CGISESSID', value => $session->id});
-$t->request_ok($tx)
-  ->status_is(200)
-  ->json_is('/borrowernumber' => $borrower->{ borrowernumber })
-  ->json_is('/surname' => $borrower->{ surname });
-
-$dbh->rollback;
diff --git a/t/db_dependent/api/v1/patrons.t b/t/db_dependent/api/v1/patrons.t
new file mode 100644 (file)
index 0000000..344cac9
--- /dev/null
@@ -0,0 +1,84 @@
+#!/usr/bin/env perl
+
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 3 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with Koha; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+use Modern::Perl;
+
+use Test::More tests => 10;
+use Test::Mojo;
+use t::lib::TestBuilder;
+
+use C4::Auth;
+use C4::Context;
+
+use Koha::Database;
+use Koha::Borrower;
+
+my $builder = t::lib::TestBuilder->new();
+
+my $dbh = C4::Context->dbh;
+$dbh->{AutoCommit} = 0;
+$dbh->{RaiseError} = 1;
+
+$ENV{REMOTE_ADDR} = '127.0.0.1';
+my $t = Test::Mojo->new('Koha::REST::V1');
+
+my $categorycode = $builder->build({ source => 'Category' })->{ categorycode };
+my $branchcode = $builder->build({ source => 'Branch' })->{ branchcode };
+my $borrower = $builder->build({
+    source => 'Borrower',
+    value => {
+        branchcode   => $branchcode,
+        categorycode => $categorycode
+    }
+});
+
+$t->get_ok('/api/v1/patrons')
+  ->status_is(403);
+
+$t->get_ok("/api/v1/patrons/" . $borrower->{ borrowernumber })
+  ->status_is(403);
+
+my $loggedinuser = $builder->build({
+    source => 'Borrower',
+    value => {
+        branchcode   => $branchcode,
+        categorycode => $categorycode,
+        flags        => 16 # borrowers flag
+    }
+});
+
+my $session = C4::Auth::get_session('');
+$session->param('number', $loggedinuser->{ borrowernumber });
+$session->param('id', $loggedinuser->{ userid });
+$session->param('ip', '127.0.0.1');
+$session->param('lasttime', time());
+$session->flush;
+
+my $tx = $t->ua->build_tx(GET => '/api/v1/patrons');
+$tx->req->cookies({name => 'CGISESSID', value => $session->id});
+$tx->req->env({REMOTE_ADDR => '127.0.0.1'});
+$t->request_ok($tx)
+  ->status_is(200);
+
+$tx = $t->ua->build_tx(GET => "/api/v1/patrons/" . $borrower->{ borrowernumber });
+$tx->req->cookies({name => 'CGISESSID', value => $session->id});
+$t->request_ok($tx)
+  ->status_is(200)
+  ->json_is('/borrowernumber' => $borrower->{ borrowernumber })
+  ->json_is('/surname' => $borrower->{ surname });
+
+$dbh->rollback;