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

(-)a/t/db_dependent/TestBuilder.t (-3 / +11 lines)
Lines 36-47 our $builder; Link Here
36
36
37
37
38
subtest 'Start with some trivial tests' => sub {
38
subtest 'Start with some trivial tests' => sub {
39
    plan tests => 6;
39
    plan tests => 7;
40
40
41
    $builder = t::lib::TestBuilder->new;
41
    $builder = t::lib::TestBuilder->new;
42
    isnt( $builder, undef, 'We got a builder' );
42
    isnt( $builder, undef, 'We got a builder' );
43
43
44
    is( $builder->build, undef, 'build without arguments returns undef' );
44
    my $data;
45
    warning_like { my $data = $builder->build; } qr/.+/, 'Catch a warning';
46
    is( $data, undef, 'build without arguments returns undef' );
45
    is( ref( $builder->schema ), 'Koha::Schema', 'check schema' );
47
    is( ref( $builder->schema ), 'Koha::Schema', 'check schema' );
46
    is( ref( $builder->can('delete') ), 'CODE', 'found delete method' );
48
    is( ref( $builder->can('delete') ), 'CODE', 'found delete method' );
47
49
Lines 391-397 subtest 'build_object() tests' => sub { Link Here
391
};
393
};
392
394
393
subtest '->build parameter' => sub {
395
subtest '->build parameter' => sub {
394
    plan tests => 2;
396
    plan tests => 3;
395
397
396
    # Test to make sure build() warns user of unknown parameters.
398
    # Test to make sure build() warns user of unknown parameters.
397
    warnings_are {
399
    warnings_are {
Lines 409-414 subtest '->build parameter' => sub { Link Here
409
            branchcode => 'BRANCH_2' # This is wrong!
411
            branchcode => 'BRANCH_2' # This is wrong!
410
        })
412
        })
411
    } qr/unknown param/i, "Carp unknown parameters";
413
    } qr/unknown param/i, "Carp unknown parameters";
414
415
    warnings_like {
416
        $builder->build({
417
            zource     => 'Branch', # Intentional spelling error
418
        })
419
    } qr/Source parameter not specified/, "Catch warning on missing source";
412
};
420
};
413
421
414
$schema->storage->txn_rollback;
422
$schema->storage->txn_rollback;
(-)a/t/lib/TestBuilder.pm (-2 / +5 lines)
Lines 86-92 sub build { Link Here
86
# build returns a hash of column values for a created record, or undef
86
# build returns a hash of column values for a created record, or undef
87
# build does NOT update a record, or pass back values of an existing record
87
# build does NOT update a record, or pass back values of an existing record
88
    my ($self, $params) = @_;
88
    my ($self, $params) = @_;
89
    my $source  = $params->{source} || return;
89
    my $source  = $params->{source};
90
    if( !$source ) {
91
        carp "Source parameter not specified!";
92
        return;
93
    }
90
    my $value   = $params->{value};
94
    my $value   = $params->{value};
91
95
92
    my @unknowns = grep( !/^(source|value)$/, keys %{ $params });
96
    my @unknowns = grep( !/^(source|value)$/, keys %{ $params });
93
- 

Return to bug 15339