Bug 6810: [QA Follow-up] Move test file to db_dependent
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Wed, 16 Sep 2015 12:49:11 +0000 (14:49 +0200)
committerTomas Cohen Arazi <tomascohen@theke.io>
Tue, 6 Oct 2015 14:13:58 +0000 (11:13 -0300)
Note that this was already mentioned by Jonathan on comment48.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
t/Members.t [deleted file]
t/db_dependent/Members/GetUpcomingMembershipExpires.t [new file with mode: 0644]

diff --git a/t/Members.t b/t/Members.t
deleted file mode 100644 (file)
index 241858f..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-#!/usr/bin/perl
-
-# This file is part of Koha.
-#
-# Copyright 2015 Biblibre
-#
-# 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, see <http://www.gnu.org/licenses>.
-
-use Modern::Perl;
-use C4::Members;
-use Test::MockModule;
-use t::lib::TestBuilder;
-use t::lib::Mocks qw( mock_preference );
-
-use Test::More tests => 5;
-use Test::MockModule;
-
-BEGIN {
-    use_ok('C4::Members');
-}
-
-my $date_time = new Test::MockModule('DateTime');
-$date_time->mock(
-    'now', sub {
-        return DateTime->new(
-            year      => 2015,
-            month     => 6,
-            day       => 15,
-        );
-
-});
-
-t::lib::Mocks::mock_preference('MembershipExpiryDaysNotice', 15);
-
-my $builder = t::lib::TestBuilder->new();
-$builder->build({
-    source => 'Category',
-    value  => {
-        categorycode            => 'AD',
-        description             => 'Adult',
-        enrolmentperiod         => 18,
-        upperagelimit           => 99,
-        category_type           => 'A',
-    },
-});
-
-$builder->build({
-    source => 'Branch',
-    value  => {
-        branchcode              => 'CR',
-        branchname              => 'My branch',
-    },
-});
-
-$builder->build({
-    source => 'Borrower',
-    value  => {
-        firstname               => 'Vincent',
-        surname                 => 'Martin',
-        cardnumber              => '80808081',
-        categorycode            => 'AD',
-        branchcode              => 'CR',
-        dateexpiry              => '2015-06-30'
-    },
-});
-
-$builder->build({
-    source => 'Borrower',
-    value  => {
-        firstname               => 'Claude',
-        surname                 => 'Dupont',
-        cardnumber              => '80808082',
-        categorycode            => 'AD',
-        branchcode              => 'CR',
-        dateexpiry              => '2015-06-29'
-    },
-});
-
-$builder->build({
-    source => 'Borrower',
-    value  => {
-        firstname               => 'Gilles',
-        surname                 => 'Dupond',
-        cardnumber              => '80808083',
-        categorycode            => 'AD',
-        branchcode              => 'CR',
-        dateexpiry              => '2015-07-02'
-    },
-});
-
-my $upcoming_mem_expires = C4::Members::GetUpcomingMembershipExpires();
-is(scalar(@$upcoming_mem_expires), 1, 'Get upcoming membership expires should return 1 borrower.');
-
-is($upcoming_mem_expires->[0]{surname}, 'Martin', 'Get upcoming membership expires should return borrower "Martin".');
-
-# Test GetUpcomingMembershipExpires() with MembershipExpiryDaysNotice == 0
-t::lib::Mocks::mock_preference('MembershipExpiryDaysNotice', 0);
-
-$upcoming_mem_expires = C4::Members::GetUpcomingMembershipExpires();
-is(scalar(@$upcoming_mem_expires), 0, 'Get upcoming membership expires with 0 MembershipExpiryDaysNotice should return 0.');
-
-# Test GetUpcomingMembershipExpires() with MembershipExpiryDaysNotice == undef
-t::lib::Mocks::mock_preference('MembershipExpiryDaysNotice', undef);
-
-$upcoming_mem_expires = C4::Members::GetUpcomingMembershipExpires();
-is(scalar(@$upcoming_mem_expires), 0, 'Get upcoming membership expires without MembershipExpiryDaysNotice should return 0.');
diff --git a/t/db_dependent/Members/GetUpcomingMembershipExpires.t b/t/db_dependent/Members/GetUpcomingMembershipExpires.t
new file mode 100644 (file)
index 0000000..241858f
--- /dev/null
@@ -0,0 +1,117 @@
+#!/usr/bin/perl
+
+# This file is part of Koha.
+#
+# Copyright 2015 Biblibre
+#
+# 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, see <http://www.gnu.org/licenses>.
+
+use Modern::Perl;
+use C4::Members;
+use Test::MockModule;
+use t::lib::TestBuilder;
+use t::lib::Mocks qw( mock_preference );
+
+use Test::More tests => 5;
+use Test::MockModule;
+
+BEGIN {
+    use_ok('C4::Members');
+}
+
+my $date_time = new Test::MockModule('DateTime');
+$date_time->mock(
+    'now', sub {
+        return DateTime->new(
+            year      => 2015,
+            month     => 6,
+            day       => 15,
+        );
+
+});
+
+t::lib::Mocks::mock_preference('MembershipExpiryDaysNotice', 15);
+
+my $builder = t::lib::TestBuilder->new();
+$builder->build({
+    source => 'Category',
+    value  => {
+        categorycode            => 'AD',
+        description             => 'Adult',
+        enrolmentperiod         => 18,
+        upperagelimit           => 99,
+        category_type           => 'A',
+    },
+});
+
+$builder->build({
+    source => 'Branch',
+    value  => {
+        branchcode              => 'CR',
+        branchname              => 'My branch',
+    },
+});
+
+$builder->build({
+    source => 'Borrower',
+    value  => {
+        firstname               => 'Vincent',
+        surname                 => 'Martin',
+        cardnumber              => '80808081',
+        categorycode            => 'AD',
+        branchcode              => 'CR',
+        dateexpiry              => '2015-06-30'
+    },
+});
+
+$builder->build({
+    source => 'Borrower',
+    value  => {
+        firstname               => 'Claude',
+        surname                 => 'Dupont',
+        cardnumber              => '80808082',
+        categorycode            => 'AD',
+        branchcode              => 'CR',
+        dateexpiry              => '2015-06-29'
+    },
+});
+
+$builder->build({
+    source => 'Borrower',
+    value  => {
+        firstname               => 'Gilles',
+        surname                 => 'Dupond',
+        cardnumber              => '80808083',
+        categorycode            => 'AD',
+        branchcode              => 'CR',
+        dateexpiry              => '2015-07-02'
+    },
+});
+
+my $upcoming_mem_expires = C4::Members::GetUpcomingMembershipExpires();
+is(scalar(@$upcoming_mem_expires), 1, 'Get upcoming membership expires should return 1 borrower.');
+
+is($upcoming_mem_expires->[0]{surname}, 'Martin', 'Get upcoming membership expires should return borrower "Martin".');
+
+# Test GetUpcomingMembershipExpires() with MembershipExpiryDaysNotice == 0
+t::lib::Mocks::mock_preference('MembershipExpiryDaysNotice', 0);
+
+$upcoming_mem_expires = C4::Members::GetUpcomingMembershipExpires();
+is(scalar(@$upcoming_mem_expires), 0, 'Get upcoming membership expires with 0 MembershipExpiryDaysNotice should return 0.');
+
+# Test GetUpcomingMembershipExpires() with MembershipExpiryDaysNotice == undef
+t::lib::Mocks::mock_preference('MembershipExpiryDaysNotice', undef);
+
+$upcoming_mem_expires = C4::Members::GetUpcomingMembershipExpires();
+is(scalar(@$upcoming_mem_expires), 0, 'Get upcoming membership expires without MembershipExpiryDaysNotice should return 0.');