Bug 12748: (QA followup) make new tests pass
authorJesse Weaver <jweaver@bywatersolutions.com>
Mon, 25 Apr 2016 18:00:13 +0000 (12:00 -0600)
committerBrendan Gallagher <brendan@bywatersolutions.com>
Tue, 26 Apr 2016 20:20:14 +0000 (20:20 +0000)
  * t/Koha/ItemType.pm:
    * Rename to .t
    * Fix method names
  * t/db_dependent/Koha/ItemTypes.t: Fix method names and Koha::Database usage

Signed-off-by: Jesse Weaver <jweaver@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>
t/Koha/ItemType.pm [deleted file]
t/Koha/ItemType.t [new file with mode: 0755]
t/db_dependent/Koha/ItemTypes.t

diff --git a/t/Koha/ItemType.pm b/t/Koha/ItemType.pm
deleted file mode 100755 (executable)
index e47d5e2..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/usr/bin/perl
-#
-# Copyright 2014 Catalyst IT
-#
-# 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 => 8;
-
-BEGIN {
-    use_ok('Koha::ItemType');
-}
-
-my $data = {
-    itemtype       => 'CODE',
-    description    => 'description',
-    rentalcharge   => 'rentalcharge',
-    imageurl       => 'imageurl',
-    summary        => 'summary',
-    checkinmsg     => 'checkinmsg',
-    checkinmsgtype => 'checkinmsgtype',
-};
-
-my $type = Koha::ItemType->new($data);
-
-is( $type->code,           'CODE',           'itemtype/code' );
-is( $type->description,    'description',    'description' );
-is( $type->rentalcharge,   'rentalcharge',   'rentalcharge' );
-is( $type->imageurl,       'imageurl',       'imageurl' );
-is( $type->summary,        'summary',        'summary' );
-is( $type->checkinmsg,     'checkinmsg',     'checkinmsg' );
-is( $type->checkinmsgtype, 'checkinmsgtype', 'checkinmsgtype' );
diff --git a/t/Koha/ItemType.t b/t/Koha/ItemType.t
new file mode 100755 (executable)
index 0000000..ae94812
--- /dev/null
@@ -0,0 +1,46 @@
+#!/usr/bin/perl
+#
+# Copyright 2014 Catalyst IT
+#
+# 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 => 8;
+
+BEGIN {
+    use_ok('Koha::ItemType');
+}
+
+my $data = {
+    itemtype       => 'CODE',
+    description    => 'description',
+    rentalcharge   => 'rentalcharge',
+    imageurl       => 'imageurl',
+    summary        => 'summary',
+    checkinmsg     => 'checkinmsg',
+    checkinmsgtype => 'checkinmsgtype',
+};
+
+my $type = Koha::ItemType->new($data);
+
+is( $type->itemtype,       'CODE',           'itemtype/code' );
+is( $type->description,    'description',    'description' );
+is( $type->rentalcharge,   'rentalcharge',   'rentalcharge' );
+is( $type->imageurl,       'imageurl',       'imageurl' );
+is( $type->summary,        'summary',        'summary' );
+is( $type->checkinmsg,     'checkinmsg',     'checkinmsg' );
+is( $type->checkinmsgtype, 'checkinmsgtype', 'checkinmsgtype' );
index b6e61bc..9ce1ad6 100755 (executable)
 
 use Modern::Perl;
 
-use Test::More tests => 17;
+use Test::More tests => 18;
 use Data::Dumper;
 use Koha::Database;
 
 BEGIN {
+    use_ok('Koha::ItemType');
     use_ok('Koha::ItemTypes');
 }
 
@@ -31,7 +32,7 @@ my $database = Koha::Database->new();
 my $schema   = $database->schema();
 $schema->txn_begin;
 
-$schema->resultset('Itemtype')->create(
+Koha::ItemType->new(
     {
         itemtype       => 'type1',
         description    => 'description',
@@ -41,8 +42,9 @@ $schema->resultset('Itemtype')->create(
         checkinmsg     => 'checkinmsg',
         checkinmsgtype => 'checkinmsgtype',
     }
-);
-$schema->resultset('Itemtype')->create(
+)->store;
+
+Koha::ItemType->new(
     {
         itemtype       => 'type2',
         description    => 'description',
@@ -52,14 +54,11 @@ $schema->resultset('Itemtype')->create(
         checkinmsg     => 'checkinmsg',
         checkinmsgtype => 'checkinmsgtype',
     }
-);
-my $itypes = Koha::ItemTypes->new();
-
-my @types = $itypes->get_itemtype( 'type1', 'type2' );
+)->store;
 
-my $type = $types[0];
+my $type = Koha::ItemTypes->find('type1');
 ok( defined($type), 'first result' );
-is( $type->code,           'type1',          'itemtype/code' );
+is( $type->itemtype,       'type1',          'itemtype/code' );
 is( $type->description,    'description',    'description' );
 is( $type->rentalcharge,   '0.0000',             'rentalcharge' );
 is( $type->imageurl,       'imageurl',       'imageurl' );
@@ -67,9 +66,9 @@ is( $type->summary,        'summary',        'summary' );
 is( $type->checkinmsg,     'checkinmsg',     'checkinmsg' );
 is( $type->checkinmsgtype, 'checkinmsgtype', 'checkinmsgtype' );
 
-$type = $types[1];
+$type = Koha::ItemTypes->find('type2');
 ok( defined($type), 'second result' );
-is( $type->code,           'type2',          'itemtype/code' );
+is( $type->itemtype,       'type2',          'itemtype/code' );
 is( $type->description,    'description',    'description' );
 is( $type->rentalcharge,   '0.0000',             'rentalcharge' );
 is( $type->imageurl,       'imageurl',       'imageurl' );