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

(-)a/Koha/Objects.pm (+13 lines)
Lines 234-239 sub _wrap { Link Here
234
    return @objects;
234
    return @objects;
235
}
235
}
236
236
237
=head3 update
238
239
    Koha::Objects->search({ $key => $value})->update( \%values );
240
241
Sets the specified columns in the resultset to the supplied values in a single query.
242
243
=cut
244
245
sub update {
246
    my ( $self, $params ) = @_;
247
    return $self->_resultset()->update($params);
248
}
249
237
=head3 Koha::Objects->_resultset
250
=head3 Koha::Objects->_resultset
238
251
239
Returns the internal resultset or creates it if undefined
252
Returns the internal resultset or creates it if undefined
(-)a/t/db_dependent/Koha/Objects.t (-2 / +16 lines)
Lines 19-27 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 2;
22
use Test::More tests => 3;
23
23
24
use Koha::Authority::Types;
24
use Koha::Authority::Types;
25
use Koha::Cities;
25
use Koha::Patrons;
26
use Koha::Patrons;
26
use Koha::Database;
27
use Koha::Database;
27
28
Lines 36-40 my @columns = Koha::Patrons->columns; Link Here
36
my $borrowernumber_exists = grep { /^borrowernumber$/ } @columns;
37
my $borrowernumber_exists = grep { /^borrowernumber$/ } @columns;
37
is( $borrowernumber_exists, 1, 'Koha::Objects->columns should return the table columns' );
38
is( $borrowernumber_exists, 1, 'Koha::Objects->columns should return the table columns' );
38
39
40
subtest 'update' => sub {
41
    plan tests => 2;
42
    my $builder = t::lib::TestBuilder->new;
43
    $builder->build( { source => 'City', value => { city_country => 'UK' } } );
44
    $builder->build( { source => 'City', value => { city_country => 'UK' } } );
45
    $builder->build( { source => 'City', value => { city_country => 'UK' } } );
46
    $builder->build( { source => 'City', value => { city_country => 'France' } } );
47
    $builder->build( { source => 'City', value => { city_country => 'France' } } );
48
    $builder->build( { source => 'City', value => { city_country => 'Germany' } } );
49
    Koha::Cities->search( { city_country => 'UK' } )->update( { city_country => 'EU' } );
50
    is( Koha::Cities->search( { city_country => 'EU' } )->count, 3, 'Koha::Objects->update should have updated the 3 rows' );
51
    is( Koha::Cities->search( { city_country => 'UK' } )->count, 0, 'Koha::Objects->update should have updated the 3 rows' );
52
};
53
39
$schema->storage->txn_rollback;
54
$schema->storage->txn_rollback;
40
1;
55
1;
41
- 

Return to bug 16961