|
Lines 2886-2892
subtest 'store() tests' => sub {
Link Here
|
| 2886 |
{ |
2886 |
{ |
| 2887 |
borrowernumber => $patron->id, |
2887 |
borrowernumber => $patron->id, |
| 2888 |
date => '1970-01-01 14:00:01', |
2888 |
date => '1970-01-01 14:00:01', |
| 2889 |
amountoutstanding => 0, |
2889 |
amountoutstanding => 0, |
| 2890 |
amount => -5, |
2890 |
amount => -5, |
| 2891 |
interface => 'commandline', |
2891 |
interface => 'commandline', |
| 2892 |
credit_type_code => 'PAYMENT' |
2892 |
credit_type_code => 'PAYMENT' |
|
Lines 3869-3875
subtest 'effective_not_for_loan_status() tests' => sub {
Link Here
|
| 3869 |
|
3869 |
|
| 3870 |
subtest 'effective_bookable() tests' => sub { |
3870 |
subtest 'effective_bookable() tests' => sub { |
| 3871 |
|
3871 |
|
| 3872 |
plan tests => 5; |
3872 |
plan tests => 9; |
| 3873 |
|
3873 |
|
| 3874 |
$schema->storage->txn_begin; |
3874 |
$schema->storage->txn_begin; |
| 3875 |
|
3875 |
|
|
Lines 3920-3925
subtest 'effective_bookable() tests' => sub {
Link Here
|
| 3920 |
'->effective_bookable returns item specific bookable value when item bookable is defined' |
3920 |
'->effective_bookable returns item specific bookable value when item bookable is defined' |
| 3921 |
); |
3921 |
); |
| 3922 |
|
3922 |
|
|
|
3923 |
note("Parent itemtype fallback tests"); |
| 3924 |
|
| 3925 |
my $parent_itype = $builder->build_object( { class => 'Koha::ItemTypes', value => { bookable => 1 } } ); |
| 3926 |
my $child_itype = $builder->build_object( |
| 3927 |
{ class => 'Koha::ItemTypes', value => { bookable => 0, parent_type => $parent_itype->itemtype } } ); |
| 3928 |
|
| 3929 |
my $child_item = $builder->build_sample_item( |
| 3930 |
{ biblionumber => $biblio->biblionumber, itype => $child_itype->itemtype, bookable => undef } ); |
| 3931 |
|
| 3932 |
is( |
| 3933 |
$child_item->effective_bookable, $parent_itype->bookable, |
| 3934 |
'->effective_bookable falls back to parent itemtype when child is not bookable' |
| 3935 |
); |
| 3936 |
|
| 3937 |
$child_itype->bookable(1)->store(); |
| 3938 |
$child_itype->discard_changes; |
| 3939 |
is( |
| 3940 |
$child_item->effective_bookable, 1, |
| 3941 |
'->effective_bookable uses child itemtype bookable when set' |
| 3942 |
); |
| 3943 |
|
| 3944 |
$child_itype->bookable(0)->store(); |
| 3945 |
$child_itype->discard_changes; |
| 3946 |
$child_item->bookable(1)->store(); |
| 3947 |
$child_item->discard_changes; |
| 3948 |
is( |
| 3949 |
$child_item->effective_bookable, 1, |
| 3950 |
'->effective_bookable uses item-level bookable over parent fallback' |
| 3951 |
); |
| 3952 |
|
| 3953 |
my $orphan_itype = |
| 3954 |
$builder->build_object( { class => 'Koha::ItemTypes', value => { bookable => 0, parent_type => undef } } ); |
| 3955 |
my $orphan_item = $builder->build_sample_item( |
| 3956 |
{ biblionumber => $biblio->biblionumber, itype => $orphan_itype->itemtype, bookable => undef } ); |
| 3957 |
is( |
| 3958 |
$orphan_item->effective_bookable, 0, |
| 3959 |
'->effective_bookable returns 0 for orphan itemtype with no parent' |
| 3960 |
); |
| 3961 |
|
| 3923 |
$schema->storage->txn_rollback; |
3962 |
$schema->storage->txn_rollback; |
| 3924 |
}; |
3963 |
}; |
| 3925 |
|
3964 |
|
| 3926 |
- |
|
|