View | Details | Raw Unified | Return to bug 29495
Collapse All | Expand All

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

Return to bug 29495