Lines 19-29
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 11; |
22 |
use Test::More tests => 12; |
23 |
use Test::Warn; |
23 |
use Test::Warn; |
24 |
use Data::Dumper qw(Dumper); |
24 |
use Data::Dumper qw(Dumper); |
25 |
|
25 |
|
26 |
use Koha::Database; |
26 |
use Koha::Database; |
|
|
27 |
use Koha::Patrons; |
27 |
|
28 |
|
28 |
BEGIN { |
29 |
BEGIN { |
29 |
use_ok('t::lib::TestBuilder'); |
30 |
use_ok('t::lib::TestBuilder'); |
Lines 343-346
subtest 'Default values' => sub {
Link Here
|
343 |
|
344 |
|
344 |
$schema->storage->txn_rollback; |
345 |
$schema->storage->txn_rollback; |
345 |
|
346 |
|
|
|
347 |
subtest 'build_object() tests' => sub { |
348 |
|
349 |
plan tests => 5; |
350 |
|
351 |
$schema->storage->txn_begin; |
352 |
|
353 |
$builder = t::lib::TestBuilder->new(); |
354 |
|
355 |
my $categorycode = $builder->build( { source => 'Category' } )->{categorycode}; |
356 |
my $itemtype = $builder->build( { source => 'Itemtype' } )->{itemtype}; |
357 |
|
358 |
my $issuing_rule = $builder->build_object( |
359 |
{ class => 'Koha::IssuingRules', |
360 |
value => { |
361 |
categorycode => $categorycode, |
362 |
itemtype => $itemtype |
363 |
} |
364 |
} |
365 |
); |
366 |
|
367 |
is( ref($issuing_rule), 'Koha::IssuingRule', 'Type is correct' ); |
368 |
is( $issuing_rule->categorycode, |
369 |
$categorycode, 'Firstname correctly set' ); |
370 |
is( $issuing_rule->itemtype, $itemtype, 'Firstname correctly set' ); |
371 |
|
372 |
warning_is { $issuing_rule = $builder->build_object( {} ); } |
373 |
{ carped => 'Missing class param' }, |
374 |
'The class parameter is mandatory, raises a warning if absent'; |
375 |
is( $issuing_rule, undef, |
376 |
'If the class parameter is missing, undef is returned' ); |
377 |
|
378 |
$schema->storage->txn_rollback; |
379 |
}; |
380 |
|
346 |
1; |
381 |
1; |