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

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

Return to bug 28299