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