From 361eef9f15a249f8ad1a1a0a8ee4161324b17cc3 Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Sun, 29 Jan 2017 15:59:53 +0000 Subject: [PATCH] Bug 17944 - Implemented a subtest in the ItemTypes.t file for is_used function in ItemType.pm Test plan: 1. Go to t/db_dependent/Koha/ 2. Start koha-shell: sudo koha-shell 3. Run the ItemTypes.t unit test: prove -v ItemTypes.t 4. Notice all tests are successful, and notice that the last two outputs show the is_used subtest gave successful results --- t/db_dependent/Koha/ItemTypes.t | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/t/db_dependent/Koha/ItemTypes.t b/t/db_dependent/Koha/ItemTypes.t index 8417369..1064118 100755 --- a/t/db_dependent/Koha/ItemTypes.t +++ b/t/db_dependent/Koha/ItemTypes.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 18; +use Test::More tests => 20; use Data::Dumper; use Koha::Database; use Koha::Items; @@ -78,7 +78,7 @@ Koha::Item->new( itemnumber => 1, biblionumber => 1, biblioitemnumber =>1, - itype => 'type2', + itype => 'type1', notforloan => 1, itemlost => 0, } @@ -106,8 +106,8 @@ is( $type->checkinmsg, 'checkinmsg', 'checkinmsg' ); is( $type->checkinmsgtype, 'checkinmsgtype', 'checkinmsgtype' ); -subtest is_used => sub{ - plan test => 2; +sub is_used { + require Test::More; my $itemtype_code = shift; my $schema = Koha::Database->new()->schema(); my $itemtotal = Koha::Items->search({ 'itype' => $itemtype_code })->count; @@ -115,8 +115,11 @@ subtest is_used => sub{ my $overalltotal = $itemtotal + $bibliototal; return $overalltotal; } -for my $itemtype_code ('type1', 'type 2') { - subtest "is_used $itemtype_code", \&is_used, $range; -} +my $passcount = is_used('type1'); +is ( $passcount, 2, 'Exists in the database, test is successful'); + +my $failcount = is_used('type2'); +is ( $failcount, 0, 'Doesnt exist in database, test is success'); + $schema->txn_rollback; -- 2.1.4