Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 7; |
20 |
use Test::More tests => 9; |
21 |
use t::lib::TestBuilder; |
21 |
use t::lib::TestBuilder; |
22 |
|
22 |
|
23 |
use Koha::Database; |
23 |
use Koha::Database; |
Lines 38-50
foreach (1..10) {
Link Here
|
38 |
push @borrowers, $builder->build({ source => 'Borrower' }); |
38 |
push @borrowers, $builder->build({ source => 'Borrower' }); |
39 |
} |
39 |
} |
40 |
|
40 |
|
41 |
my $owner = $borrowers[0]->{borrowernumber}; |
41 |
my $owner = $borrowers[0]->{borrowernumber}; |
|
|
42 |
my $owner2 = $borrowers[1]->{borrowernumber}; |
42 |
|
43 |
|
43 |
my @lists = GetPatronLists( { owner => $owner } ); |
44 |
my @lists = GetPatronLists( { owner => $owner } ); |
44 |
my $list_count_original = @lists; |
45 |
my $list_count_original = @lists; |
45 |
|
46 |
|
46 |
my $list1 = AddPatronList( { name => 'Test List 1', owner => $owner } ); |
47 |
my $list1 = AddPatronList( { name => 'Test List 1', owner => $owner } ); |
47 |
ok( $list1->name() eq 'Test List 1', 'AddPatronList works' ); |
48 |
is( $list1->name(), 'Test List 1', 'AddPatronList works' ); |
48 |
|
49 |
|
49 |
my $list2 = AddPatronList( { name => 'Test List 2', owner => $owner } ); |
50 |
my $list2 = AddPatronList( { name => 'Test List 2', owner => $owner } ); |
50 |
|
51 |
|
Lines 56-68
ModPatronList(
Link Here
|
56 |
} |
57 |
} |
57 |
); |
58 |
); |
58 |
$list2->discard_changes(); |
59 |
$list2->discard_changes(); |
59 |
ok( $list2->name() eq 'Test List 3', 'ModPatronList works' ); |
60 |
is( $list2->name(), 'Test List 3', 'ModPatronList works' ); |
60 |
|
61 |
|
61 |
AddPatronsToList( |
62 |
AddPatronsToList( |
62 |
{ list => $list1, cardnumbers => [ map { $_->{cardnumber} } @borrowers ] } |
63 |
{ list => $list1, cardnumbers => [ map { $_->{cardnumber} } @borrowers ] } |
63 |
); |
64 |
); |
64 |
ok( |
65 |
is( |
65 |
scalar @borrowers == |
66 |
scalar @borrowers, |
66 |
$list1->patron_list_patrons()->search_related('borrowernumber')->all(), |
67 |
$list1->patron_list_patrons()->search_related('borrowernumber')->all(), |
67 |
'AddPatronsToList works for cardnumbers' |
68 |
'AddPatronsToList works for cardnumbers' |
68 |
); |
69 |
); |
Lines 73-80
AddPatronsToList(
Link Here
|
73 |
borrowernumbers => [ map { $_->{borrowernumber} } @borrowers ] |
74 |
borrowernumbers => [ map { $_->{borrowernumber} } @borrowers ] |
74 |
} |
75 |
} |
75 |
); |
76 |
); |
76 |
ok( |
77 |
is( |
77 |
scalar @borrowers == |
78 |
scalar @borrowers, |
78 |
$list2->patron_list_patrons()->search_related('borrowernumber')->all(), |
79 |
$list2->patron_list_patrons()->search_related('borrowernumber')->all(), |
79 |
'AddPatronsToList works for borrowernumbers' |
80 |
'AddPatronsToList works for borrowernumbers' |
80 |
); |
81 |
); |
Lines 88-104
DelPatronsFromList(
Link Here
|
88 |
} |
89 |
} |
89 |
); |
90 |
); |
90 |
$list1->discard_changes(); |
91 |
$list1->discard_changes(); |
91 |
ok( !$list1->patron_list_patrons()->count(), 'DelPatronsFromList works.' ); |
92 |
is( $list1->patron_list_patrons()->count(), 0, 'DelPatronsFromList works.' ); |
92 |
|
93 |
|
93 |
@lists = GetPatronLists( { owner => $owner } ); |
94 |
@lists = GetPatronLists( { owner => $owner } ); |
94 |
ok( @lists == $list_count_original + 2, 'GetPatronLists works' ); |
95 |
is( scalar @lists, $list_count_original + 2, 'GetPatronLists works' ); |
|
|
96 |
|
97 |
my $list3 = AddPatronList( { name => 'Test List 3', owner => $owner2, shared => 0 } ); |
98 |
@lists = GetPatronLists( { owner => $owner } ); |
99 |
is( scalar @lists, $list_count_original + 2, 'GetPatronLists does not return non-shared list' ); |
100 |
|
101 |
my $list4 = AddPatronList( { name => 'Test List 4', owner => $owner2, shared => 1 } ); |
102 |
@lists = GetPatronLists( { owner => $owner } ); |
103 |
is( scalar @lists, $list_count_original + 3, 'GetPatronLists does return shared list' ); |
95 |
|
104 |
|
96 |
DelPatronList( { patron_list_id => $list1->patron_list_id(), owner => $owner } ); |
105 |
DelPatronList( { patron_list_id => $list1->patron_list_id(), owner => $owner } ); |
97 |
DelPatronList( { patron_list_id => $list2->patron_list_id(), owner => $owner } ); |
106 |
DelPatronList( { patron_list_id => $list2->patron_list_id(), owner => $owner } ); |
98 |
|
107 |
|
99 |
@lists = |
108 |
@lists = |
100 |
GetPatronLists( { patron_list_id => $list1->patron_list_id(), owner => $owner } ); |
109 |
GetPatronLists( { patron_list_id => $list1->patron_list_id(), owner => $owner } ); |
101 |
ok( !@lists, 'DelPatronList works' ); |
110 |
is( scalar @lists, 0, 'DelPatronList works' ); |
102 |
|
111 |
|
103 |
$schema->storage->txn_rollback; |
112 |
$schema->storage->txn_rollback; |
104 |
|
113 |
|
105 |
- |
|
|