Bug 12478 - add test cases
Signed-off-by: Nick Clemens <nick@bywatersolutions.com> 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>
This commit is contained in:
parent
d9cdde9d27
commit
de084f7087
|
|
@ -1,5 +1,7 @@
|
|||
#!/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
|
||||
|
|
|
|||
|
|
@ -17,49 +17,64 @@
|
|||
# with Koha; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
# XXX This doesn't work because I need to figure out how to do transactions
|
||||
# in a test-case with DBIx::Class
|
||||
|
||||
use Modern::Perl;
|
||||
|
||||
use Test::More tests => 8;
|
||||
use Test::More tests => 17;
|
||||
use Data::Dumper;
|
||||
use Koha::Database;
|
||||
|
||||
BEGIN {
|
||||
use_ok('Koha::ItemTypes');
|
||||
}
|
||||
|
||||
my $dbh = C4::Context->dbh;
|
||||
|
||||
# Start transaction
|
||||
$dbh->{AutoCommit} = 0;
|
||||
$dbh->{RaiseError} = 1;
|
||||
|
||||
my $prep = $dbh->prepare('INSERT INTO itemtypes (itemtype, description, rentalcharge, imageurl, summary, checkinmsg, checkinmsgtype) VALUES (?,?,?,?,?,?,?)');
|
||||
$prep->execute('type1', 'description', 'rentalcharge', 'imageurl', 'summary', 'checkinmsg', 'checkinmsgtype');
|
||||
$prep->execute('type2', 'description', 'rentalcharge', 'imageurl', 'summary', 'checkinmsg', 'checkinmsgtype');
|
||||
my $database = Koha::Database->new();
|
||||
my $schema = $database->schema();
|
||||
$schema->txn_begin;
|
||||
|
||||
$schema->resultset('Itemtype')->create(
|
||||
{
|
||||
itemtype => 'type1',
|
||||
description => 'description',
|
||||
rentalcharge => '0.00',
|
||||
imageurl => 'imageurl',
|
||||
summary => 'summary',
|
||||
checkinmsg => 'checkinmsg',
|
||||
checkinmsgtype => 'checkinmsgtype',
|
||||
}
|
||||
);
|
||||
$schema->resultset('Itemtype')->create(
|
||||
{
|
||||
itemtype => 'type2',
|
||||
description => 'description',
|
||||
rentalcharge => '0.00',
|
||||
imageurl => 'imageurl',
|
||||
summary => 'summary',
|
||||
checkinmsg => 'checkinmsg',
|
||||
checkinmsgtype => 'checkinmsgtype',
|
||||
}
|
||||
);
|
||||
my $itypes = Koha::ItemTypes->new();
|
||||
|
||||
my @types = $itypes->get_itemtype('type1', 'type2');
|
||||
my @types = $itypes->get_itemtype( 'type1', 'type2' );
|
||||
|
||||
die Dumper(\@types);
|
||||
my $type = $types[0];
|
||||
ok(defined($type), 'first result');
|
||||
is( $type->code, 'type1', 'itemtype/code' );
|
||||
ok( defined($type), 'first result' );
|
||||
is( $type->code, 'type1', 'itemtype/code' );
|
||||
is( $type->description, 'description', 'description' );
|
||||
is( $type->rentalcharge, 'rentalcharge', 'rentalcharge' );
|
||||
is( $type->rentalcharge, '0.0000', 'rentalcharge' );
|
||||
is( $type->imageurl, 'imageurl', 'imageurl' );
|
||||
is( $type->summary, 'summary', 'summary' );
|
||||
is( $type->checkinmsg, 'checkinmsg', 'checkinmsg' );
|
||||
is( $type->checkinmsgtype, 'checkinmsgtype', 'checkinmsgtype' );
|
||||
|
||||
$type = $types[1];
|
||||
ok(defined($type), 'second result');
|
||||
is( $type->code, 'type2', 'itemtype/code' );
|
||||
ok( defined($type), 'second result' );
|
||||
is( $type->code, 'type2', 'itemtype/code' );
|
||||
is( $type->description, 'description', 'description' );
|
||||
is( $type->rentalcharge, 'rentalcharge', 'rentalcharge' );
|
||||
is( $type->rentalcharge, '0.0000', 'rentalcharge' );
|
||||
is( $type->imageurl, 'imageurl', 'imageurl' );
|
||||
is( $type->summary, 'summary', 'summary' );
|
||||
is( $type->checkinmsg, 'checkinmsg', 'checkinmsg' );
|
||||
is( $type->checkinmsgtype, 'checkinmsgtype', 'checkinmsgtype' );
|
||||
|
||||
$schema->txn_rollback;
|
||||
Loading…
Reference in New Issue