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