View | Details | Raw Unified | Return to bug 15956
Collapse All | Expand All

(-)a/t/db_dependent/SIP/Patron.t (+29 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Some tests for SIP::ILS::Patron
4
# This needs to be extended! Your help is appreciated..
5
6
use Modern::Perl;
7
use Test::More tests => 2;
8
9
use Koha::Database;
10
use t::lib::TestBuilder;
11
use C4::SIP::ILS::Patron;
12
13
my $schema = Koha::Database->new->schema;
14
$schema->storage->txn_begin;
15
16
my $builder = t::lib::TestBuilder->new();
17
my $patron1 = $builder->build({ source => 'Borrower' });
18
my $card = $patron1->{cardnumber};
19
20
# Check existing card number
21
my $sip_patron = C4::SIP::ILS::Patron->new( $card );
22
is( defined $sip_patron, 1, "Patron is valid" );
23
24
# Check invalid cardnumber by deleting patron
25
$schema->resultset('Borrower')->search({ cardnumber => $card })->delete;
26
my $sip_patron2 = C4::SIP::ILS::Patron->new( $card );
27
is( $sip_patron2, undef, "Patron is not valid (anymore)" );
28
29
$schema->storage->txn_rollback;
(-)a/t/db_dependent/SIP/Transaction.t (+28 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Tests for SIP::ILS::Transaction
4
# Current state is very rudimentary. Please help to extend it!
5
6
use Modern::Perl;
7
use Test::More tests => 3;
8
9
use Koha::Database;
10
use t::lib::TestBuilder;
11
use C4::SIP::ILS::Patron;
12
use C4::SIP::ILS::Transaction::RenewAll;
13
14
my $schema = Koha::Database->new->schema;
15
$schema->storage->txn_begin;
16
17
my $builder = t::lib::TestBuilder->new();
18
my $borr1 = $builder->build({ source => 'Borrower' });
19
my $card = $borr1->{cardnumber};
20
my $sip_patron = C4::SIP::ILS::Patron->new( $card );
21
22
# Create transaction RenewAll, assign patron, and run (no items)
23
my $transaction = C4::SIP::ILS::Transaction::RenewAll->new();
24
is( ref $transaction, "C4::SIP::ILS::Transaction::RenewAll", "New transaction created" );
25
is( $transaction->patron( $sip_patron ), $sip_patron, "Patron assigned to transaction" );
26
isnt( $transaction->do_renew_all, undef, "RenewAll on zero items" );
27
28
$schema->storage->txn_rollback;
(-)a/t/db_dependent/SIP_ILS.t (-28 lines)
Lines 1-27 Link Here
1
#!/usr/bin/perl
2
#
3
# This Koha test module is a stub!
4
# Add more tests here!!!
5
6
use strict;
7
use warnings;
8
9
use Test::More tests => 4;
10
11
BEGIN {
12
        use_ok('C4::SIP::ILS');
13
};
14
15
my $transaction = C4::SIP::ILS::Transaction::RenewAll->new();
16
17
$transaction->patron(my $patron = C4::SIP::ILS::Patron->new(23529000120056));
18
19
ok(defined $patron, "patron code: 23529000120056 is valid");
20
21
my $transaction2 = C4::SIP::ILS::Transaction::RenewAll->new();
22
$transaction2->patron(my $patron2 = C4::SIP::ILS::Patron->new("ABCDE12345"));
23
24
#This test assumes that the patron code ABCDE12345 is invalid
25
ok(!defined $patron2, "patron code: ABCDE12345 is invalid");
26
27
ok($transaction->do_renew_all(), "items renewed correctly");
28
- 

Return to bug 15956