|
Lines 19-25
Link Here
|
| 19 |
|
19 |
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 9; |
22 |
use Test::More tests => 10; |
| 23 |
|
23 |
|
| 24 |
use Test::Exception; |
24 |
use Test::Exception; |
| 25 |
use Test::MockModule; |
25 |
use Test::MockModule; |
|
Lines 863-865
subtest 'cancellation_requestable_from_opac() tests' => sub {
Link Here
|
| 863 |
|
863 |
|
| 864 |
$schema->storage->txn_rollback; |
864 |
$schema->storage->txn_rollback; |
| 865 |
}; |
865 |
}; |
| 866 |
- |
866 |
|
|
|
867 |
subtest 'change_type tests' => sub { |
| 868 |
|
| 869 |
plan tests => 9; |
| 870 |
|
| 871 |
$schema->storage->txn_begin; |
| 872 |
|
| 873 |
my $item = $builder->build_object( { class => 'Koha::Items', } ); |
| 874 |
my $hold = $builder->build_object( { |
| 875 |
class => 'Koha::Holds', |
| 876 |
value => { |
| 877 |
itemnumber => undef, |
| 878 |
} |
| 879 |
} ); |
| 880 |
|
| 881 |
my $hold2 = $builder->build_object( { |
| 882 |
class => 'Koha::Holds', |
| 883 |
value => { |
| 884 |
borrowernumber => $hold->borrowernumber, |
| 885 |
} |
| 886 |
} ); |
| 887 |
|
| 888 |
ok( $hold->change_type ); |
| 889 |
|
| 890 |
$hold->discard_changes; |
| 891 |
|
| 892 |
is( $hold->itemnumber, undef, 'record hold to record hold, no changes'); |
| 893 |
|
| 894 |
ok( $hold->change_type( $item->itemnumber ) ); |
| 895 |
|
| 896 |
$hold->discard_changes; |
| 897 |
|
| 898 |
is( $hold->itemnumber, $item->itemnumber, 'record hold to item hold'); |
| 899 |
|
| 900 |
ok( $hold->change_type( $item->itemnumber ) ); |
| 901 |
|
| 902 |
$hold->discard_changes; |
| 903 |
|
| 904 |
is( $hold->itemnumber, $item->itemnumber, 'item hold to item hold, no changes'); |
| 905 |
|
| 906 |
ok( $hold->change_type ); |
| 907 |
|
| 908 |
$hold->discard_changes; |
| 909 |
|
| 910 |
is( $hold->itemnumber, undef, 'item hold to record hold'); |
| 911 |
|
| 912 |
my $hold3 = $builder->build_object( { |
| 913 |
class => 'Koha::Holds', |
| 914 |
value => { |
| 915 |
biblionumber => $hold->biblionumber, |
| 916 |
borrowernumber => $hold->borrowernumber, |
| 917 |
} |
| 918 |
} ); |
| 919 |
|
| 920 |
throws_ok { $hold->change_type } |
| 921 |
'Koha::Exceptions::Hold::CannotChangeHoldType', |
| 922 |
'Exception thrown because more than one hold per record'; |
| 923 |
|
| 924 |
$schema->storage->txn_rollback; |
| 925 |
}; |