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

(-)a/t/db_dependent/PatronLists.t (-10 / +34 lines)
Lines 1-21 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
2
#
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
3
use Modern::Perl;
18
use Modern::Perl;
4
19
5
use Test::More tests => 9;
20
use Test::More tests => 7;
21
use t::lib::TestBuilder;
6
22
7
BEGIN {
23
use Koha::Database;
8
    use_ok('C4::Context');
24
use Koha::List::Patron
9
    use_ok('Koha::List::Patron');
25
    qw( AddPatronList AddPatronsToList DelPatronList DelPatronsFromList GetPatronLists ModPatronList );
10
}
26
27
my $schema = Koha::Database->schema;
28
$schema->storage->txn_begin;
29
30
my $builder = t::lib::TestBuilder->new;
11
31
12
C4::Context->_new_userenv('DUMMY SESSION');
32
C4::Context->_new_userenv('DUMMY SESSION');
13
C4::Context->set_userenv(0,0,0,'firstname','surname', 'BRANCH1', 'Library 1', 0, ', ');
33
C4::Context->set_userenv(0,0,0,'firstname','surname', 'BRANCH1', 'Library 1', 0, ', ');
14
34
15
my $dbh = C4::Context->dbh;
35
# Create 10 sample borrowers
16
my $sth = $dbh->prepare("SELECT * FROM borrowers ORDER BY RAND() LIMIT 10");
36
my @borrowers = ();
17
$sth->execute();
37
foreach (1..10) {
18
my @borrowers = @{ $sth->fetchall_arrayref( {} ) };
38
    push @borrowers, $builder->build({ source => 'Borrower' });
39
}
19
40
20
my $owner = $borrowers[0]->{borrowernumber};
41
my $owner = $borrowers[0]->{borrowernumber};
21
42
Lines 78-80 DelPatronList( { patron_list_id => $list2->patron_list_id(), owner => $owner } ) Link Here
78
@lists =
99
@lists =
79
  GetPatronLists( { patron_list_id => $list1->patron_list_id(), owner => $owner } );
100
  GetPatronLists( { patron_list_id => $list1->patron_list_id(), owner => $owner } );
80
ok( !@lists, 'DelPatronList works' );
101
ok( !@lists, 'DelPatronList works' );
81
- 
102
103
$schema->storage->txn_rollback;
104
105
1;

Return to bug 17722