|
Lines 30-36
my $builder = t::lib::TestBuilder->new;
Link Here
|
| 30 |
|
30 |
|
| 31 |
subtest "store() tests" => sub { |
31 |
subtest "store() tests" => sub { |
| 32 |
|
32 |
|
| 33 |
plan tests => 11; |
33 |
plan tests => 13; |
| 34 |
|
34 |
|
| 35 |
$schema->storage->txn_begin; |
35 |
$schema->storage->txn_begin; |
| 36 |
|
36 |
|
|
Lines 59-81
subtest "store() tests" => sub {
Link Here
|
| 59 |
} |
59 |
} |
| 60 |
)->store } |
60 |
)->store } |
| 61 |
'Koha::Exceptions::Checkouts::ReturnClaims::NoCreatedBy', |
61 |
'Koha::Exceptions::Checkouts::ReturnClaims::NoCreatedBy', |
| 62 |
'Exception thrown correctly'; |
62 |
'Exception thrown if no created_by passed on creation'; |
| 63 |
|
63 |
|
| 64 |
my $nullified_created_by = $builder->build_object( |
64 |
my $old_checkout = $builder->build_object( |
| 65 |
{ |
65 |
{ |
| 66 |
class => 'Koha::Checkouts::ReturnClaims', |
66 |
class => 'Koha::Old::Checkouts', |
| 67 |
value => { |
67 |
value => { |
| 68 |
created_by => undef |
68 |
borrowernumber => $patron->borrowernumber, |
|
|
69 |
itemnumber => $item->itemnumber, |
| 70 |
branchcode => $patron->branchcode |
| 69 |
} |
71 |
} |
| 70 |
} |
72 |
} |
| 71 |
); |
73 |
); |
| 72 |
|
74 |
|
| 73 |
is( $nullified_created_by->created_by, undef, 'Is undef' ); |
75 |
my $nullable_created_by = Koha::Checkouts::ReturnClaim->new( |
| 74 |
ok( $nullified_created_by->in_storage, 'In storage' ); |
76 |
{ |
|
|
77 |
issue_id => $old_checkout->id, |
| 78 |
itemnumber => $old_checkout->itemnumber, |
| 79 |
borrowernumber => $old_checkout->borrowernumber, |
| 80 |
notes => 'Some notes', |
| 81 |
created_by => $librarian->borrowernumber |
| 82 |
} |
| 83 |
)->store; |
| 84 |
is( $nullable_created_by->created_by, $librarian->borrowernumber, 'Claim created with created_by set' ); |
| 85 |
ok( $nullable_created_by->in_storage, 'In storage' ); |
| 86 |
|
| 87 |
$nullable_created_by->created_by(undef)->store(); |
| 88 |
is( $nullable_created_by->created_by, undef, 'Deletion was deleted' ); |
| 89 |
ok( $nullable_created_by->in_storage, 'In storage' ); |
| 75 |
is( |
90 |
is( |
| 76 |
ref($nullified_created_by->notes('Some other note')->store), |
91 |
ref($nullable_created_by->notes('Some other note')->store), |
| 77 |
'Koha::Checkouts::ReturnClaim', |
92 |
'Koha::Checkouts::ReturnClaim', |
| 78 |
'No exception, store success' |
93 |
'Subsequent store succeeds after created_by has been unset' |
| 79 |
); |
94 |
); |
| 80 |
|
95 |
|
| 81 |
is( Koha::Checkouts::ReturnClaims->search({ issue_id => $checkout->id })->count, 0, 'No claims stored' ); |
96 |
is( Koha::Checkouts::ReturnClaims->search({ issue_id => $checkout->id })->count, 0, 'No claims stored' ); |
| 82 |
- |
|
|