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

(-)a/t/db_dependent/XSLT.t (-2 / +60 lines)
Lines 18-24 Link Here
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use MARC::Record;
20
use MARC::Record;
21
use Test::More tests => 3;
21
use Test::More tests => 4;
22
use Test::Warn;
22
use Test::Warn;
23
use t::lib::TestBuilder;
23
use t::lib::TestBuilder;
24
use t::lib::Mocks;
24
use t::lib::Mocks;
Lines 137-139 subtest 'buildKohaItemsNamespace status tests' => sub { Link Here
137
};
137
};
138
138
139
$schema->storage->txn_rollback;
139
$schema->storage->txn_rollback;
140
- 
140
141
subtest 'buildKohaItemsNamespace() including/omitting items tests' => sub {
142
143
    plan tests => 14;
144
145
    $schema->storage->txn_begin;
146
147
    my $biblio = $builder->build_sample_biblio;
148
149
    # Have two known libraries for testing purposes
150
    my $library_1 = $builder->build_object({ class => 'Koha::Libraries' });
151
    my $library_2 = $builder->build_object({ class => 'Koha::Libraries' });
152
153
    my $item_1 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber, library => $library_1->id });
154
    my $item_2 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber, library => $library_2->id });
155
156
    ## Test passing items_rs only
157
    my $xml = C4::XSLT::buildKohaItemsNamespace( $biblio->biblionumber, undef, $biblio->items );
158
159
    my $library_1_name = $library_1->branchname;
160
    my $library_2_name = $library_2->branchname;
161
162
    like( $xml, qr{<homebranch>$library_1_name</homebranch>}, '$item_1 present in the XML' );
163
    like( $xml, qr{<homebranch>$library_2_name</homebranch>}, '$item_2 present in the XML' );
164
165
    ## Test passing one item in hidden_items and items_rs
166
    $xml = C4::XSLT::buildKohaItemsNamespace( $biblio->biblionumber, [ $item_1->itemnumber ], $biblio->items );
167
168
    unlike( $xml, qr{<homebranch>$library_1_name</homebranch>}, '$item_1 not present in the XML' );
169
    like( $xml, qr{<homebranch>$library_2_name</homebranch>}, '$item_2 present in the XML' );
170
171
    ## Test passing both items in hidden_items and items_rs
172
    $xml = C4::XSLT::buildKohaItemsNamespace( $biblio->biblionumber, [ $item_1->itemnumber, $item_2->itemnumber ], $biblio->items );
173
174
    unlike( $xml, qr{<homebranch>$library_1_name</homebranch>}, '$item_1 not present in the XML' );
175
    unlike( $xml, qr{<homebranch>$library_2_name</homebranch>}, '$item_2 present in the XML' );
176
    is( $xml, '<items xmlns="http://www.koha-community.org/items"></items>', 'Empty XML' );
177
178
    ## Test passing both items in hidden_items and no items_rs
179
    $xml = C4::XSLT::buildKohaItemsNamespace( $biblio->biblionumber, [ $item_1->itemnumber, $item_2->itemnumber ] );
180
181
    unlike( $xml, qr{<homebranch>$library_1_name</homebranch>}, '$item_1 not present in the XML' );
182
    unlike( $xml, qr{<homebranch>$library_2_name</homebranch>}, '$item_2 present in the XML' );
183
    is( $xml, '<items xmlns="http://www.koha-community.org/items"></items>', 'Empty XML' );
184
185
    ## Test passing one item in hidden_items and items_rs
186
    $xml = C4::XSLT::buildKohaItemsNamespace( $biblio->biblionumber, [ $item_1->itemnumber ] );
187
188
    unlike( $xml, qr{<homebranch>$library_1_name</homebranch>}, '$item_1 not present in the XML' );
189
    like( $xml, qr{<homebranch>$library_2_name</homebranch>}, '$item_2 present in the XML' );
190
191
    ## Test not passing any param
192
    $xml = C4::XSLT::buildKohaItemsNamespace( $biblio->biblionumber );
193
194
    like( $xml, qr{<homebranch>$library_1_name</homebranch>}, '$item_1 present in the XML' );
195
    like( $xml, qr{<homebranch>$library_2_name</homebranch>}, '$item_2 present in the XML' );
196
197
    $schema->storage->txn_rollback;
198
};

Return to bug 28299