Bug 15956: Rearranging some SIP unit tests
The original SIP_ILS.t is split up into SIP/Patron.t and SIP/Transaction.t. The assumption on a hardcoded existing and non-existing card number is replaced by adding and deleting a card number (:patron) with TestBuilder. Test plan: Run SIP/Patron.t Run SIP/Transaction.t Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
parent
a6da1c024c
commit
7ce9008a00
|
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
# Some tests for SIP::ILS::Patron
|
||||
# This needs to be extended! Your help is appreciated..
|
||||
|
||||
use Modern::Perl;
|
||||
use Test::More tests => 2;
|
||||
|
||||
use Koha::Database;
|
||||
use t::lib::TestBuilder;
|
||||
use C4::SIP::ILS::Patron;
|
||||
|
||||
my $schema = Koha::Database->new->schema;
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
my $builder = t::lib::TestBuilder->new();
|
||||
my $patron1 = $builder->build({ source => 'Borrower' });
|
||||
my $card = $patron1->{cardnumber};
|
||||
|
||||
# Check existing card number
|
||||
my $sip_patron = C4::SIP::ILS::Patron->new( $card );
|
||||
is( defined $sip_patron, 1, "Patron is valid" );
|
||||
|
||||
# Check invalid cardnumber by deleting patron
|
||||
$schema->resultset('Borrower')->search({ cardnumber => $card })->delete;
|
||||
my $sip_patron2 = C4::SIP::ILS::Patron->new( $card );
|
||||
is( $sip_patron2, undef, "Patron is not valid (anymore)" );
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
# Tests for SIP::ILS::Transaction
|
||||
# Current state is very rudimentary. Please help to extend it!
|
||||
|
||||
use Modern::Perl;
|
||||
use Test::More tests => 3;
|
||||
|
||||
use Koha::Database;
|
||||
use t::lib::TestBuilder;
|
||||
use C4::SIP::ILS::Patron;
|
||||
use C4::SIP::ILS::Transaction::RenewAll;
|
||||
|
||||
my $schema = Koha::Database->new->schema;
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
my $builder = t::lib::TestBuilder->new();
|
||||
my $borr1 = $builder->build({ source => 'Borrower' });
|
||||
my $card = $borr1->{cardnumber};
|
||||
my $sip_patron = C4::SIP::ILS::Patron->new( $card );
|
||||
|
||||
# Create transaction RenewAll, assign patron, and run (no items)
|
||||
my $transaction = C4::SIP::ILS::Transaction::RenewAll->new();
|
||||
is( ref $transaction, "C4::SIP::ILS::Transaction::RenewAll", "New transaction created" );
|
||||
is( $transaction->patron( $sip_patron ), $sip_patron, "Patron assigned to transaction" );
|
||||
isnt( $transaction->do_renew_all, undef, "RenewAll on zero items" );
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
# This Koha test module is a stub!
|
||||
# Add more tests here!!!
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Test::More tests => 4;
|
||||
|
||||
BEGIN {
|
||||
use_ok('C4::SIP::ILS');
|
||||
};
|
||||
|
||||
my $transaction = C4::SIP::ILS::Transaction::RenewAll->new();
|
||||
|
||||
$transaction->patron(my $patron = C4::SIP::ILS::Patron->new(23529000120056));
|
||||
|
||||
ok(defined $patron, "patron code: 23529000120056 is valid");
|
||||
|
||||
my $transaction2 = C4::SIP::ILS::Transaction::RenewAll->new();
|
||||
$transaction2->patron(my $patron2 = C4::SIP::ILS::Patron->new("ABCDE12345"));
|
||||
|
||||
#This test assumes that the patron code ABCDE12345 is invalid
|
||||
ok(!defined $patron2, "patron code: ABCDE12345 is invalid");
|
||||
|
||||
ok($transaction->do_renew_all(), "items renewed correctly");
|
||||
Loading…
Reference in New Issue