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

(-)a/t/db_dependent/Koha/Notice/Message.t (-2 / +18 lines)
Lines 368-377 subtest 'stylesheets() tests' => sub { Link Here
368
368
369
subtest 'patron() tests' => sub {
369
subtest 'patron() tests' => sub {
370
370
371
    plan tests => 2;
371
    plan tests => 4;
372
372
373
    $schema->storage->txn_begin;
373
    $schema->storage->txn_begin;
374
374
375
    # Valid patron and message
375
    my $patron  = $builder->build_object( { class => 'Koha::Patrons' } );
376
    my $patron  = $builder->build_object( { class => 'Koha::Patrons' } );
376
    my $message = $builder->build_object(
377
    my $message = $builder->build_object(
377
        {
378
        {
Lines 379-388 subtest 'patron() tests' => sub { Link Here
379
            value => { borrowernumber => $patron->borrowernumber }
380
            value => { borrowernumber => $patron->borrowernumber }
380
        }
381
        }
381
    );
382
    );
383
    my $message_id = $message->message_id;
382
384
383
    is( ref( $message->patron ),          'Koha::Patron',          'Object type is correct' );
385
    is( ref( $message->patron ),          'Koha::Patron',          'Object type is correct' );
384
    is( $message->patron->borrowernumber, $patron->borrowernumber, 'Right patron linked' );
386
    is( $message->patron->borrowernumber, $patron->borrowernumber, 'Right patron linked' );
385
387
388
    # Deleted patron
389
    $patron->delete;
390
    $message = Koha::Notice::Messages->find($message_id);
391
    is( $message, undef, 'Deleting the patron also deletes the associated message' );
392
393
    # Missing patron
394
    $message = $builder->build_object(
395
        {
396
            class => 'Koha::Notice::Messages',
397
            value => { borrowernumber => undef }
398
        }
399
    );
400
401
    is( $message->patron, undef, 'Returns undef if borrowernumber is missing' );
402
386
    $schema->storage->txn_rollback;
403
    $schema->storage->txn_rollback;
387
};
404
};
388
405
389
- 

Return to bug 33260