Lines 17-48
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 4; |
20 |
use Test::More tests => 5; |
21 |
|
21 |
|
22 |
use Test::MockModule; |
22 |
use Test::MockModule; |
23 |
use Test::Exception; |
23 |
use Test::Exception; |
|
|
24 |
use Test::Warn; |
25 |
|
26 |
use Koha::Patrons; |
27 |
use Koha::Patron::Allowlist; |
24 |
|
28 |
|
25 |
use t::lib::Mocks; |
29 |
use t::lib::Mocks; |
26 |
|
30 |
|
27 |
use_ok('Koha::Patron::Allowlist::Staff'); |
31 |
use_ok('Koha::Patron::Allowlist::Staff'); |
28 |
use_ok('Koha::Patron::Allowlist::Public'); |
32 |
use_ok('Koha::Patron::Allowlist::Public'); |
29 |
|
33 |
|
|
|
34 |
subtest '_get_all_fields' => sub { |
35 |
my @columns = Koha::Patrons->columns; |
36 |
is_deeply( |
37 |
\@columns, |
38 |
[ Koha::Patron::Allowlist->_get_all_fields ], |
39 |
'All DB columns must be listed in _get_all_fields' |
40 |
); |
41 |
}; |
42 |
|
30 |
subtest 'Staff Allowlist' => sub { |
43 |
subtest 'Staff Allowlist' => sub { |
31 |
plan tests => 3; |
44 |
plan tests => 4; |
32 |
my $input = { firstname => 'test firstname', surname => 'test surname', flags => '1' }; |
45 |
my $input = { firstname => 'test firstname', surname => 'test surname', flags => '1' }; |
33 |
my $allowlist = Koha::Patron::Allowlist::Staff->new(); |
46 |
my $allowlist = Koha::Patron::Allowlist::Staff->new(); |
34 |
$allowlist->apply({ input => $input, }); |
47 |
warning_like { |
35 |
ok( $input->{firstname} eq 'test firstname', 'firstname preserved' ); |
48 |
$allowlist->apply({ input => $input, }); |
36 |
ok( $input->{surname} eq 'test surname', 'surname preserved' ); |
49 |
} qr{Forbidden - Tried to modify 'flags' with '1' from}; |
|
|
50 |
is( $input->{firstname}, 'test firstname', 'firstname preserved' ); |
51 |
is( $input->{surname}, 'test surname', 'surname preserved' ); |
37 |
is( $input->{flags}, undef, 'flags filtered' ); |
52 |
is( $input->{flags}, undef, 'flags filtered' ); |
38 |
}; |
53 |
}; |
39 |
|
54 |
|
40 |
subtest 'Public Allowlist' => sub { |
55 |
subtest 'Public Allowlist' => sub { |
41 |
plan tests => 3; |
56 |
plan tests => 4; |
42 |
my $input = { firstname => 'test firstname', surname => 'test surname', flags => '1' }; |
57 |
my $input = { firstname => 'test firstname', surname => 'test surname', flags => '1' }; |
43 |
my $allowlist = Koha::Patron::Allowlist::Public->new(); |
58 |
my $allowlist = Koha::Patron::Allowlist::Public->new(); |
44 |
$allowlist->apply({ input => $input, }); |
59 |
warning_like { |
45 |
ok( $input->{firstname} eq 'test firstname', 'firstname preserved' ); |
60 |
$allowlist->apply({ input => $input, }); |
46 |
ok( $input->{surname} eq 'test surname', 'surname preserved' ); |
61 |
} qr{Forbidden - Tried to modify 'flags' with '1' from}; |
|
|
62 |
|
63 |
is( $input->{firstname}, 'test firstname', 'firstname preserved' ); |
64 |
is( $input->{surname}, 'test surname', 'surname preserved' ); |
47 |
is( $input->{flags}, undef, 'flags filtered' ); |
65 |
is( $input->{flags}, undef, 'flags filtered' ); |
48 |
}; |
66 |
}; |
49 |
- |
|
|