Bug 12748: (QA followup) make new tests pass new_12478_elasticsearch
authorJesse Weaver <jweaver@bywatersolutions.com>
Mon, 25 Apr 2016 18:00:13 +0000 (12:00 -0600)
committerTomas Cohen Arazi <tomascohen@theke.io>
Tue, 26 Apr 2016 13:02:32 +0000 (10:02 -0300)
  * 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>

t/Koha/ItemType.t [moved from t/Koha/ItemType.pm with 95% similarity]
t/db_dependent/Koha/ItemTypes.t

similarity index 95%
rename from t/Koha/ItemType.pm
rename to t/Koha/ItemType.t
index e47d5e2..ae94812 100755 (executable)
@@ -37,7 +37,7 @@ my $data = {
 
 my $type = Koha::ItemType->new($data);
 
-is( $type->code,           'CODE',           'itemtype/code' );
+is( $type->itemtype,       'CODE',           'itemtype/code' );
 is( $type->description,    'description',    'description' );
 is( $type->rentalcharge,   'rentalcharge',   'rentalcharge' );
 is( $type->imageurl,       'imageurl',       'imageurl' );
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' );