Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 11; |
22 |
use Test::More tests => 12; |
23 |
|
23 |
|
24 |
use Test::Exception; |
24 |
use Test::Exception; |
25 |
use Test::MockModule; |
25 |
use Test::MockModule; |
Lines 955-957
subtest 'Koha::Hold::item_group tests' => sub {
Link Here
|
955 |
|
955 |
|
956 |
$schema->storage->txn_rollback; |
956 |
$schema->storage->txn_rollback; |
957 |
}; |
957 |
}; |
958 |
- |
958 |
|
|
|
959 |
subtest 'change_type tests' => sub { |
960 |
|
961 |
plan tests => 9; |
962 |
|
963 |
$schema->storage->txn_begin; |
964 |
|
965 |
my $item = $builder->build_object( { class => 'Koha::Items', } ); |
966 |
my $hold = $builder->build_object( { |
967 |
class => 'Koha::Holds', |
968 |
value => { |
969 |
itemnumber => undef, |
970 |
} |
971 |
} ); |
972 |
|
973 |
my $hold2 = $builder->build_object( { |
974 |
class => 'Koha::Holds', |
975 |
value => { |
976 |
borrowernumber => $hold->borrowernumber, |
977 |
} |
978 |
} ); |
979 |
|
980 |
ok( $hold->change_type ); |
981 |
|
982 |
$hold->discard_changes; |
983 |
|
984 |
is( $hold->itemnumber, undef, 'record hold to record hold, no changes'); |
985 |
|
986 |
ok( $hold->change_type( $item->itemnumber ) ); |
987 |
|
988 |
$hold->discard_changes; |
989 |
|
990 |
is( $hold->itemnumber, $item->itemnumber, 'record hold to item hold'); |
991 |
|
992 |
ok( $hold->change_type( $item->itemnumber ) ); |
993 |
|
994 |
$hold->discard_changes; |
995 |
|
996 |
is( $hold->itemnumber, $item->itemnumber, 'item hold to item hold, no changes'); |
997 |
|
998 |
ok( $hold->change_type ); |
999 |
|
1000 |
$hold->discard_changes; |
1001 |
|
1002 |
is( $hold->itemnumber, undef, 'item hold to record hold'); |
1003 |
|
1004 |
my $hold3 = $builder->build_object( { |
1005 |
class => 'Koha::Holds', |
1006 |
value => { |
1007 |
biblionumber => $hold->biblionumber, |
1008 |
borrowernumber => $hold->borrowernumber, |
1009 |
} |
1010 |
} ); |
1011 |
|
1012 |
throws_ok { $hold->change_type } |
1013 |
'Koha::Exceptions::Hold::CannotChangeHoldType', |
1014 |
'Exception thrown because more than one hold per record'; |
1015 |
|
1016 |
$schema->storage->txn_rollback; |
1017 |
}; |