|
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; |
| 175 |
|
| 176 |
$schema->storage->txn_begin; |
| 171 |
|
177 |
|
|
|
178 |
my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; |
| 179 |
my $library = Koha::Libraries->find( $branchcode ); |
| 180 |
$library->update({ branchname => 'New_Name', branchcity => 'AMS' }); |
| 181 |
is( $library->branchname, 'New_Name', 'Changed name with update' ); |
| 182 |
is( $library->branchcity, 'AMS', 'Changed city too' ); |
| 183 |
is( $library->is_changed, 0, 'Change should be stored already' ); |
| 184 |
try { |
| 185 |
$library->update({ |
| 186 |
branchcity => 'NYC', not_a_column => 53, branchname => 'Name3', |
| 187 |
}); |
| 188 |
fail( 'It should not be possible to update an unexisting column without an error from Koha::Object/DBIx' ); |
| 189 |
} catch { |
| 190 |
ok( $_->isa('Koha::Exceptions::Object'), 'Caught error when updating wrong column' ); |
| 191 |
$library->discard_changes; #requery after failing update |
| 192 |
}; |
| 193 |
# Check if the columns are not updated |
| 194 |
is( $library->branchcity, 'AMS', 'First column not updated' ); |
| 195 |
is( $library->branchname, 'New_Name', 'Third column not updated' ); |
| 172 |
|
196 |
|
| 173 |
1; |
197 |
$schema->storage->txn_rollback; |
|
|
198 |
}; |
| 174 |
- |
|
|