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

(-)a/t/db_dependent/Koha/Filter/ExpandCodedFields.t (-2 / +30 lines)
Lines 35-48 my $builder = t::lib::TestBuilder->new(); Link Here
35
35
36
subtest 'ExpandCodedFields tests' => sub {
36
subtest 'ExpandCodedFields tests' => sub {
37
37
38
    plan tests => 10;
38
    plan tests => 16;
39
39
40
    $schema->storage->txn_begin();
40
    $schema->storage->txn_begin();
41
41
42
    # Add libraries
43
    my $homebranch    = $builder->build_object( { class => 'Koha::Libraries' } );
44
    my $holdingbranch = $builder->build_object( { class => 'Koha::Libraries' } );
45
46
    diag("Homebranch: " . $homebranch->branchcode . " : " . $homebranch->branchname);
47
    # Add itemtypes
48
    my $itemtype = $builder->build_object( { class => 'Koha::ItemTypes' } );
49
42
    # Add a biblio
50
    # Add a biblio
43
    my $biblio = $builder->build_sample_biblio;
51
    my $biblio = $builder->build_sample_biblio;
44
    my $record = $biblio->metadata->record;
52
    my $record = $biblio->metadata->record;
53
54
    # Suppress the record to test that suppression is never expanded
45
    $record->field('942')->update( n => 1 );
55
    $record->field('942')->update( n => 1 );
56
57
    # Add an AV ended field to test for AV expansion
46
    $record->append_fields(
58
    $record->append_fields(
47
        MARC::Field->new( '590', '', '', a => 'CODE' ),
59
        MARC::Field->new( '590', '', '', a => 'CODE' ),
48
    );
60
    );
Lines 66-73 subtest 'ExpandCodedFields tests' => sub { Link Here
66
    $biblio = Koha::Biblios->find( $biblio->biblionumber);
78
    $biblio = Koha::Biblios->find( $biblio->biblionumber);
67
    $record = $biblio->metadata->record;
79
    $record = $biblio->metadata->record;
68
80
81
    # Embed an item to test for branchcode and itemtype expansions
82
    $record->append_fields(
83
        MARC::Field->new(
84
            '952', '', '',
85
            a => $homebranch->branchcode,
86
            b => $holdingbranch->branchcode,
87
            y => $itemtype->itemtype
88
        ),
89
    );
90
91
69
    is( $record->field('590')->subfield('a'), 'CODE', 'Record prior to filtering contains AV Code' );
92
    is( $record->field('590')->subfield('a'), 'CODE', 'Record prior to filtering contains AV Code' );
70
    is( $record->field('942')->subfield('n'), 1, 'Record suppression is numeric prior to filtering' );
93
    is( $record->field('942')->subfield('n'), 1, 'Record suppression is numeric prior to filtering' );
94
    is( $record->field('952')->subfield('a'), $homebranch->branchcode, 'Record prior to filtering contains homebranch branchcode' );
95
    is( $record->field('952')->subfield('b'), $holdingbranch->branchcode, 'Record prior to filtering contains holdingbranch branchcode' );
96
    is( $record->field('952')->subfield('y'), $itemtype->itemtype, 'Record prior to filtering contains itemtype code' );
71
97
72
    my $processor = Koha::RecordProcessor->new(
98
    my $processor = Koha::RecordProcessor->new(
73
        {
99
        {
Lines 82-87 subtest 'ExpandCodedFields tests' => sub { Link Here
82
    is( $result->field('590')->subfield('a'), 'Description should show OPAC', 'Returned record contains AV OPAC description (interface defaults to opac)' );
108
    is( $result->field('590')->subfield('a'), 'Description should show OPAC', 'Returned record contains AV OPAC description (interface defaults to opac)' );
83
    is( $record->field('590')->subfield('a'), 'Description should show OPAC', 'Original record now contains AV OPAC description (interface defaults to opac)' );
109
    is( $record->field('590')->subfield('a'), 'Description should show OPAC', 'Original record now contains AV OPAC description (interface defaults to opac)' );
84
    is( $record->field('942')->subfield('n'), 1, 'Record suppression is still numeric after filtering' );
110
    is( $record->field('942')->subfield('n'), 1, 'Record suppression is still numeric after filtering' );
111
    is( $record->field('952')->subfield('a'), $homebranch->branchname, 'Record now contains homebranch branchname' );
112
    is( $record->field('952')->subfield('b'), $holdingbranch->branchname, 'Record now contains holdingbranch branchname' );
113
    is( $record->field('952')->subfield('y'), $itemtype->description, 'Record now contains itemtype description' );
85
114
86
    # reset record for next test
115
    # reset record for next test
87
    $record = $biblio->metadata->record;
116
    $record = $biblio->metadata->record;
88
- 

Return to bug 30848