Lines 28-33
use Koha::Items;
Link Here
|
28 |
use Koha::Database; |
28 |
use Koha::Database; |
29 |
use Koha::Old::Items; |
29 |
use Koha::Old::Items; |
30 |
|
30 |
|
|
|
31 |
use List::MoreUtils qw(all); |
32 |
|
31 |
use t::lib::TestBuilder; |
33 |
use t::lib::TestBuilder; |
32 |
use t::lib::Mocks; |
34 |
use t::lib::Mocks; |
33 |
|
35 |
|
Lines 91-101
subtest "as_marc_field() tests" => sub {
Link Here
|
91 |
my @schema_columns = $schema->resultset('Item')->result_source->columns; |
93 |
my @schema_columns = $schema->resultset('Item')->result_source->columns; |
92 |
my @mapped_columns = grep { exists $mss->{'items.'.$_} } @schema_columns; |
94 |
my @mapped_columns = grep { exists $mss->{'items.'.$_} } @schema_columns; |
93 |
|
95 |
|
94 |
plan tests => 2 * (scalar @mapped_columns + 1) + 1; |
96 |
plan tests => 2 * (scalar @mapped_columns + 1) + 2; |
95 |
|
97 |
|
96 |
$schema->storage->txn_begin; |
98 |
$schema->storage->txn_begin; |
97 |
|
99 |
|
98 |
my $item = $builder->build_sample_item; |
100 |
my $item = $builder->build_sample_item; |
|
|
101 |
# Make sure it has at least one undefined attribute |
102 |
$item->set({ replacementprice => undef })->store->discard_changes; |
99 |
|
103 |
|
100 |
# Tests with the mss parameter |
104 |
# Tests with the mss parameter |
101 |
my $marc_field = $item->as_marc_field({ mss => $mss }); |
105 |
my $marc_field = $item->as_marc_field({ mss => $mss }); |
Lines 141-146
subtest "as_marc_field() tests" => sub {
Link Here
|
141 |
$item->more_subfields_xml( C4::Items::_get_unlinked_subfields_xml( \@unlinked_subfields ) )->store; |
145 |
$item->more_subfields_xml( C4::Items::_get_unlinked_subfields_xml( \@unlinked_subfields ) )->store; |
142 |
|
146 |
|
143 |
$marc_field = $item->as_marc_field; |
147 |
$marc_field = $item->as_marc_field; |
|
|
148 |
|
149 |
my @subfields = $marc_field->subfields; |
150 |
my $result = all { defined $_->[1] } @subfields; |
151 |
ok( $result, 'There are no undef subfields' ); |
152 |
|
144 |
is( scalar $marc_field->subfield('X'), 'Something weird', 'more_subfield_xml is considered' ); |
153 |
is( scalar $marc_field->subfield('X'), 'Something weird', 'more_subfield_xml is considered' ); |
145 |
|
154 |
|
146 |
$schema->storage->txn_rollback; |
155 |
$schema->storage->txn_rollback; |
147 |
- |
|
|