|
Lines 808-814
subtest 'is_superlibrarian() tests' => sub {
Link Here
|
| 808 |
|
808 |
|
| 809 |
subtest 'permissions() tests' => sub { |
809 |
subtest 'permissions() tests' => sub { |
| 810 |
|
810 |
|
| 811 |
plan tests => 8; |
811 |
plan tests => 12; |
| 812 |
|
812 |
|
| 813 |
$schema->storage->txn_begin; |
813 |
$schema->storage->txn_begin; |
| 814 |
|
814 |
|
|
Lines 824-832
subtest 'permissions() tests' => sub {
Link Here
|
| 824 |
|
824 |
|
| 825 |
my $permissions = $patron->permissions; |
825 |
my $permissions = $patron->permissions; |
| 826 |
|
826 |
|
| 827 |
is( ref($permissions), 'HASH', "permissions() returns a hashref" ); |
827 |
is( ref($permissions), 'HASH', "permissions() returns a hashref" ); |
| 828 |
is( scalar keys %$permissions, 1, "Patron has one module permission" ); |
828 |
ok( scalar keys %$permissions > 0, "permissions() returns all flags, not just granted ones" ); |
| 829 |
is( $permissions->{catalogue}, 1, "Patron has catalogue permission" ); |
829 |
is( $permissions->{catalogue}, 1, "Patron has catalogue permission" ); |
|
|
830 |
is( $permissions->{superlibrarian}, 0, "Patron does not have superlibrarian (demonstrates all flags present)" ); |
| 830 |
|
831 |
|
| 831 |
# Test patron with no permissions |
832 |
# Test patron with no permissions |
| 832 |
my $patron_no_perms = $builder->build_object( |
833 |
my $patron_no_perms = $builder->build_object( |
|
Lines 836-842
subtest 'permissions() tests' => sub {
Link Here
|
| 836 |
} |
837 |
} |
| 837 |
); |
838 |
); |
| 838 |
my $no_perms = $patron_no_perms->permissions; |
839 |
my $no_perms = $patron_no_perms->permissions; |
| 839 |
is( scalar keys %$no_perms, 0, "Patron with no flags has no permissions" ); |
840 |
ok( scalar keys %$no_perms > 0, "Patron with no flags still has hashref with all flags" ); |
|
|
841 |
is( $no_perms->{catalogue}, 0, "Patron does not have catalogue permission" ); |
| 842 |
is( $no_perms->{superlibrarian}, 0, "Patron does not have superlibrarian permission" ); |
| 840 |
|
843 |
|
| 841 |
# Test patron with multiple flags (catalogue=4 + circulate=2 = 6) |
844 |
# Test patron with multiple flags (catalogue=4 + circulate=2 = 6) |
| 842 |
my $patron_multi = $builder->build_object( |
845 |
my $patron_multi = $builder->build_object( |
|
Lines 846-853
subtest 'permissions() tests' => sub {
Link Here
|
| 846 |
} |
849 |
} |
| 847 |
); |
850 |
); |
| 848 |
my $multi_perms = $patron_multi->permissions; |
851 |
my $multi_perms = $patron_multi->permissions; |
| 849 |
is( $multi_perms->{catalogue}, 1, "Multi-flag patron has catalogue permission" ); |
852 |
is( $multi_perms->{catalogue}, 1, "Multi-flag patron has catalogue permission" ); |
| 850 |
is( $multi_perms->{circulate}, 1, "Multi-flag patron has circulate permission" ); |
853 |
is( $multi_perms->{circulate}, 1, "Multi-flag patron has circulate permission" ); |
|
|
854 |
is( $multi_perms->{superlibrarian}, 0, "Multi-flag patron does not have superlibrarian" ); |
| 851 |
|
855 |
|
| 852 |
# Test patron with granular subpermissions |
856 |
# Test patron with granular subpermissions |
| 853 |
my $patron_subperm = $builder->build_object( { class => 'Koha::Patrons', value => { flags => 0 } } ); |
857 |
my $patron_subperm = $builder->build_object( { class => 'Koha::Patrons', value => { flags => 0 } } ); |
| 854 |
- |
|
|