View | Details | Raw Unified | Return to bug 31644
Collapse All | Expand All

(-)a/t/db_dependent/MarcModificationTemplates.t (-3 / +36 lines)
Lines 1-6 Link Here
1
use Modern::Perl;
1
use Modern::Perl;
2
2
3
use Test::More tests => 127;
3
use Test::More tests => 129;
4
4
5
use Koha::Database;
5
use Koha::Database;
6
use Koha::SimpleMARC;
6
use Koha::SimpleMARC;
Lines 744-749 sub expected_record_0 { Link Here
744
        MARC::Field->new(
744
        MARC::Field->new(
745
            690, ' ', ' ',
745
            690, ' ', ' ',
746
            0 => 'Zeroth',
746
            0 => 'Zeroth',
747
            a => 'Appolo',
748
        ),
749
        MARC::Field->new(
750
            690, ' ', '0',
751
            0 => 'Zeroth',
752
            a => 'Appolo',
747
        ),
753
        ),
748
    );
754
    );
749
    $record->append_fields(@fields);
755
    $record->append_fields(@fields);
Lines 766-771 is( AddModificationTemplateAction( Link Here
766
), 1, 'Action 1: Delete subfield 100$0');
772
), 1, 'Action 1: Delete subfield 100$0');
767
773
768
# Add new subfield 100$0 with value "Test"
774
# Add new subfield 100$0 with value "Test"
775
# This adds a new 100 field to the record
769
is( AddModificationTemplateAction(
776
is( AddModificationTemplateAction(
770
    $template_id, 'add_field', 0,
777
    $template_id, 'add_field', 0,
771
    '100', '0', 'Test', '', '',
778
    '100', '0', 'Test', '', '',
Lines 775-780 is( AddModificationTemplateAction( Link Here
775
), 1, 'Action 2: Add new subfield 100$0');
782
), 1, 'Action 2: Add new subfield 100$0');
776
783
777
# Update existing or add new subfield 100$0 with value "TestUpdated"
784
# Update existing or add new subfield 100$0 with value "TestUpdated"
785
# This updates the new 100 create above, and adds a new 100$0 to the original 100 field
778
is( AddModificationTemplateAction(
786
is( AddModificationTemplateAction(
779
    $template_id, 'update_field', 0,
787
    $template_id, 'update_field', 0,
780
    '100', '0', 'TestUpdated', '', '',
788
    '100', '0', 'TestUpdated', '', '',
Lines 784-789 is( AddModificationTemplateAction( Link Here
784
), 1, 'Action 3: Update existing or add new subfield 100$0 with value "TestUpdated"');
792
), 1, 'Action 3: Update existing or add new subfield 100$0 with value "TestUpdated"');
785
793
786
# Move subfield 100$0 to 600$0
794
# Move subfield 100$0 to 600$0
795
# This removes the newly created 100, and removes the 100$0 from the original 100 field
796
# Two 600 fields with a single 0 subfield are created
787
is( AddModificationTemplateAction(
797
is( AddModificationTemplateAction(
788
    $template_id, 'move_field', 0,
798
    $template_id, 'move_field', 0,
789
    '100', '0', '', '600', '0',
799
    '100', '0', '', '600', '0',
Lines 793-798 is( AddModificationTemplateAction( Link Here
793
), 1, 'Action 4: Move subfield 100$0 to 600$0');
803
), 1, 'Action 4: Move subfield 100$0 to 600$0');
794
804
795
# Copy subfield 600$0 to 100$0
805
# Copy subfield 600$0 to 100$0
806
# Copy subfield adds to existing fields if found, so we get two 100$0 on the original field
796
is( AddModificationTemplateAction(
807
is( AddModificationTemplateAction(
797
    $template_id, 'copy_field', 0,
808
    $template_id, 'copy_field', 0,
798
    '600', '0', '', '100', '0',
809
    '600', '0', '', '100', '0',
Lines 802-807 is( AddModificationTemplateAction( Link Here
802
), 1, 'Action 5: Copy subfield 600$0 to 100$0');
813
), 1, 'Action 5: Copy subfield 600$0 to 100$0');
803
814
804
# Copy and replace subfield 245$0 to 700$0
815
# Copy and replace subfield 245$0 to 700$0
816
# Copy and replace in this case makes a new 700$0 as it wasn't there
805
is( AddModificationTemplateAction(
817
is( AddModificationTemplateAction(
806
    $template_id, 'copy_and_replace_field', 0,
818
    $template_id, 'copy_and_replace_field', 0,
807
    '245', '0', '', '700', '0',
819
    '245', '0', '', '700', '0',
Lines 811-816 is( AddModificationTemplateAction( Link Here
811
), 1, 'Action 6: Copy and replace subfield 245$0 to 700$0');
823
), 1, 'Action 6: Copy and replace subfield 245$0 to 700$0');
812
824
813
# Copy subfield 590$0 to 690$0
825
# Copy subfield 590$0 to 690$0
826
# Copies the single subfield from 590 to a new 690
814
is( AddModificationTemplateAction(
827
is( AddModificationTemplateAction(
815
    $template_id, 'copy_field', 0,
828
    $template_id, 'copy_field', 0,
816
    '590', '0', '', '690', '0',
829
    '590', '0', '', '690', '0',
Lines 819-826 is( AddModificationTemplateAction( Link Here
819
    'Action 7: Copy subfield 590$0 to 690$0'
832
    'Action 7: Copy subfield 590$0 to 690$0'
820
), 1, 'Action 7: Copy subfield 590$0 to 690$0');
833
), 1, 'Action 7: Copy subfield 590$0 to 690$0');
821
834
835
# Copy subfield 590$a to 690$a
836
# Copy subfield adds to existing 690 a new subfield a
837
is( AddModificationTemplateAction(
838
    $template_id, 'copy_field', 0,
839
    '590', 'a', '', '690', 'a',
840
    '', '', '',
841
    '', '', '', '', '', '',
842
    'Action 8: Copy subfield 690$a to 690$a'
843
), 1, 'Action 8: Copy subfield 690$a to 690$a');
844
845
846
# Copy field 590 to 690
847
# Copy field copies existing to a new 690, does not add to existing
848
is( AddModificationTemplateAction(
849
    $template_id, 'copy_field', 0,
850
    '590', '', '', '690', '',
851
    '', '', '',
852
    '', '', '', '', '', '',
853
    'Action 9: Copy subfield 590 to 690'
854
), 1, 'Action 9: Copy subfield 590 to 690');
855
822
my @actions_0 = GetModificationTemplateActions( $template_id );
856
my @actions_0 = GetModificationTemplateActions( $template_id );
823
is( @actions_0, 7, "7 actions are inserted");
857
is( @actions_0, 9, "9 actions are inserted");
824
858
825
ModifyRecordWithTemplate( $template_id, $record );
859
ModifyRecordWithTemplate( $template_id, $record );
826
my $expected_record_0 = expected_record_0();
860
my $expected_record_0 = expected_record_0();
827
- 

Return to bug 31644