|
Lines 20-26
Link Here
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::NoWarnings; |
22 |
use Test::NoWarnings; |
| 23 |
use Test::More tests => 6; |
23 |
use Test::More tests => 7; |
| 24 |
use Test::MockModule; |
24 |
use Test::MockModule; |
| 25 |
|
25 |
|
| 26 |
use Koha::ILL::Requests; |
26 |
use Koha::ILL::Requests; |
|
Lines 197-199
subtest 'get_backend_plugin() tests' => sub {
Link Here
|
| 197 |
|
197 |
|
| 198 |
$schema->storage->txn_rollback; |
198 |
$schema->storage->txn_rollback; |
| 199 |
}; |
199 |
}; |
| 200 |
- |
200 |
|
|
|
201 |
subtest 'copyright clearance methods tests' => sub { |
| 202 |
|
| 203 |
plan tests => 8; |
| 204 |
|
| 205 |
$schema->storage->txn_begin; |
| 206 |
|
| 207 |
# Test set_copyright_clearance_confirmed with truthy value |
| 208 |
my $request = $builder->build_object( { class => 'Koha::ILL::Requests' } ); |
| 209 |
|
| 210 |
$request->set_copyright_clearance_confirmed(1); |
| 211 |
|
| 212 |
my $attr = $request->extended_attributes->find( { type => 'copyrightclearance_confirmed' } ); |
| 213 |
ok( $attr, 'Copyright clearance attribute created' ); |
| 214 |
is( $attr->value, 1, 'Copyright clearance value set to 1' ); |
| 215 |
|
| 216 |
# Test setting to false creates attribute with value 0 |
| 217 |
my $request2 = $builder->build_object( { class => 'Koha::ILL::Requests' } ); |
| 218 |
$request2->set_copyright_clearance_confirmed(0); |
| 219 |
|
| 220 |
my $attr2 = $request2->extended_attributes->find( { type => 'copyrightclearance_confirmed' } ); |
| 221 |
ok( $attr2, 'Attribute created for false value' ); |
| 222 |
is( $attr2->value, 0, 'False value normalized to 0' ); |
| 223 |
|
| 224 |
# Test setting to false when already true updates the value |
| 225 |
$request->set_copyright_clearance_confirmed(0); |
| 226 |
my $attr_after_false = $request->extended_attributes->find( { type => 'copyrightclearance_confirmed' } ); |
| 227 |
ok( $attr_after_false, 'Attribute still exists after setting to false' ); |
| 228 |
is( $attr_after_false->value, 0, 'Attribute value updated to 0 when set to false' ); |
| 229 |
|
| 230 |
# Test get_copyright_clearance_confirmed returns boolean values |
| 231 |
is( $request->get_copyright_clearance_confirmed, 0, 'Returns 0 when set to false' ); |
| 232 |
is( $request2->get_copyright_clearance_confirmed, 0, 'Returns 0 when set to false value' ); |
| 233 |
|
| 234 |
$schema->storage->txn_rollback; |
| 235 |
}; |