Bugzilla – Attachment 33141 Details for
Bug 12478
Elasticsearch support for Koha
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12478 - add test cases
Bug-12478---add-test-cases.patch (text/plain), 5.54 KB, created by
Robin Sheat
on 2014-11-03 04:06:04 UTC
(
hide
)
Description:
Bug 12478 - add test cases
Filename:
MIME Type:
Creator:
Robin Sheat
Created:
2014-11-03 04:06:04 UTC
Size:
5.54 KB
patch
obsolete
>From a0f3b881800e25acb1cc30f27f1b4ab1b6f44a40 Mon Sep 17 00:00:00 2001 >From: Robin Sheat <robin@catalyst.net.nz> >Date: Tue, 23 Sep 2014 17:32:57 +1200 >Subject: [PATCH] Bug 12478 - add test cases > >--- > t/db_dependent/Koha/Biblio.t | 54 +++++++++++++++++++++ > t/db_dependent/Koha/{ItemTypes.pm => ItemTypes.t} | 57 ++++++++++++++--------- > 2 files changed, 90 insertions(+), 21 deletions(-) > create mode 100755 t/db_dependent/Koha/Biblio.t > rename t/db_dependent/Koha/{ItemTypes.pm => ItemTypes.t} (55%) > >diff --git a/t/db_dependent/Koha/Biblio.t b/t/db_dependent/Koha/Biblio.t >new file mode 100755 >index 0000000..4596015 >--- /dev/null >+++ b/t/db_dependent/Koha/Biblio.t >@@ -0,0 +1,54 @@ >+#!/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 => 17; >+use Data::Dumper; >+use Koha::Database; >+ >+BEGIN { >+ use_ok('Koha::Biblio'); >+} >+ >+my $database = Koha::Database->new(); >+my $schema = $database->schema(); >+$schema->txn_begin; >+ >+# Make a MARC::Record >+ >+# Make a Koha::Biblio from it >+ >+# Verify that the fields saved correctly >+ >+# Delete all biblios currently in the DB (for testing) >+ >+# Save our biblio to the database (will need to implement this) >+ >+# Fetch it >+ >+# Verify that the fields are correct >+ >+# Get an iterator >+ >+# Verify that the biblio it returns is correct >+ >+my $biblios = Koha::ItemTypes->new(); >+ >+$schema->txn_rollback; >diff --git a/t/db_dependent/Koha/ItemTypes.pm b/t/db_dependent/Koha/ItemTypes.t >similarity index 55% >rename from t/db_dependent/Koha/ItemTypes.pm >rename to t/db_dependent/Koha/ItemTypes.t >index dfefd08..b6e61bc 100755 >--- a/t/db_dependent/Koha/ItemTypes.pm >+++ b/t/db_dependent/Koha/ItemTypes.t >@@ -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; >-- >1.9.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 12478
:
29204
|
31128
|
31129
|
33136
|
33137
|
33138
|
33139
|
33140
|
33141
|
35654
|
40903
|
42030
|
42031
|
42032
|
42033
|
42062
|
42063
|
42064
|
42065
|
42066
|
42067
|
42068
|
42069
|
42392
|
42393
|
43127
|
43128
|
43129
|
43130
|
43131
|
43132
|
43133
|
43134
|
43140
|
43141
|
43142
|
43148
|
43345
|
43346
|
43347
|
43348
|
43349
|
43350
|
43351
|
43352
|
43373
|
47767
|
47768
|
50115
|
50159
|
50211
|
50212
|
50213
|
50214
|
50245
|
50246
|
50291
|
50292