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

(-)a/t/db_dependent/Koha/Object.t (-2 / +40 lines)
Lines 242-248 subtest "Test update method" => sub { Link Here
242
242
243
subtest 'store() tests' => sub {
243
subtest 'store() tests' => sub {
244
244
245
    plan tests => 8;
245
    plan tests => 16;
246
246
247
    # Using Koha::ApiKey to test Koha::Object>-store
247
    # Using Koha::ApiKey to test Koha::Object>-store
248
    # Simple object with foreign keys and unique key
248
    # Simple object with foreign keys and unique key
Lines 306-311 subtest 'store() tests' => sub { Link Here
306
    my $ret = $api_key->store;
306
    my $ret = $api_key->store;
307
    is( ref($ret), 'Koha::ApiKey', 'store() returns the object on success' );
307
    is( ref($ret), 'Koha::ApiKey', 'store() returns the object on success' );
308
308
309
    my $library = $builder->build_object( { class => 'Koha::Libraries' } );
310
    my $patron_category = $builder->build_object(
311
        {
312
            class => 'Koha::Patron::Categories',
313
            value => { category_type => 'P', enrolmentfee => 0 }
314
        }
315
    );
316
317
    $patron = eval {
318
        Koha::Patron->new(
319
            {
320
                categorycode    => $patron_category->categorycode,
321
                branchcode      => $library->branchcode,
322
                dateofbirth     => "", # date will be set to NULL
323
                sms_provider_id => "", # Integer will be set to NULL
324
                privacy         => "", # privacy cannot be NULL but has a default value
325
            }
326
        )->store;
327
    };
328
    is( $@, '', 'No error should be raised by ->store if empty strings are passed' );
329
    is( $patron->privacy, 1, 'Default value for privacy should be set to 1' );
330
    is( $patron->dateofbirth,     undef, 'dateofbirth must have been set to undef');
331
    is( $patron->sms_provider_id, undef, 'sms_provider_id must have been set to undef');
332
333
    my $itemtype = eval {
334
        Koha::ItemType->new(
335
            {
336
                itemtype        => 'IT4test',
337
                rentalcharge    => "",
338
                notforloan      => "",
339
                hideinopac      => "",
340
            }
341
        )->store;
342
    };
343
    is( $@, '', 'No error should be raised by ->store if empty strings are passed' );
344
    is( $itemtype->rentalcharge, undef, 'decimal DEFAULT NULL should default to null');
345
    is( $itemtype->notforloan, undef, 'int DEFAULT NULL should default to null');
346
    is( $itemtype->hideinopac, 0, 'int NOT NULL DEFAULT 0 should default to 0');
347
309
    subtest 'Bad value tests' => sub {
348
    subtest 'Bad value tests' => sub {
310
349
311
        plan tests => 1;
350
        plan tests => 1;
312
- 

Return to bug 21610