-
Notifications
You must be signed in to change notification settings - Fork 3
/
MarcLintTest.php
695 lines (674 loc) · 26.9 KB
/
MarcLintTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
<?php
/**
* MarcLint Test Class
*
* PHP version 7
*
* Copyright (C) The National Library of Finland 2020-2022.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category VuFind
* @package Tests
* @author Ere Maijala <ere.maijala@helsinki.fi>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development:testing:unit_tests Wiki
*/
namespace VuFind\Marc\Test;
use VuFind\Marc\MarcCollection;
use VuFind\Marc\MarcLint;
use VuFind\Marc\MarcReader;
/**
* MarcLint Test Class
*
* @category VuFind
* @package Tests
* @author Ere Maijala <ere.maijala@helsinki.fi>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development:testing:unit_tests Wiki
*/
class MarcLintTest extends \PHPUnit\Framework\TestCase
{
use Feature\FixtureTrait;
use Feature\ReflectionTrait;
/**
* Test check020 method
*
* @param string $expected Expected output
* @param string $input Input
*
* @dataProvider get020TestData
*
* @return void
*/
public function testCheck020($expected, $input)
{
$record = new MarcReader("<record>$input</record>");
$lint = new MarcLint();
$this->callMethod($lint, 'check020', [$record->getField('020'), $record]);
$this->assertEquals(
$expected,
$this->getProperty($lint, 'warnings')
);
}
/**
* Data provider for testCheck020
*
* @return array
*/
public static function get020TestData()
{
return [
[
['020: Subfield a has the wrong number of digits, 154879473.'],
// too few digits
'<datafield tag="020" ind1=" " ind2=" "><subfield code="a">154879473</subfield></datafield>',
],
[
['020: Subfield a has bad checksum, 1548794743.'],
// invalid checksum
'<datafield tag="020" ind1=" " ind2=" "><subfield code="a">1548794743</subfield></datafield>',
],
[
['020: Subfield a has the wrong number of digits, 15487947443.'],
// 11 digits
'<datafield tag="020" ind1=" " ind2=" "><subfield code="a">15487947443</subfield></datafield>',
],
[
['020: Subfield a has the wrong number of digits, 15487947443324.'],
// 14 digits
'<datafield tag="020" ind1=" " ind2=" "><subfield code="a">15487947443324</subfield></datafield>',
],
[
[],
// 13 digit valid
'<datafield tag="020" ind1=" " ind2=" "><subfield code="a">9781548794743</subfield></datafield>',
],
[
['020: Subfield a has bad checksum (13 digit), 9781548794745.'],
// 13 digit invalid
'<datafield tag="020" ind1=" " ind2=" "><subfield code="a">9781548794745</subfield></datafield>',
],
[
[],
// 10 digit valid with qualifier
'<datafield tag="020" ind1=" " ind2=" ">'
. '<subfield code="a">1548794740 (10 : good checksum)</subfield></datafield>',
],
[
['020: Subfield a has bad checksum, 1548794745 (10 : bad checksum).'],
// 10 digit invalid with qualifier
'<datafield tag="020" ind1=" " ind2=" ">'
. '<subfield code="a">1548794745 (10 : bad checksum)</subfield></datafield>',
],
[
['020: Subfield a may have invalid characters.'],
// 10 digit invalid with hyphens and qualifier
'<datafield tag="020" ind1=" " ind2=" ">'
. '<subfield code="a">1-54879-474-0 (hyphens and good checksum)</subfield></datafield>',
],
[
[
'020: Subfield a may have invalid characters.',
'020: Subfield a has bad checksum, 1-54879-474-5 (hyphens and bad checksum).',
],
// 10 digit invalid with hyphens and qualifier
'<datafield tag="020" ind1=" " ind2=" ">'
. '<subfield code="a">1-54879-474-5 (hyphens and bad checksum)</subfield></datafield>',
],
[
['020: Subfield a qualifier must be preceded by space, 1548794740(10 : unspaced qualifier).'],
// 10 valid without space before qualifier
'<datafield tag="020" ind1=" " ind2=" ">'
. '<subfield code="a">1548794740(10 : unspaced qualifier)</subfield></datafield>',
],
[
[
'020: Subfield a qualifier must be preceded by space, 1548794745(10 : '
. 'unspaced qualifier : bad checksum).',
'020: Subfield a has bad checksum, 1548794745(10 : unspaced qualifier : bad checksum).',
],
// 10 invalid without space before qualifier
'<datafield tag="020" ind1=" " ind2=" ">'
. '<subfield code="a">1548794745(10 : unspaced qualifier : bad checksum)</subfield></datafield>',
],
[
[],
// subfield z
'<datafield tag="020" ind1=" " ind2=" "><subfield code="z">1548794743</subfield></datafield>',
],
[
['020: Subfield z is numerically valid.'],
// subfield z with valid checsum
'<datafield tag="020" ind1=" " ind2=" "><subfield code="z">ISBN 1548794740</subfield></datafield>',
],
];
}
/**
* Test check041 method
*
* @param string $expected Expected output
* @param string $input Input
*
* @dataProvider get041TestData
*
* @return void
*/
public function testCheck041($expected, $input)
{
$record = new MarcReader("<record>$input</record>");
$lint = new MarcLint();
$this->callMethod($lint, 'check041', [$record->getField('041'), $record]);
$this->assertEquals(
$expected,
$this->getProperty($lint, 'warnings')
);
}
/**
* Data provider for testCheck041
*
* @return array
*/
public static function get041TestData()
{
return [
[
[
'041: Subfield _a, end (end), is not valid.',
'041: Subfield _a must be evenly divisible by 3 or exactly '
. 'three characters if ind2 is not 7, (span).',
'041: Subfield _h, far, may be obsolete.',
],
<<<EOT
<datafield tag="041" ind1="0" ind2=" ">
<subfield code="a">end</subfield> <!-- invalid -->
<subfield code="a">span</subfield> <!-- too long -->
<subfield code="h">far</subfield> <!-- obsolete -->
</datafield>
EOT,
],
[
[
'041: Subfield _a, endorviwo (end), is not valid.',
'041: Subfield _a, endorviwo (orv), is not valid.',
'041: Subfield _a, endorviwo (iwo), is not valid.',
'041: Subfield _a must be evenly divisible by 3 or exactly three characters if ind2 is not 7, '
. '(spanowpalasba).',
],
<<<EOT
<datafield tag="041" ind1="1" ind2=" ">
<subfield code="a">endorviwo</subfield> <!-- invalid -->
<subfield code="a">spanowpalasba</subfield> <!-- too long and invalid -->
</datafield>
EOT,
],
];
}
/**
* Test check043 method
*
* @return void
*/
public function testCheck043()
{
$xml = <<<EOT
<record>
<datafield tag="043" ind1=" " ind2=" ">
<subfield code="a">n-----</subfield> <!-- 6 chars vs. 7 -->
<subfield code="a">n-us----</subfield> <!-- 8 chars vs. 7 -->
<subfield code="a">n-ma-us</subfield> <!-- invalid code -->
<subfield code="a">e-ur-ai</subfield> <!-- obsolete code -->
<subfield code="c">us</subfield> <!-- subfield c -->
</datafield>
</record>
EOT;
$record = new MarcReader($xml);
$lint = new MarcLint();
$this->callMethod($lint, 'check043', [$record->getField('043'), $record]);
$this->assertEquals(
[
'043: Subfield _a must be exactly 7 characters, n-----',
'043: Subfield _a must be exactly 7 characters, n-us----',
'043: Subfield _a, n-ma-us, is not valid.',
'043: Subfield _a, e-ur-ai, may be obsolete.',
],
$this->getProperty($lint, 'warnings')
);
}
/**
* Test check245 method
*
* @param string $expected Expected output
* @param string $input Input
*
* @dataProvider get245TestData
*
* @return void
*/
public function testCheck245($expected, $input)
{
$record = new MarcReader("<record>$input</record>");
$lint = new MarcLint();
$this->callMethod($lint, 'check245', [$record->getField('245'), $record]);
$this->assertEquals(
$expected,
$this->getProperty($lint, 'warnings')
);
}
/**
* Data provider for testCheck245
*
* @return array
*/
public static function get245TestData()
{
return [
[
[],
'<datafield tag="245" ind1="0" ind2="0"><subfield code="a">Subfield a.</subfield></datafield>',
],
[
[
'245: Must have a subfield _a.',
'245: First subfield must be _a, but it is _b',
],
'<datafield tag="245" ind1="0" ind2="0"><subfield code="b">no subfield a.</subfield></datafield>',
],
[
['245: Must end with . (period).'],
'<datafield tag="245" ind1="0" ind2="0"><subfield code="a">No period at end</subfield></datafield>',
],
[
[
'245: MARC21 allows ? or ! as final punctuation but LCRI 1.0C, Nov. 2003 '
. '(LCPS 1.7.1 for RDA records), requires period.',
],
'<datafield tag="245" ind1="0" ind2="0">'
. '<subfield code="a">Other punctuation not followed by period!</subfield></datafield>',
],
[
[
'245: MARC21 allows ? or ! as final punctuation but LCRI 1.0C, Nov. 2003 '
. '(LCPS 1.7.1 for RDA records), requires period.',
],
'<datafield tag="245" ind1="0" ind2="0">'
. '<subfield code="a">Other punctuation not followed by period?</subfield></datafield>',
],
[
['245: Subfield _c must be preceded by /'],
'<datafield tag="245" ind1="0" ind2="0">'
. '<subfield code="a">Precedes sub c</subfield><subfield code="c">not preceded by space-slash.'
. '</subfield></datafield>',
],
[
['245: Subfield _c must be preceded by /'],
'<datafield tag="245" ind1="0" ind2="0"><subfield code="a">Precedes sub c/</subfield>'
. '<subfield code="c">not preceded by space-slash.</subfield></datafield>',
],
[
['245: Subfield _c initials should not have a space.'],
'<datafield tag="245" ind1="0" ind2="0"><subfield code="a">Precedes sub c /</subfield>'
. '<subfield code="c">initials in sub c B. B.</subfield></datafield>',
],
[
[],
'<datafield tag="245" ind1="0" ind2="0"><subfield code="a">Precedes sub c /</subfield>'
. '<subfield code="c">initials in sub c B.B. (no warning).</subfield></datafield>',
],
[
['245: Subfield _b should be preceded by space-colon, space-semicolon, or space-equals sign.'],
'<datafield tag="245" ind1="0" ind2="0"><subfield code="a">Precedes sub b</subfield>'
. '<subfield code="b">not preceded by proper punctuation.</subfield></datafield>',
],
[
['245: Subfield _b should be preceded by space-colon, space-semicolon, or space-equals sign.'],
'<datafield tag="245" ind1="0" ind2="0"><subfield code="a">Precedes sub b=</subfield>'
. '<subfield code="b">not preceded by proper punctuation.</subfield></datafield>',
],
[
['245: Subfield _b should be preceded by space-colon, space-semicolon, or space-equals sign.'],
'<datafield tag="245" ind1="0" ind2="0"><subfield code="a">Precedes sub b:</subfield>'
. '<subfield code="b">not preceded by proper punctuation.</subfield></datafield>',
],
[
['245: Subfield _b should be preceded by space-colon, space-semicolon, or space-equals sign.'],
'<datafield tag="245" ind1="0" ind2="0"><subfield code="a">Precedes sub b;</subfield>'
. '<subfield code="b">not preceded by proper punctuation.</subfield></datafield>',
],
[
[],
'<datafield tag="245" ind1="0" ind2="0"><subfield code="a">Precedes sub b =</subfield>'
. '<subfield code="b">preceded by proper punctuation.</subfield></datafield>',
],
[
[],
'<datafield tag="245" ind1="0" ind2="0"><subfield code="a">Precedes sub b :</subfield>'
. '<subfield code="b">preceded by proper punctuation.</subfield></datafield>',
],
[
[],
'<datafield tag="245" ind1="0" ind2="0"><subfield code="a">Precedes sub b ;</subfield>'
. '<subfield code="b">preceded by proper punctuation.</subfield></datafield>',
],
[
['245: Subfield _h should not be preceded by space.'],
'<datafield tag="245" ind1="0" ind2="0"><subfield code="a">Precedes sub h </subfield>'
. '<subfield code="h">[videorecording].</subfield></datafield>',
],
[
[],
'<datafield tag="245" ind1="0" ind2="0"><subfield code="a">Precedes sub h-- </subfield>'
. '<subfield code="h">[videorecording] :</subfield>'
. '<subfield code="b">with elipses dash before h.</subfield></datafield>',
],
[
['245: Subfield _h must have matching square brackets, videorecording :.'],
'<datafield tag="245" ind1="0" ind2="0"><subfield code="a">Precedes sub h-- </subfield>'
. '<subfield code="h">videorecording :</subfield>'
. '<subfield code="b">without brackets around GMD.</subfield></datafield>',
],
[
[],
'<datafield tag="245" ind1="0" ind2="0"><subfield code="a">Precedes sub n.</subfield>'
. '<subfield code="n">Number 1.</subfield></datafield>',
],
[
['245: Subfield _n must be preceded by . (period).'],
'<datafield tag="245" ind1="0" ind2="0"><subfield code="a">Precedes sub n</subfield>'
. '<subfield code="n">Number 2.</subfield></datafield>',
],
[
['245: Subfield _p must be preceded by , (comma) when it follows subfield _n.'],
'<datafield tag="245" ind1="0" ind2="0"><subfield code="a">Precedes sub n.</subfield>'
. '<subfield code="n">Number 3.</subfield><subfield code="p">Sub n has period not comma.</subfield>'
. '</datafield>',
],
[
[],
'<datafield tag="245" ind1="0" ind2="0"><subfield code="a">Precedes sub n.</subfield>'
. '<subfield code="n">Number 3,</subfield><subfield code="p">Sub n has comma.</subfield></datafield>',
],
[
[],
'<datafield tag="245" ind1="0" ind2="0"><subfield code="a">Precedes sub p.</subfield>'
. '<subfield code="p">Sub a has period.</subfield></datafield>',
],
[
['245: Subfield _p must be preceded by . (period) when it follows a subfield other than _n.'],
'<datafield tag="245" ind1="0" ind2="0"><subfield code="a">Precedes sub p</subfield>'
. '<subfield code="p">Sub a has no period.</subfield></datafield>',
],
[
['245: Non-filing indicator is non-numeric'],
'<datafield tag="245" ind1="0" ind2="a">'
. '<subfield code="a">Invalid filing indicator.</subfield></datafield>',
],
[
['245: First word, the, may be an article, check 2nd indicator (0).'],
'<datafield tag="245" ind1="0" ind2="0"><subfield code="a">The article.</subfield></datafield>',
],
[
[],
'<datafield tag="245" ind1="0" ind2="4"><subfield code="a">The article.</subfield></datafield>',
],
[
['245: First word, an, may be an article, check 2nd indicator (2).'],
'<datafield tag="245" ind1="0" ind2="2"><subfield code="a">An article.</subfield></datafield>',
],
[
['245: First word, l, may be an article, check 2nd indicator (0).'],
'<datafield tag="245" ind1="0" ind2="0"><subfield code="a">L'article.</subfield></datafield>',
],
[
['245: First word, a, does not appear to be an article, check 2nd indicator (2).'],
'<datafield tag="245" ind1="0" ind2="2"><subfield code="a">A la mode.</subfield></datafield>',
],
[
[],
'<datafield tag="245" ind1="0" ind2="5">'
. '<subfield code="a">The "quoted article".</subfield></datafield>',
],
[
[],
'<datafield tag="245" ind1="0" ind2="5">'
. '<subfield code="a">The (parenthetical article).</subfield></datafield>',
],
[
[],
'<datafield tag="245" ind1="0" ind2="6">'
. '<subfield code="a">(The) article in parentheses).</subfield></datafield>',
],
[
[],
'<datafield tag="245" ind1="0" ind2="9">'
. '<subfield code="a">"(The)" 'article' in quotes and parentheses).</subfield>'
. '</datafield>',
],
[
[],
'<datafield tag="245" ind1="0" ind2="5">'
. '<subfield code="a">[The supplied title].</subfield></datafield>',
],
[
[
'245: Must have a subfield _a.',
'245: Must end with . (period).',
'245: May have too few subfields.',
],
'<datafield tag="245" ind1="0" ind2="0"><subfield code="6">sub6</subfield></datafield>',
],
[
[
'245: Must end with . (period).',
'245: First subfield must be _6, but it is a',
],
'<datafield tag="245" ind1="0" ind2="0"><subfield code="a">Subfield a.</subfield>'
. '<subfield code="6">sub6</subfield></datafield>',
],
[
[
'245: Must have a subfield _a.',
'245: First subfield after subfield _6 must be _a, but it is _b',
'245: Subfield _b should be preceded by space-colon, space-semicolon, or space-equals sign.',
],
'<datafield tag="245" ind1="0" ind2="0"><subfield code="6">sub6</subfield>'
. '<subfield code="b">Subfield b.</subfield></datafield>',
],
];
}
/**
* Test field 880
*
* @return void
*/
public function test880()
{
$record = new MarcReader(
$this->getFixture('marc/lint/880.xml')
);
$expected = [
'245: Field is not repeatable.',
'880: No subfield 6.',
];
$lint = new MarcLint();
$this->assertEquals($expected, $lint->checkRecord($record));
}
/**
* Test records that cover the rest of the rules
*
* @return void
*/
public function testRecords()
{
$lint = new MarcLint();
$collection = new MarcCollection(
$this->getFixture('marc/lint/camel.mrc')
);
$expected = [
'100: Indicator 1 must be 0, 1 or 3 but it\'s "2"',
];
$warnings = [];
foreach ($collection as $record) {
$warnings = array_merge($warnings, $lint->checkRecord($record));
}
$this->assertEquals($expected, array_filter($warnings));
$record = new MarcReader(
$this->getFixture('marc/lint/record2.xml')
);
$expected = [
'1XX: Only one 1XX tag is allowed, but I found 2 of them.',
'041: Subfield _a, end (end), is not valid.',
'041: Subfield _a must be evenly divisible by 3 or exactly three characters if ind2 is not 7, (fren).',
'043: Subfield _a, n-us-pn, is not valid.',
'082: Subfield _R is not allowed.',
'100: Indicator 2 must be blank but it\'s "4"',
'245: Indicator 1 must be 0 or 1 but it\'s "9"',
'245: Subfield _a is not repeatable.',
'260: Subfield _r is not allowed.',
'856: Indicator 2 must be blank, 0, 1, 2 or 8 but it\'s "3"',
];
$this->assertEquals($expected, $lint->checkRecord($record));
$marc = $this->getFixture('marc/lint/record3.xml');
$reader = new \VuFind\Marc\MarcReader($marc);
$expected = [
'1XX: Only one 1XX tag is allowed, but I found 4 of them.',
'245: No 245 tag.',
'009: Subfields are not allowed in fields lower than 010',
'100: Subfield _a is not repeatable.',
'100: Subfield _a has an invalid control character',
'110: Field is not repeatable.',
'130: Indicator 1 must be 0, 1, 2, 3, 4, 5, 6, 7, 8 or 9 but it\'s "blank"',
'130: Indicator 2 must be blank but it\'s "1"',
'240: Subfield _b is not allowed.',
];
$this->assertEquals($expected, $lint->checkRecord($reader));
}
/**
* Test checkArticle method
*
* @param string $expected Expected output
* @param string $input Input
*
* @dataProvider getCheckArticleTestData
*
* @return void
*/
public function testCheckArticle($expected, $input)
{
$record = new MarcReader("<record>{$input['data']}</record>");
$lint = new MarcLint();
$this->callMethod(
$lint,
'checkArticle',
[
$record->getField($input['tag']),
$record,
]
);
$this->assertEquals(
$expected,
$this->getProperty($lint, 'warnings')
);
}
/**
* Data provider for testCheck041
*
* @return array
*/
public static function getCheckArticleTestData()
{
return [
[
[],
[
'tag' => '130',
'data' => '<datafield tag="130" ind1="0" ind2=" "><subfield code="a">Foo</subfield></datafield>',
],
],
[
['130: Non-filing indicator is out of range'],
[
'tag' => '130',
'data' => '<datafield tag="130" ind1="5" ind2=" "><subfield code="a">Foo</subfield></datafield>',
],
],
[
['130: Non-filing indicator is non-numeric'],
[
'tag' => '130',
'data' => '<datafield tag="130" ind1=" " ind2=" "><subfield code="a">Foo</subfield></datafield>',
],
],
[
['Internal error: 650 is not a valid field for article checking'],
[
'tag' => '650',
'data' => '<datafield tag="650" ind1=" " ind2=" "><subfield code="a">Foo</subfield></datafield>',
],
],
];
}
/**
* Test parsing of rules
*
* @return void
*/
public function testRuleParsing()
{
$lint = new \VuFind\Marc\MarcLint();
// Test rule parsing for a range of subfields:
$ruleGroup = [
'999 R LOCAL',
'ind1 0-9 Undefined',
'ind2 0-9 Undefined',
'a-c R Undefined',
];
$expected = [
'repeatable' => '',
'desc' => '',
'ind1' => [
'values' => '',
'hr_values' => '',
'desc' => '',
],
'ind2' => [
'values' => '',
'hr_values' => '',
'desc' => '',
],
'suba' => [
'repeatable' => '',
'desc' => '',
],
'subb' => [
'repeatable' => '',
'desc' => '',
],
'subc' => [
'repeatable' => '',
'desc' => '',
],
];
$lint = new \VuFind\Marc\MarcLint();
$this->CallMethod(
$lint,
'processRuleGroup',
[
$ruleGroup,
]
);
$rules = $this->getProperty($lint, 'rules');
$this->assertEquals($expected, $rules['999']);
}
}