@@ -, +, @@ --- t/db_dependent/SIP/Patron.t | 29 +++++++++++++++++++++++++++++ t/db_dependent/SIP/Transaction.t | 28 ++++++++++++++++++++++++++++ t/db_dependent/SIP_ILS.t | 27 --------------------------- 3 files changed, 57 insertions(+), 27 deletions(-) create mode 100755 t/db_dependent/SIP/Patron.t create mode 100755 t/db_dependent/SIP/Transaction.t delete mode 100755 t/db_dependent/SIP_ILS.t --- a/t/db_dependent/SIP/Patron.t +++ a/t/db_dependent/SIP/Patron.t @@ -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; --- a/t/db_dependent/SIP/Transaction.t +++ a/t/db_dependent/SIP/Transaction.t @@ -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; --- a/t/db_dependent/SIP_ILS.t +++ a/t/db_dependent/SIP_ILS.t @@ -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"); --