Lines 745-757
subtest "LinkBibHeadingsToAuthorities record generation tests" => sub {
Link Here
|
745 |
t::lib::Mocks::mock_preference('AutoCreateAuthorities', '1'); |
745 |
t::lib::Mocks::mock_preference('AutoCreateAuthorities', '1'); |
746 |
|
746 |
|
747 |
my $linker = C4::Linker::Default->new(); |
747 |
my $linker = C4::Linker::Default->new(); |
748 |
my $record = MARC::Record->new(); |
748 |
my $biblio = $builder->build_sample_biblio(); |
|
|
749 |
my $record = $biblio->metadata->record; |
749 |
|
750 |
|
750 |
# Generate a record including all valid subfields and an invalid one 'e' |
751 |
# Generate a record including all valid subfields and an invalid one 'e' |
751 |
my $field = MARC::Field->new('650','','','a' => 'Beach city', 'b' => 'Weirdness', 'v' => 'Fiction', 'x' => 'Books', 'y' => '21st Century', 'z' => 'Fish Stew Pizza', 'e' => 'Depicted'); |
752 |
my $field = MARC::Field->new('650','','','a' => 'Beach city', 'b' => 'Weirdness', 'v' => 'Fiction', 'x' => 'Books', 'y' => '21st Century', 'z' => 'Fish Stew Pizza', 'e' => 'Depicted'); |
752 |
|
753 |
|
753 |
$record->append_fields($field); |
754 |
$record->append_fields($field); |
754 |
my ( $num_headings_changed, $results ) = LinkBibHeadingsToAuthorities($linker, $record, "",undef); |
755 |
my ( $num_headings_changed, $results ) = LinkBibHeadingsToAuthorities($linker, $record, "",undef,650); |
755 |
|
756 |
|
756 |
is( $num_headings_changed, 1, 'We changed the one we passed' ); |
757 |
is( $num_headings_changed, 1, 'We changed the one we passed' ); |
757 |
is_deeply( $results->{added}, |
758 |
is_deeply( $results->{added}, |
Lines 767-774
subtest "LinkBibHeadingsToAuthorities record generation tests" => sub {
Link Here
|
767 |
); |
768 |
); |
768 |
|
769 |
|
769 |
#Add test for this case using verbose |
770 |
#Add test for this case using verbose |
770 |
( $num_headings_changed, $results ) = LinkBibHeadingsToAuthorities($linker, $record, "",undef, 1); |
771 |
$record->field('650')->delete_subfield('9'); |
771 |
my $details = $results->{details}; |
772 |
( $num_headings_changed, $results ) = LinkBibHeadingsToAuthorities($linker, $record, "",undef, 650, 1); |
772 |
is( $num_headings_changed, 1, 'We changed the one we passed' ); |
773 |
is( $num_headings_changed, 1, 'We changed the one we passed' ); |
773 |
is( $results->{details}->[0]->{status}, 'CREATED', "We added an authority record for the heading using verbose"); |
774 |
is( $results->{details}->[0]->{status}, 'CREATED', "We added an authority record for the heading using verbose"); |
774 |
|
775 |
|
Lines 781-791
subtest "LinkBibHeadingsToAuthorities record generation tests" => sub {
Link Here
|
781 |
); |
782 |
); |
782 |
|
783 |
|
783 |
# Example series link with volume and punctuation |
784 |
# Example series link with volume and punctuation |
784 |
$record = MARC::Record->new(); |
|
|
785 |
$field = MARC::Field->new('800','','','a' => 'Tolkien, J. R. R.', 'q' => '(John Ronald Reuel),', 'd' => '1892-1973.', 't' => 'Lord of the rings ;', 'v' => '1'); |
785 |
$field = MARC::Field->new('800','','','a' => 'Tolkien, J. R. R.', 'q' => '(John Ronald Reuel),', 'd' => '1892-1973.', 't' => 'Lord of the rings ;', 'v' => '1'); |
786 |
$record->append_fields($field); |
786 |
$record->append_fields($field); |
787 |
|
787 |
|
788 |
( $num_headings_changed, $results ) = LinkBibHeadingsToAuthorities($linker, $record, "",undef); |
788 |
( $num_headings_changed, $results ) = LinkBibHeadingsToAuthorities($linker, $record, "",undef, 800); |
789 |
|
789 |
|
790 |
is( $num_headings_changed, 1, 'We changed the one we passed' ); |
790 |
is( $num_headings_changed, 1, 'We changed the one we passed' ); |
791 |
is_deeply( $results->{added}, |
791 |
is_deeply( $results->{added}, |
Lines 801-807
subtest "LinkBibHeadingsToAuthorities record generation tests" => sub {
Link Here
|
801 |
); |
801 |
); |
802 |
|
802 |
|
803 |
# The same example With verbose |
803 |
# The same example With verbose |
804 |
( $num_headings_changed, $results ) = LinkBibHeadingsToAuthorities($linker, $record, "",undef, 1); |
804 |
$record->field('800')->delete_subfield('9'); |
|
|
805 |
( $num_headings_changed, $results ) = LinkBibHeadingsToAuthorities($linker, $record, "",undef, 800, 1); |
805 |
is( $num_headings_changed, 1, 'We changed the one we passed' ); |
806 |
is( $num_headings_changed, 1, 'We changed the one we passed' ); |
806 |
is( $results->{details}->[0]->{status}, 'CREATED', "We added an authority record for the heading using verbose"); |
807 |
is( $results->{details}->[0]->{status}, 'CREATED', "We added an authority record for the heading using verbose"); |
807 |
|
808 |
|
808 |
- |
|
|