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

(-)a/t/db_dependent/Illrequests.t (-47 / +36 lines)
Lines 191-253 subtest 'store borrowernumber change also updates holds' => sub { Link Here
191
191
192
subtest 'Working with related objects' => sub {
192
subtest 'Working with related objects' => sub {
193
193
194
    plan tests => 7;
194
    plan tests => 6;
195
195
196
    $schema->storage->txn_begin;
196
    $schema->storage->txn_begin;
197
197
198
    Koha::Illrequests->search->delete;
198
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
199
199
    my $illrq  = $builder->build_object(
200
    my $patron = $builder->build({ source => 'Borrower' });
200
        {   class => 'Koha::Illrequests',
201
    my $illrq = $builder->build({
201
            value => { borrowernumber => $patron->id, biblio_id => undef }
202
        source => 'Illrequest',
202
        }
203
        value => { borrowernumber => $patron->{borrowernumber} }
203
    );
204
    });
205
    my $illrq_obj = Koha::Illrequests->find($illrq->{illrequest_id});
206
207
    isa_ok($illrq_obj->patron, 'Koha::Patron',
208
           "OK accessing related patron.");
209
204
210
    $builder->build({
205
    isa_ok( $illrq->patron, 'Koha::Patron', "OK accessing related patron." );
211
        source => 'Illrequestattribute',
212
        value  => { illrequest_id => $illrq_obj->illrequest_id, type => 'X' }
213
    });
214
    $builder->build({
215
        source => 'Illrequestattribute',
216
        value  => { illrequest_id => $illrq_obj->illrequest_id, type => 'Y' }
217
    });
218
    $builder->build({
219
        source => 'Illrequestattribute',
220
        value  => { illrequest_id => $illrq_obj->illrequest_id, type => 'Z' }
221
    });
222
206
223
    is($illrq_obj->illrequestattributes->count, Koha::Illrequestattributes->search->count,
207
    $builder->build(
224
       "Fetching expected number of Illrequestattributes for our request.");
208
        {   source => 'Illrequestattribute',
209
            value  => { illrequest_id => $illrq->illrequest_id, type => 'X' }
210
        }
211
    );
212
    $builder->build(
213
        {   source => 'Illrequestattribute',
214
            value  => { illrequest_id => $illrq->illrequest_id, type => 'Y' }
215
        }
216
    );
217
    $builder->build(
218
        {   source => 'Illrequestattribute',
219
            value  => { illrequest_id => $illrq->illrequest_id, type => 'Z' }
220
        }
221
    );
225
222
226
    my $illrq1 = $builder->build({ source => 'Illrequest' });
223
    my $rs = Koha::Illrequestattributes->search( { illrequest_id => $illrq->id } );
227
    $builder->build({
228
        source => 'Illrequestattribute',
229
        value  => { illrequest_id => $illrq1->{illrequest_id}, type => 'X' }
230
    });
231
224
232
    is($illrq_obj->illrequestattributes->count + 1, Koha::Illrequestattributes->search->count,
225
    is( $illrq->extended_attributes->count,
233
       "Fetching expected number of Illrequestattributes for our request.");
226
        $rs->count, "Fetching expected number of Illrequestattributes for our request." );
234
227
235
    is($illrq_obj->biblio, undef, "->biblio returns undef if no biblio");
228
    is( $illrq->biblio, undef, "->biblio returns undef if no biblio" );
236
    my $biblio = $builder->build_object({ class => 'Koha::Biblios' });
229
    my $biblio  = $builder->build_object( { class => 'Koha::Biblios' } );
237
    my $req_bib = $builder->build_object({
230
    my $req_bib = $builder->build_object(
238
        class => 'Koha::Illrequests',
231
        {   class => 'Koha::Illrequests',
239
        value => {
232
            value => { biblio_id => $biblio->biblionumber }
240
            biblio_id      => $biblio->biblionumber
241
        }
233
        }
242
    });
234
    );
243
    isa_ok($req_bib->biblio, 'Koha::Biblio', "OK accessing related biblio");
235
    isa_ok( $req_bib->biblio, 'Koha::Biblio', "OK accessing related biblio" );
244
236
245
    $illrq_obj->delete;
237
    $illrq->delete;
246
    is(Koha::Illrequestattributes->search->count, 1,
238
    is( $rs->count, 0, "Correct number of illrequestattributes after delete." );
247
       "Correct number of illrequestattributes after delete.");
248
239
249
    isa_ok(Koha::Patrons->find($patron->{borrowernumber}), 'Koha::Patron',
240
    isa_ok( Koha::Patrons->find( $patron->id ), 'Koha::Patron', "Borrower was not deleted after illrq delete." );
250
           "Borrower was not deleted after illrq delete.");
251
241
252
    $schema->storage->txn_rollback;
242
    $schema->storage->txn_rollback;
253
};
243
};
254
- 

Return to bug 22440