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 => 9; |
23 |
use Test::More tests => 10; |
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 816-818
subtest 'get_transfers' => sub {
Link Here
|
816 |
|
818 |
|
817 |
$schema->storage->txn_rollback; |
819 |
$schema->storage->txn_rollback; |
818 |
}; |
820 |
}; |
819 |
- |
821 |
|
|
|
822 |
subtest 'columns_to_str' => sub { |
823 |
plan tests => 4; |
824 |
|
825 |
$schema->storage->txn_begin; |
826 |
|
827 |
my ( $itemtag, $itemsubfield ) = C4::Biblio::GetMarcFromKohaField( "items.itemnumber" ); |
828 |
|
829 |
my $cache = Koha::Caches->get_instance(); |
830 |
$cache->clear_from_cache("MarcStructure-0-"); |
831 |
$cache->clear_from_cache("MarcStructure-1-"); |
832 |
$cache->clear_from_cache("default_value_for_mod_marc-"); |
833 |
$cache->clear_from_cache("MarcSubfieldStructure-"); |
834 |
|
835 |
# Creating subfields 'é', 'è' that are not linked with a kohafield |
836 |
Koha::MarcSubfieldStructures->search( |
837 |
{ |
838 |
frameworkcode => '', |
839 |
tagfield => $itemtag, |
840 |
tagsubfield => ['é', 'è'], |
841 |
} |
842 |
)->delete; # In case it exist already |
843 |
|
844 |
# é is not linked with a AV |
845 |
# è is linked with AV branches |
846 |
Koha::MarcSubfieldStructure->new( |
847 |
{ |
848 |
frameworkcode => '', |
849 |
tagfield => $itemtag, |
850 |
tagsubfield => 'é', |
851 |
kohafield => undef, |
852 |
repeatable => 1, |
853 |
defaultvalue => 'ééé', |
854 |
tab => 10, |
855 |
} |
856 |
)->store; |
857 |
Koha::MarcSubfieldStructure->new( |
858 |
{ |
859 |
frameworkcode => '', |
860 |
tagfield => $itemtag, |
861 |
tagsubfield => 'è', |
862 |
kohafield => undef, |
863 |
repeatable => 1, |
864 |
defaultvalue => 'èèè', |
865 |
tab => 10, |
866 |
authorised_value => 'branches', |
867 |
} |
868 |
)->store; |
869 |
|
870 |
my $biblio = $builder->build_sample_biblio({ frameworkcode => '' }); |
871 |
my $item = $builder->build_sample_item({ biblionumber => $biblio->biblionumber }); |
872 |
my $itemlost = Koha::AuthorisedValues->search({ category => 'LOST' })->next->authorised_value; |
873 |
my $dateaccessioned = '2020-12-15'; |
874 |
my $library = Koha::Libraries->search->next; |
875 |
my $branchcode = $library->branchcode; |
876 |
|
877 |
my $some_marc_xml = qq{<?xml version="1.0" encoding="UTF-8"?> |
878 |
<collection |
879 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
880 |
xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd" |
881 |
xmlns="http://www.loc.gov/MARC21/slim"> |
882 |
|
883 |
<record> |
884 |
<leader> a </leader> |
885 |
<datafield tag="999" ind1=" " ind2=" "> |
886 |
<subfield code="é">value é</subfield> |
887 |
<subfield code="è">$branchcode</subfield> |
888 |
</datafield> |
889 |
</record> |
890 |
|
891 |
</collection>}; |
892 |
|
893 |
$item->update( |
894 |
{ |
895 |
itemlost => $itemlost, |
896 |
dateaccessioned => $dateaccessioned, |
897 |
more_subfields_xml => $some_marc_xml, |
898 |
} |
899 |
); |
900 |
|
901 |
$item = $item->get_from_storage; |
902 |
|
903 |
my $s = $item->columns_to_str; |
904 |
is( $s->{itemlost}, 'Lost' ); |
905 |
is( $s->{dateaccessioned}, '2020-12-15'); |
906 |
is( $s->{é}, 'value é'); |
907 |
is( $s->{è}, $library->branchname ); |
908 |
|
909 |
$cache->clear_from_cache("MarcStructure-0-"); |
910 |
$cache->clear_from_cache("MarcStructure-1-"); |
911 |
$cache->clear_from_cache("default_value_for_mod_marc-"); |
912 |
$cache->clear_from_cache("MarcSubfieldStructure-"); |
913 |
|
914 |
$schema->storage->txn_rollback; |
915 |
|
916 |
}; |