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 => 20; |
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 |
my $library_3 = $builder->build_object({ class => 'Koha::Libraries' }); |
153 |
|
154 |
my $item_1 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber, library => $library_1->id }); |
155 |
my $item_2 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber, library => $library_2->id }); |
156 |
my $item_3 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber, library => $library_3->id }); |
157 |
|
158 |
my $items_rs = $biblio->items->search({ "me.itemnumber" => { '!=' => $item_3->itemnumber } }); |
159 |
|
160 |
## Test passing items_rs only |
161 |
my $xml = C4::XSLT::buildKohaItemsNamespace( $biblio->biblionumber, undef, $items_rs ); |
162 |
|
163 |
my $library_1_name = $library_1->branchname; |
164 |
my $library_2_name = $library_2->branchname; |
165 |
my $library_3_name = $library_3->branchname; |
166 |
|
167 |
like( $xml, qr{<homebranch>$library_1_name</homebranch>}, '$item_1 present in the XML' ); |
168 |
like( $xml, qr{<homebranch>$library_2_name</homebranch>}, '$item_2 present in the XML' ); |
169 |
unlike( $xml, qr{<homebranch>$library_3_name</homebranch>}, '$item_3 not present in the XML' ); |
170 |
## Test passing one item in hidden_items and items_rs |
171 |
$xml = C4::XSLT::buildKohaItemsNamespace( $biblio->biblionumber, [ $item_1->itemnumber ], $items_rs->reset ); |
172 |
|
173 |
unlike( $xml, qr{<homebranch>$library_1_name</homebranch>}, '$item_1 not present in the XML' ); |
174 |
like( $xml, qr{<homebranch>$library_2_name</homebranch>}, '$item_2 present in the XML' ); |
175 |
unlike( $xml, qr{<homebranch>$library_3_name</homebranch>}, '$item_3 not present in the XML' ); |
176 |
|
177 |
## Test passing both items in hidden_items and items_rs |
178 |
$xml = C4::XSLT::buildKohaItemsNamespace( $biblio->biblionumber, [ $item_1->itemnumber, $item_2->itemnumber ], $items_rs->reset ); |
179 |
|
180 |
unlike( $xml, qr{<homebranch>$library_1_name</homebranch>}, '$item_1 not present in the XML' ); |
181 |
unlike( $xml, qr{<homebranch>$library_2_name</homebranch>}, '$item_2 not present in the XML' ); |
182 |
unlike( $xml, qr{<homebranch>$library_3_name</homebranch>}, '$item_3 not present in the XML' ); |
183 |
is( $xml, '<items xmlns="http://www.koha-community.org/items"></items>', 'Empty XML' ); |
184 |
|
185 |
## Test passing both items in hidden_items and no items_rs |
186 |
$xml = C4::XSLT::buildKohaItemsNamespace( $biblio->biblionumber, [ $item_1->itemnumber, $item_2->itemnumber, $item_3->itemnumber ] ); |
187 |
|
188 |
unlike( $xml, qr{<homebranch>$library_1_name</homebranch>}, '$item_1 not present in the XML' ); |
189 |
unlike( $xml, qr{<homebranch>$library_2_name</homebranch>}, '$item_2 not present in the XML' ); |
190 |
unlike( $xml, qr{<homebranch>$library_3_name</homebranch>}, '$item_3 not present in the XML' ); |
191 |
is( $xml, '<items xmlns="http://www.koha-community.org/items"></items>', 'Empty XML' ); |
192 |
|
193 |
## Test passing one item in hidden_items and items_rs |
194 |
$xml = C4::XSLT::buildKohaItemsNamespace( $biblio->biblionumber, [ $item_1->itemnumber ] ); |
195 |
|
196 |
unlike( $xml, qr{<homebranch>$library_1_name</homebranch>}, '$item_1 not present in the XML' ); |
197 |
like( $xml, qr{<homebranch>$library_2_name</homebranch>}, '$item_2 present in the XML' ); |
198 |
like( $xml, qr{<homebranch>$library_3_name</homebranch>}, '$item_3 present in the XML' ); |
199 |
|
200 |
## Test not passing any param |
201 |
$xml = C4::XSLT::buildKohaItemsNamespace( $biblio->biblionumber ); |
202 |
|
203 |
like( $xml, qr{<homebranch>$library_1_name</homebranch>}, '$item_1 present in the XML' ); |
204 |
like( $xml, qr{<homebranch>$library_2_name</homebranch>}, '$item_2 present in the XML' ); |
205 |
like( $xml, qr{<homebranch>$library_3_name</homebranch>}, '$item_3 present in the XML' ); |
206 |
|
207 |
$schema->storage->txn_rollback; |
208 |
}; |