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

(-)a/t/db_dependent/Koha/Notice/Message.t (-2 / +18 lines)
Lines 221-230 WRAPPED Link Here
221
221
222
subtest 'patron() tests' => sub {
222
subtest 'patron() tests' => sub {
223
223
224
    plan tests => 2;
224
    plan tests => 4;
225
225
226
    $schema->storage->txn_begin;
226
    $schema->storage->txn_begin;
227
227
228
    # Valid patron and message
228
    my $patron  = $builder->build_object( { class => 'Koha::Patrons' } );
229
    my $patron  = $builder->build_object( { class => 'Koha::Patrons' } );
229
    my $message = $builder->build_object(
230
    my $message = $builder->build_object(
230
        {
231
        {
Lines 232-241 subtest 'patron() tests' => sub { Link Here
232
            value => { borrowernumber => $patron->borrowernumber }
233
            value => { borrowernumber => $patron->borrowernumber }
233
        }
234
        }
234
    );
235
    );
236
    my $message_id = $message->message_id;
235
237
236
    is( ref( $message->patron ),          'Koha::Patron',          'Object type is correct' );
238
    is( ref( $message->patron ),          'Koha::Patron',          'Object type is correct' );
237
    is( $message->patron->borrowernumber, $patron->borrowernumber, 'Right patron linked' );
239
    is( $message->patron->borrowernumber, $patron->borrowernumber, 'Right patron linked' );
238
240
241
    # Deleted patron
242
    $patron->delete;
243
    $message = Koha::Notice::Messages->find($message_id);
244
    is( $message, undef, 'Deleting the patron also deletes the associated message' );
245
246
    # Missing patron
247
    $message = $builder->build_object(
248
        {
249
            class => 'Koha::Notice::Messages',
250
            value => { borrowernumber => undef }
251
        }
252
    );
253
254
    is( $message->patron, undef, 'Returns undef if borrowernumber is missing' );
255
239
    $schema->storage->txn_rollback;
256
    $schema->storage->txn_rollback;
240
};
257
};
241
258
242
- 

Return to bug 33260