Lines 77-79
subtest 'renewals() tests' => sub {
Link Here
|
77 |
|
77 |
|
78 |
$schema->storage->txn_rollback; |
78 |
$schema->storage->txn_rollback; |
79 |
}; |
79 |
}; |
80 |
- |
80 |
|
|
|
81 |
subtest 'public_read_list() tests' => sub { |
82 |
|
83 |
$schema->storage->txn_begin; |
84 |
|
85 |
my @all_attrs = Koha::Checkouts->columns(); |
86 |
my $public_attrs = |
87 |
{ map { $_ => 1 } @{ Koha::Checkout->public_read_list() } }; |
88 |
my $mapping = Koha::Checkout->to_api_mapping; |
89 |
|
90 |
plan tests => scalar @all_attrs * 2; |
91 |
|
92 |
# Create a sample checkout |
93 |
my $checkout = $builder->build_object( { class => 'Koha::Checkouts' } ); |
94 |
|
95 |
my $unprivileged_representation = $checkout->to_api( { public => 1 } ); |
96 |
my $privileged_representation = $checkout->to_api; |
97 |
|
98 |
foreach my $attr (@all_attrs) { |
99 |
my $mapped = exists $mapping->{$attr} ? $mapping->{$attr} : $attr; |
100 |
if ( defined($mapped) ) { |
101 |
ok( |
102 |
exists $privileged_representation->{$mapped}, |
103 |
"Attribute '$attr' is present when privileged" |
104 |
); |
105 |
if ( exists $public_attrs->{$attr} ) { |
106 |
ok( |
107 |
exists $unprivileged_representation->{$mapped}, |
108 |
"Attribute '$attr' is present when public" |
109 |
); |
110 |
} else { |
111 |
ok( |
112 |
!exists $unprivileged_representation->{$mapped}, |
113 |
"Attribute '$attr' is not present when public" |
114 |
); |
115 |
} |
116 |
} else { |
117 |
ok( |
118 |
!exists $privileged_representation->{$attr}, |
119 |
"Unmapped attribute '$attr' is not present when privileged" |
120 |
); |
121 |
ok( |
122 |
!exists $unprivileged_representation->{$attr}, |
123 |
"Unmapped attribute '$attr' is not present when public" |
124 |
); |
125 |
} |
126 |
} |
127 |
|
128 |
$schema->storage->txn_rollback; |
129 |
}; |