|
Lines 19-25
Link Here
|
| 19 |
|
19 |
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 3; |
22 |
use Test::More tests => 4; |
| 23 |
use t::lib::TestBuilder; |
23 |
use t::lib::TestBuilder; |
| 24 |
|
24 |
|
| 25 |
use Koha::Database; |
25 |
use Koha::Database; |
|
Lines 136-138
subtest 'renewals() tests' => sub {
Link Here
|
| 136 |
|
136 |
|
| 137 |
$schema->storage->txn_rollback; |
137 |
$schema->storage->txn_rollback; |
| 138 |
}; |
138 |
}; |
| 139 |
- |
139 |
|
|
|
140 |
subtest 'public_read_list() tests' => sub { |
| 141 |
|
| 142 |
$schema->storage->txn_begin; |
| 143 |
|
| 144 |
my @all_attrs = Koha::Checkouts->columns(); |
| 145 |
my $public_attrs = |
| 146 |
{ map { $_ => 1 } @{ Koha::Checkout->public_read_list() } }; |
| 147 |
my $mapping = Koha::Checkout->to_api_mapping; |
| 148 |
|
| 149 |
plan tests => scalar @all_attrs * 2; |
| 150 |
|
| 151 |
# Create a sample checkout |
| 152 |
my $checkout = $builder->build_object( { class => 'Koha::Checkouts' } ); |
| 153 |
|
| 154 |
my $unprivileged_representation = $checkout->to_api( { public => 1 } ); |
| 155 |
my $privileged_representation = $checkout->to_api; |
| 156 |
|
| 157 |
foreach my $attr (@all_attrs) { |
| 158 |
my $mapped = exists $mapping->{$attr} ? $mapping->{$attr} : $attr; |
| 159 |
if ( defined($mapped) ) { |
| 160 |
ok( |
| 161 |
exists $privileged_representation->{$mapped}, |
| 162 |
"Attribute '$attr' is present when privileged" |
| 163 |
); |
| 164 |
if ( exists $public_attrs->{$attr} ) { |
| 165 |
ok( |
| 166 |
exists $unprivileged_representation->{$mapped}, |
| 167 |
"Attribute '$attr' is present when public" |
| 168 |
); |
| 169 |
} else { |
| 170 |
ok( |
| 171 |
!exists $unprivileged_representation->{$mapped}, |
| 172 |
"Attribute '$attr' is not present when public" |
| 173 |
); |
| 174 |
} |
| 175 |
} else { |
| 176 |
ok( |
| 177 |
!exists $privileged_representation->{$attr}, |
| 178 |
"Unmapped attribute '$attr' is not present when privileged" |
| 179 |
); |
| 180 |
ok( |
| 181 |
!exists $unprivileged_representation->{$attr}, |
| 182 |
"Unmapped attribute '$attr' is not present when public" |
| 183 |
); |
| 184 |
} |
| 185 |
} |
| 186 |
|
| 187 |
$schema->storage->txn_rollback; |
| 188 |
}; |