Lines 17-30
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 8; |
20 |
use Test::More tests => 9; |
21 |
use Test::Warn; |
21 |
use Test::Warn; |
22 |
|
22 |
|
23 |
use C4::Context; |
23 |
use C4::Context; |
24 |
use Koha::Database; |
24 |
use Koha::Database; |
25 |
use Koha::DateUtils qw( dt_from_string ); |
25 |
use Koha::DateUtils qw( dt_from_string ); |
|
|
26 |
use Koha::Libraries; |
26 |
|
27 |
|
27 |
use Scalar::Util qw( isvstring ); |
28 |
use Scalar::Util qw( isvstring ); |
|
|
29 |
use Try::Tiny; |
28 |
|
30 |
|
29 |
use t::lib::TestBuilder; |
31 |
use t::lib::TestBuilder; |
30 |
|
32 |
|
Lines 168-173
subtest 'TO_JSON tests' => sub {
Link Here
|
168 |
$schema->storage->txn_rollback; |
170 |
$schema->storage->txn_rollback; |
169 |
}; |
171 |
}; |
170 |
|
172 |
|
|
|
173 |
subtest "Test update method" => sub { |
174 |
plan tests => 6; |
171 |
|
175 |
|
|
|
176 |
$schema->storage->txn_begin; |
177 |
my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; |
178 |
my $library = Koha::Libraries->find( $branchcode ); |
179 |
$library->update({ branchname => 'New_Name', branchcity => 'AMS' }); |
180 |
is( $library->branchname, 'New_Name', 'Changed name with update' ); |
181 |
is( $library->branchcity, 'AMS', 'Changed city too' ); |
182 |
is( $library->is_changed, 0, 'Change should be stored already' ); |
183 |
try { |
184 |
$library->update({ |
185 |
branchcity => 'NYC', not_a_column => 53, branchname => 'Name3', |
186 |
}); |
187 |
ok( 0, 'It should not be possible to update an unexisting column without an error from Koha::Object/DBIx' ); |
188 |
} catch { |
189 |
ok( $_->isa('Koha::Exceptions::Object'), 'Caught error when updating wrong column' ); |
190 |
}; |
191 |
# DBIx behavior is not reliable; run the test multiple times |
192 |
# The test mostly fails on one or both, but sometimes passes |
193 |
is( $library->branchcity, 'NYC', 'DBIx updated the first column' ); |
194 |
is( $library->branchname, 'New_Name', 'DBIx did not update the third column' ); |
172 |
|
195 |
|
173 |
1; |
196 |
$schema->storage->txn_rollback; |
|
|
197 |
}; |
174 |
- |
|
|