Lines 18-30
Link Here
|
18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
|
|
21 |
use utf8; |
21 |
|
22 |
|
22 |
use Test::More tests => 12; |
23 |
use Test::More tests => 13; |
23 |
use Test::Exception; |
24 |
use Test::Exception; |
24 |
|
25 |
|
25 |
use C4::Biblio qw( GetMarcSubfieldStructure ); |
26 |
use C4::Biblio qw( GetMarcSubfieldStructure ); |
26 |
use C4::Circulation qw( AddIssue AddReturn ); |
27 |
use C4::Circulation qw( AddIssue AddReturn ); |
27 |
|
28 |
|
|
|
29 |
use Koha::Caches; |
28 |
use Koha::Items; |
30 |
use Koha::Items; |
29 |
use Koha::Database; |
31 |
use Koha::Database; |
30 |
use Koha::DateUtils; |
32 |
use Koha::DateUtils; |
Lines 1050-1052
subtest 'move_to_biblio() tests' => sub {
Link Here
|
1050 |
|
1052 |
|
1051 |
$schema->storage->txn_rollback; |
1053 |
$schema->storage->txn_rollback; |
1052 |
}; |
1054 |
}; |
1053 |
- |
1055 |
|
|
|
1056 |
subtest 'columns_to_str' => sub { |
1057 |
plan tests => 4; |
1058 |
|
1059 |
$schema->storage->txn_begin; |
1060 |
|
1061 |
my ( $itemtag, $itemsubfield ) = C4::Biblio::GetMarcFromKohaField( "items.itemnumber" ); |
1062 |
|
1063 |
my $cache = Koha::Caches->get_instance(); |
1064 |
$cache->clear_from_cache("MarcStructure-0-"); |
1065 |
$cache->clear_from_cache("MarcStructure-1-"); |
1066 |
$cache->clear_from_cache("default_value_for_mod_marc-"); |
1067 |
$cache->clear_from_cache("MarcSubfieldStructure-"); |
1068 |
|
1069 |
# Creating subfields 'é', 'è' that are not linked with a kohafield |
1070 |
Koha::MarcSubfieldStructures->search( |
1071 |
{ |
1072 |
frameworkcode => '', |
1073 |
tagfield => $itemtag, |
1074 |
tagsubfield => ['é', 'è'], |
1075 |
} |
1076 |
)->delete; # In case it exist already |
1077 |
|
1078 |
# é is not linked with a AV |
1079 |
# è is linked with AV branches |
1080 |
Koha::MarcSubfieldStructure->new( |
1081 |
{ |
1082 |
frameworkcode => '', |
1083 |
tagfield => $itemtag, |
1084 |
tagsubfield => 'é', |
1085 |
kohafield => undef, |
1086 |
repeatable => 1, |
1087 |
defaultvalue => 'ééé', |
1088 |
tab => 10, |
1089 |
} |
1090 |
)->store; |
1091 |
Koha::MarcSubfieldStructure->new( |
1092 |
{ |
1093 |
frameworkcode => '', |
1094 |
tagfield => $itemtag, |
1095 |
tagsubfield => 'è', |
1096 |
kohafield => undef, |
1097 |
repeatable => 1, |
1098 |
defaultvalue => 'èèè', |
1099 |
tab => 10, |
1100 |
authorised_value => 'branches', |
1101 |
} |
1102 |
)->store; |
1103 |
|
1104 |
my $biblio = $builder->build_sample_biblio({ frameworkcode => '' }); |
1105 |
my $item = $builder->build_sample_item({ biblionumber => $biblio->biblionumber }); |
1106 |
my $itemlost = Koha::AuthorisedValues->search({ category => 'LOST' })->next->authorised_value; |
1107 |
my $dateaccessioned = '2020-12-15'; |
1108 |
my $library = Koha::Libraries->search->next; |
1109 |
my $branchcode = $library->branchcode; |
1110 |
|
1111 |
my $some_marc_xml = qq{<?xml version="1.0" encoding="UTF-8"?> |
1112 |
<collection |
1113 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
1114 |
xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd" |
1115 |
xmlns="http://www.loc.gov/MARC21/slim"> |
1116 |
|
1117 |
<record> |
1118 |
<leader> a </leader> |
1119 |
<datafield tag="999" ind1=" " ind2=" "> |
1120 |
<subfield code="é">value é</subfield> |
1121 |
<subfield code="è">$branchcode</subfield> |
1122 |
</datafield> |
1123 |
</record> |
1124 |
|
1125 |
</collection>}; |
1126 |
|
1127 |
$item->update( |
1128 |
{ |
1129 |
itemlost => $itemlost, |
1130 |
dateaccessioned => $dateaccessioned, |
1131 |
more_subfields_xml => $some_marc_xml, |
1132 |
} |
1133 |
); |
1134 |
|
1135 |
$item = $item->get_from_storage; |
1136 |
|
1137 |
my $s = $item->columns_to_str; |
1138 |
is( $s->{itemlost}, 'Lost' ); |
1139 |
is( $s->{dateaccessioned}, '2020-12-15'); |
1140 |
is( $s->{é}, 'value é'); |
1141 |
is( $s->{è}, $library->branchname ); |
1142 |
|
1143 |
$cache->clear_from_cache("MarcStructure-0-"); |
1144 |
$cache->clear_from_cache("MarcStructure-1-"); |
1145 |
$cache->clear_from_cache("default_value_for_mod_marc-"); |
1146 |
$cache->clear_from_cache("MarcSubfieldStructure-"); |
1147 |
|
1148 |
$schema->storage->txn_rollback; |
1149 |
|
1150 |
}; |