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 345-348
subtest 'Default values' => sub {
Link Here
|
345 |
|
346 |
|
346 |
$schema->storage->txn_rollback; |
347 |
$schema->storage->txn_rollback; |
347 |
|
348 |
|
|
|
349 |
subtest 'build_object() tests' => sub { |
350 |
|
351 |
plan tests => 5; |
352 |
|
353 |
$schema->storage->txn_begin; |
354 |
|
355 |
$builder = t::lib::TestBuilder->new(); |
356 |
|
357 |
my $categorycode = $builder->build( { source => 'Category' } )->{categorycode}; |
358 |
my $itemtype = $builder->build( { source => 'Itemtype' } )->{itemtype}; |
359 |
|
360 |
my $issuing_rule = $builder->build_object( |
361 |
{ class => 'Koha::IssuingRules', |
362 |
value => { |
363 |
categorycode => $categorycode, |
364 |
itemtype => $itemtype |
365 |
} |
366 |
} |
367 |
); |
368 |
|
369 |
is( ref($issuing_rule), 'Koha::IssuingRule', 'Type is correct' ); |
370 |
is( $issuing_rule->categorycode, |
371 |
$categorycode, 'Firstname correctly set' ); |
372 |
is( $issuing_rule->itemtype, $itemtype, 'Firstname correctly set' ); |
373 |
|
374 |
warning_is { $issuing_rule = $builder->build_object( {} ); } |
375 |
{ carped => 'Missing class param' }, |
376 |
'The class parameter is mandatory, raises a warning if absent'; |
377 |
is( $issuing_rule, undef, |
378 |
'If the class parameter is missing, undef is returned' ); |
379 |
|
380 |
$schema->storage->txn_rollback; |
381 |
}; |
382 |
|
348 |
1; |
383 |
1; |