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

(-)a/t/db_dependent/Circulation/OfflineCirculation.t (-38 / +47 lines)
Lines 95-108 subtest "Bug 34529: Offline circulation should be able to accept userid as well Link Here
95
        "ProcessOfflineIssue succeeds with cardnumber"
95
        "ProcessOfflineIssue succeeds with cardnumber"
96
    );
96
    );
97
    is(
97
    is(
98
        ProcessOfflineIssue(
98
        ProcessOfflineIssue( { cardnumber => $borrower1->{userid}, barcode => $item2->barcode } ),
99
            { cardnumber => $borrower1->{userid}, barcode => $item2->barcode }
100
        ),
101
        "Success.",
99
        "Success.",
102
        "ProcessOfflineIssue succeeds with user id"
100
        "ProcessOfflineIssue succeeds with user id"
103
    );
101
    );
104
102
105
  };
103
};
106
104
107
subtest "Bug 30114 - Koha offline circulation will always cancel the next hold when issuing item to a patron" => sub {
105
subtest "Bug 30114 - Koha offline circulation will always cancel the next hold when issuing item to a patron" => sub {
108
106
Lines 114-149 subtest "Bug 30114 - Koha offline circulation will always cancel the next hold w Link Here
114
    t::lib::Mocks::mock_preference( "item-level_itypes", 1 );
112
    t::lib::Mocks::mock_preference( "item-level_itypes", 1 );
115
113
116
    # Create a branch
114
    # Create a branch
117
    $branch = $builder->build({ source => 'Branch' })->{ branchcode };
115
    $branch = $builder->build( { source => 'Branch' } )->{branchcode};
116
118
    # Create a borrower
117
    # Create a borrower
119
    my $borrower1 = $builder->build({
118
    my $borrower1 = $builder->build(
120
        source => 'Borrower',
119
        {
121
        value => { branchcode => $branch }
120
            source => 'Borrower',
122
    });
121
            value  => { branchcode => $branch }
122
        }
123
    );
123
124
124
    my $borrower2 = $builder->build({
125
    my $borrower2 = $builder->build(
125
        source => 'Borrower',
126
        {
126
        value => { branchcode => $branch }
127
            source => 'Borrower',
127
    });
128
            value  => { branchcode => $branch }
129
        }
130
    );
128
131
129
    my $borrower3 = $builder->build({
132
    my $borrower3 = $builder->build(
130
        source => 'Borrower',
133
        {
131
        value => { branchcode => $branch }
134
            source => 'Borrower',
132
    });
135
            value  => { branchcode => $branch }
136
        }
137
    );
133
138
134
    # Look for the defined MARC field for biblio-level itemtype
139
    # Look for the defined MARC field for biblio-level itemtype
135
    my $rs = $schema->resultset('MarcSubfieldStructure')->search({
140
    my $rs = $schema->resultset('MarcSubfieldStructure')->search(
136
        frameworkcode => '',
141
        {
137
        kohafield     => 'biblioitems.itemtype'
142
            frameworkcode => '',
138
    });
143
            kohafield     => 'biblioitems.itemtype'
144
        }
145
    );
139
    my $tagfield    = $rs->first->tagfield;
146
    my $tagfield    = $rs->first->tagfield;
140
    my $tagsubfield = $rs->first->tagsubfield;
147
    my $tagsubfield = $rs->first->tagsubfield;
141
148
142
    # Create a biblio record with biblio-level itemtype
149
    # Create a biblio record with biblio-level itemtype
143
    my $record = MARC::Record->new();
150
    my $record = MARC::Record->new();
144
    my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $record, '' );
151
    my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $record, '' );
145
    my $itype = $builder->build({ source => 'Itemtype' });
152
    my $itype = $builder->build( { source => 'Itemtype' } );
146
    my $item = $builder->build_sample_item(
153
    my $item  = $builder->build_sample_item(
147
        {
154
        {
148
            biblionumber => $biblionumber,
155
            biblionumber => $biblionumber,
149
            library      => $branch,
156
            library      => $branch,
Lines 153-189 subtest "Bug 30114 - Koha offline circulation will always cancel the next hold w Link Here
153
160
154
    AddReserve(
161
    AddReserve(
155
        {
162
        {
156
            branchcode       => $branch,
163
            branchcode     => $branch,
157
            borrowernumber   => $borrower1->{borrowernumber},
164
            borrowernumber => $borrower1->{borrowernumber},
158
            biblionumber     => $biblionumber,
165
            biblionumber   => $biblionumber,
159
            priority         => 1,
166
            priority       => 1,
160
            itemnumber       => $item->id,
167
            itemnumber     => $item->id,
161
        }
168
        }
162
    );
169
    );
163
170
164
    AddReserve(
171
    AddReserve(
165
        {
172
        {
166
            branchcode       => $branch,
173
            branchcode     => $branch,
167
            borrowernumber   => $borrower2->{borrowernumber},
174
            borrowernumber => $borrower2->{borrowernumber},
168
            biblionumber     => $biblionumber,
175
            biblionumber   => $biblionumber,
169
            priority         => 2,
176
            priority       => 2,
170
            itemnumber       => $item->id,
177
            itemnumber     => $item->id,
171
        }
178
        }
172
    );
179
    );
173
180
174
    my $now = dt_from_string->truncate( to => 'minute' );
181
    my $now = dt_from_string->truncate( to => 'minute' );
175
    AddOfflineOperation( $borrower3->{borrowernumber}, $borrower3->{branchcode}, $now, 'issue', $item->barcode, $borrower3->{cardnumber} );
182
    AddOfflineOperation(
183
        $borrower3->{borrowernumber}, $borrower3->{branchcode}, $now, 'issue', $item->barcode,
184
        $borrower3->{cardnumber}
185
    );
176
186
177
    my $offline_rs = Koha::Database->new()->schema()->resultset('PendingOfflineOperation')->search();
187
    my $offline_rs = Koha::Database->new()->schema()->resultset('PendingOfflineOperation')->search();
178
    is( $offline_rs->count, 1, "Found one pending offline operation" );
188
    is( $offline_rs->count, 1, "Found one pending offline operation" );
179
189
180
    is( Koha::Holds->search({ biblionumber => $biblionumber })->count, 2, "Found two holds for the record" );
190
    is( Koha::Holds->search( { biblionumber => $biblionumber } )->count, 2, "Found two holds for the record" );
181
191
182
    my $op = GetOfflineOperation( $offline_rs->next->id );
192
    my $op = GetOfflineOperation( $offline_rs->next->id );
183
193
184
    my $ret = ProcessOfflineOperation( $op );
194
    my $ret = ProcessOfflineOperation($op);
185
195
186
    is( Koha::Holds->search({ biblionumber => $biblionumber })->count, 2, "Still found two holds for the record" );
196
    is( Koha::Holds->search( { biblionumber => $biblionumber } )->count, 2, "Still found two holds for the record" );
187
};
197
};
188
198
189
$schema->storage->txn_rollback;
199
$schema->storage->txn_rollback;
190
- 

Return to bug 34529