Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 9; |
20 |
use Test::More tests => 10; |
|
|
21 |
use Test::Exception; |
21 |
use Test::Warn; |
22 |
use Test::Warn; |
22 |
|
23 |
|
23 |
use C4::Context; |
24 |
use C4::Context; |
Lines 218-220
subtest "Test update method" => sub {
Link Here
|
218 |
|
219 |
|
219 |
$schema->storage->txn_rollback; |
220 |
$schema->storage->txn_rollback; |
220 |
}; |
221 |
}; |
221 |
- |
222 |
|
|
|
223 |
subtest 'store() tests' => sub { |
224 |
|
225 |
plan tests => 3; |
226 |
|
227 |
$schema->storage->txn_begin; |
228 |
|
229 |
# Create a category to make sure its ID doesn't exist on the DB |
230 |
my $category = $builder->build_object({ class => 'Koha::Patron::Categories' }); |
231 |
my $category_id = $category->id; |
232 |
$category->delete; |
233 |
|
234 |
my $patron = Koha::Patron->new({ categorycode => $category_id }); |
235 |
|
236 |
my $print_error = $schema->storage->dbh->{PrintError}; |
237 |
$schema->storage->dbh->{PrintError} = 0; |
238 |
throws_ok |
239 |
{ $patron->store } |
240 |
'Koha::Exceptions::Object::FKConstraint', |
241 |
'Exception is thrown correctly'; |
242 |
is( |
243 |
$@->message, |
244 |
"Broken FK constraint", |
245 |
'Exception message is correct' |
246 |
); |
247 |
is( |
248 |
$@->broken_fk, |
249 |
'categorycode', |
250 |
'Exception message is correct' |
251 |
); |
252 |
$schema->storage->dbh->{PrintError} = $print_error; |
253 |
$schema->storage->txn_rollback; |
254 |
}; |