-
Notifications
You must be signed in to change notification settings - Fork 16
/
IXBRL-Tests.php
1174 lines (1020 loc) · 49.6 KB
/
IXBRL-Tests.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
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* XBRL Inline conformance suite test runner
* Supports v1, v2, v3 and v4
*
* Based on the implementation in Arelle
*
* @author Bill Seddon
* @version 0.9
* @Copyright (C) 2021 Lyquidity Solutions Limited
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 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, see <http://www.gnu.org/licenses/>.
*
*/
namespace lyquidity\ixbrl;
use XBRL_Dictionary;
define( 'IXBRL_TEST_ALL', 'all' );
define( 'IXBRL_TEST_ERRORS', 'errors' );
define( 'IXBRL_TEST_COMPARES', 'compares' );
/**
* Run all conformance tests
* @param string $cacheLocation
* @param string $$testCasesFolder
* @param array $testCategory
* @param bool $testClass
* @return void
*/
function TestInlineXBRL( $cacheLocation, $testCasesFolder, $testCategory, $testClass = IXBRL_TEST_ALL )
{
$log = \XBRL_Log::getInstance();
$mainDoc = new \DOMDocument();
if ( ! $mainDoc->load( "$testCasesFolder/index.xml" ) )
{
throw new IXBRLException('Failed to load the main test document');
}
$documentElement = $mainDoc->documentElement;
$log->info( "{$documentElement->localName}" );
$log->info( $documentElement->getAttribute('name') );
$outputFolder = "$testCasesFolder/output";
$xpath = new \DOMXPath( $mainDoc );
if ( is_dir( rtrim( $outputFolder,"/").'/' ) )
{
\XBRL_Global::removeFiles( $outputFolder );
}
if ( ! is_dir( rtrim( $outputFolder,"/").'/' ) )
if ( ! mkdir( $outputFolder ) )
{
throw new IXBRLTestCompareException("Unable to create folder '$outputFolder'");
}
foreach( $xpath->query( '//testcases', $documentElement ) as $testcases )
{
/** @var \DOMElement $testcases */
$log->info( $testcases->getAttribute('title') );
foreach( $xpath->query( 'testcase', $testcases ) as $tag => $testcase )
{
/** @var \DOMElement $element */
$testcaseDir = rtrim( "{$testCasesFolder}tests/" . dirname( $testcase->getAttribute('uri') ), '/' ). '/';
$testcaseFilename = basename( $testcase->getAttribute('uri') );
testCase( $testcaseDir, $testcaseFilename, $outputFolder, $cacheLocation, $testCategory, $testClass );
}
}
}
/**
* Execute a test case
* @param string $basename
* @param string $filename
* @param string $outputFolder
* @param string $cacheLocation
* @param array $testCategory
* @param bool $testClass
* @return boolean
*/
function testCase( $dirname, $filename, $outputFolder, $cacheLocation, $testCategory, $testClass = IXBRL_TEST_ALL )
{
$log = \XBRL_Log::getInstance();
list(
$baseURIs, $continuation, $exclude, $footnotes, $format, $fraction,
$fullSizeTests, $header, $hidden, $html, $ids, $multiIO, $nonFraction,
$nonNumeric, $references, $relationships, $resources, $specificationExamples,
$transformations, $tuple, $xmllang ) = array_values( $testCategory );
switch( $filename )
{
#region ./baseURIs - checked fail and pass tests and compares
case "FAIL-baseURI-on-ix-header.xml": // Checked - xbrl.core.xml.SchemaValidationError.cvc-complex-type_3_2_2, 1866, 1867
case "FAIL-baseURI-on-xhtml.xml": // Checked - xbrl.core.xml.SchemaValidationError.cvc-complex-type_3_2_2, 1866, 1867
case "PASS-baseURI-on-ix-references-multiRefs.xml":
#endregion
if ( $baseURIs ) break; else return;
#region ./continuation - checked fail and pass tests and compares
case "FAIL-continuation-duplicate-id.xml": // Checked
case "FAIL-continuation-nonNumeric-circular.xml": // Checked Dangling
case "FAIL-continuation-nonNumeric-circular2.xml": // Checked ContinuationReuse
case "FAIL-continuation-nonNumeric-invalid-nesting-2.xml": // Checked ContinuationInvalidNesting
case "FAIL-continuation-nonNumeric-invalid-nesting.xml": // Checked ContinuationInvalidNesting
case "FAIL-continuation-nonNumeric-self.xml": // Checked - DanglingContinuation
case "FAIL-continuation-orphaned-cycle.xml": // Checked UnreferencedContinuation
case "FAIL-continuation-used-twice.xml": // Checked ContinuationReuse
case "FAIL-footnote-continuation-invalid-nesting-2.xml": // Checked ContinuationInvalidNesting
case "FAIL-footnote-continuation-invalid-nesting.xml": // Checked - ContinuationInvalidNesting
case "FAIL-nonNumeric-dangling-continuation-2.xml": // Checked DanglingContinuation
case "FAIL-nonNumeric-dangling-continuation.xml": // Checked - DanglingContinuation
case "FAIL-orphaned-continuation.xml": // UnreferencedContinuation
case "PASS-nonNumeric-continuation-multiple-documents.xml":
case "PASS-nonNumeric-continuation-other-descendants-escaped.xml":
case "PASS-nonNumeric-continuation-other-descendants.xml":
case "PASS-nonNumeric-continuation-out-of-order.xml":
case "PASS-nonNumeric-continuation-transform.xml":
case "PASS-nonNumeric-continuation.xml":
#endregion
if ( $continuation ) break; else return;
#region ./exclude - checked fail and pass tests and compares
case "FAIL-exclude-nonFraction-parent.xml": // Checked - xbrl.core.xml.SchemaValidationError.cvc-complex-type_2_4_a, 1871
case "FAIL-misplaced-exclude.xml": // Checked - MisplacedExclude
case "PASS-element-ix-exclude-complete.xml":
case "PASS-exclude-nonNumeric-parent.xml":
case "PASS-multiple-excludes-nonNumeric-parent.xml":
#endregion
if ( $exclude ) break; else return;
#region ./footnotes - checked fail and pass tests and compares
case "FAIL-element-ix-footnote-04.xml": // Checked DuplicateId
case "FAIL-footnote-any-attribute.xml": // Checked xbrl.core.xml.SchemaValidationError.cvc-complex-type_3_2_2
case "FAIL-footnote-dangling-continuation.xml": // Checked DanglingContinuation
case "FAIL-footnote-dangling-fromRef.xml": // Checked DanglingRelationshipFromRef
case "FAIL-footnote-dangling-toRef.xml": // Checked DanglingRelationshipToRef
case "FAIL-footnote-duplicate-footnoteIDs-different-input-docs.xml": // Checked DuplicateId
case "FAIL-footnote-duplicate-footnoteIDs.xml": // Checked DuplicateId
case "FAIL-footnote-invalid-element-content.xml": // Checked xbrl.core.xml.SchemaValidationError.cvc-complex-type_2_4_a, 1871
case "FAIL-footnote-missing-footnoteID.xml": // Checked xbrl.core.xml.SchemaValidationError.cvc-complex-type_4, 1868
case "PASS-element-ix-footnote-03.xml":
case "PASS-element-link-footnote-02.xml":
case "PASS-element-link-footnote-complete-role-defs.xml":
case "PASS-element-link-footnote-complete.xml":
case "PASS-element-link-footnote-footnoteArcrole-2.xml":
case "PASS-element-link-footnote-footnoteArcrole.xml":
case "PASS-element-link-footnote-footnoteLinkRole-2.xml":
case "PASS-element-link-footnote-footnoteLinkRole.xml":
case "PASS-element-link-footnote-footnoteRole-2.xml":
case "PASS-element-link-footnote-footnoteRole.xml":
case "PASS-element-link-footnote-nonNumeric-escaped.xml":
case "PASS-element-link-footnote-nonNumeric-unescaped.xml":
case "PASS-element-link-footnote-nothidden.xml":
case "PASS-element-link-footnote-resolved-uris.xml":
case "PASS-element-link-footnote-xhtml-content-exclude.xml":
case "PASS-element-link-footnote-xhtml-content.xml":
case "PASS-elements-footnote-and-nonNumeric-unresolvable-uris-in-exclude.xml":
case "PASS-footnote-any-attribute.xml":
case "PASS-footnote-continuation.xml":
case "PASS-footnote-footnoteLinkRole-multiple-output.xml":
case "PASS-footnote-footnoteRole-multiple-output.xml":
case "PASS-footnote-ix-element-content.xml":
case "PASS-footnote-ix-exclude-content.xml":
case "PASS-footnote-nested-ix-element-content.xml":
case "PASS-footnote-nested-xml-base-decls.xml":
case "PASS-footnote-on-nonFraction.xml":
case "PASS-footnote-order-attribute.xml":
case "PASS-footnote-relative-uris-object-tag.xml":
case "PASS-footnote-uris-with-spaces.xml":
case "PASS-footnote-valid-element-content.xml":
case "PASS-footnote-within-footnote.xml":
case "PASS-footnote-xml-base-xhtml-base-no-interaction.xml":
case "PASS-footnoteArcrole-multiple-output.xml":
case "PASS-footnoteRef-on-fraction.xml":
case "PASS-footnoteRef-on-nonNumeric.xml":
case "PASS-footnoteRef-on-tuple.xml":
case "PASS-many-to-one-footnote-complete.xml":
case "PASS-many-to-one-footnote-different-arcroles.xml":
case "PASS-many-to-one-footnotes-multiple-outputs.xml":
case "PASS-multiple-outputs-check-dont-have-empty-footnoteLinks.xml":
case "PASS-two-footnotes-multiple-output.xml":
case "PASS-unused-footnote.xml":
#endregion
if ( $footnotes ) break; else return;
#region ./format - checked fail and pass tests compares
case "FAIL-format-numdash-badContent.xml": // Checked - InvalidDataType
case "FAIL-ix-format-undefined.xml": // Checked - FormatUndefined
case "PASS-element-ix-nonFraction-ixt-num-nodecimals.xml":
case "PASS-format-numdash.xml":
#endregion
if ( $format ) break; else return;
#region ./fraction - checked fail and pass tests and compares
case "FAIL-fraction-denominator-empty.xml": // Checked - xbrl.core.xml.SchemaValidationError.cvc-minLength-valid, 1831
case "FAIL-fraction-denominator-illegal-child-node.xml": // Checked - xbrl.core.xml.SchemaValidationError.cvc-complex-type_2_2, 1842
case "FAIL-fraction-denominator-ix-format-expanded-name-mismatch.xml": // Checked - FormatUndefined
case "FAIL-fraction-denominator-ix-format-invalid.xml": // Checked - InvalidDataType
case "FAIL-fraction-denominator-ix-sign-invalid.xml": // Checked - UnknownFractionChild
case "FAIL-fraction-illegal-content.xml": // Checked - UnknownFractionChild
case "FAIL-fraction-illegal-nesting-unitRef.xml": // Checked - FractionNestedAttributeMismatch
case "FAIL-fraction-illegal-nesting-xsi-nil-2.xml": // Checked - FractionNestedNilMismatch
case "FAIL-fraction-illegal-nesting-xsi-nil.xml": // Checked - FractionNestedNilMismatch
case "FAIL-fraction-illegal-nesting.xml": // Checked - MultipleNumeratorDenominator
case "FAIL-fraction-ix-any-attribute.xml": // Checked - xbrl.core.xml.SchemaValidationError.cvc-complex-type_3_2_2, 1867
case "FAIL-fraction-ix-contextRef-unresolvable.xml": // Checked - UnknownContext
case "FAIL-fraction-ix-footnoteRef-unresolvable.xml": // Checked - DanglingRelationshipToRef
case "FAIL-fraction-ix-tupleRef-attr-tuple-missing.xml": // Checked - UnknownTuple
case "FAIL-fraction-ix-unitRef-unresolvable.xml": // Checked - UnknownUnit
case "FAIL-fraction-missing-contextRef.xml": // Checked - xbrl.core.xml.SchemaValidationError.cvc-complex-type_4, 1868
case "FAIL-fraction-missing-denominator.xml": // Checked - IncompleteFraction
case "FAIL-fraction-missing-numerator-and-denominator.xml": // Checked - IncompleteFraction
case "FAIL-fraction-missing-numerator.xml": // Checked - IncompleteFraction
case "FAIL-fraction-missing-unitRef.xml": // Checked - xbrl.core.xml.SchemaValidationError.cvc-complex-type_4, 1868
case "FAIL-fraction-multiple-denominators.xml": // Checked - MultipleNumeratorDenominator
case "FAIL-fraction-multiple-numerators.xml": // Checked - MultipleNumeratorDenominator
case "FAIL-fraction-numerator-denominator-non-xsi-attributes.xml": // Checked - xbrl.core.xml.SchemaValidationError.cvc-complex-type_3_2_2, 1866, 1867
case "FAIL-fraction-numerator-empty.xml": // xbrl.core.xml.SchemaValidationError.cvc-minLength-valid, 1831
case "FAIL-fraction-numerator-illegal-child-node.xml": // xbrl.core.xml.SchemaValidationError.cvc-complex-type_2_2, 1842,
case "FAIL-fraction-numerator-ix-format-expanded-name-mismatch.xml": // Checked - FormatUndefined
case "FAIL-fraction-numerator-ix-format-invalid.xml": // Checked - InvalidDataType
case "FAIL-fraction-numerator-ix-sign-invalid.xml": // Checked - xbrl.core.xml.SchemaValidationError.cvc-pattern-valid, 1839
case "FAIL-fraction-rule-no-other-ixDescendants.xml": // Checked - UnknownFractionChild
case "FAIL-fraction-rule-no-xbrli-attributes.xml": // Checked - InvalidAttributeContent
case "PASS-attribute-ix-format-denominator-01.xml":
case "PASS-attribute-ix-format-numerator-01.xml":
case "PASS-attribute-ix-name-fraction-01.xml":
case "PASS-attribute-ix-scale-denominator-01.xml":
case "PASS-attribute-ix-scale-denominator-04.xml":
case "PASS-attribute-ix-scale-numerator-01.xml":
case "PASS-attribute-ix-scale-numerator-04.xml":
case "PASS-attribute-ix-sign-denominator-01.xml":
case "PASS-attribute-ix-sign-numerator-01.xml":
case "PASS-fraction-denominator-ix-format-expanded-name-match.xml":
case "PASS-fraction-denominator-ix-format.xml":
case "PASS-fraction-denominator-ix-sign-scale-valid.xml":
case "PASS-fraction-ix-order-attr.xml":
case "PASS-fraction-ix-target-attr.xml":
case "PASS-fraction-ix-tupleRef-attr.xml":
case "PASS-fraction-nesting-2.xml":
case "PASS-fraction-nesting-3.xml":
case "PASS-fraction-nesting-4.xml":
case "PASS-fraction-nesting.xml":
case "PASS-fraction-non-ix-any-attribute.xml":
case "PASS-fraction-numerator-denominator-xsi-attributes.xml":
case "PASS-fraction-numerator-ix-format-expanded-name-match.xml":
case "PASS-fraction-numerator-ix-format.xml":
case "PASS-fraction-numerator-ix-sign-valid.xml":
case "PASS-fraction-xsi-nil.xml":
case "PASS-ix-denominator-01.xml":
case "PASS-ix-denominator-02.xml":
case "PASS-ix-denominator-03.xml":
case "PASS-ix-denominator-04.xml":
case "PASS-simple-fraction.xml":
case "PASS-ix-numerator-04.xml":
case "PASS-simple-fraction-with-html-children.xml":
#endregion
if ( $fraction ) break; else return;
#region ./fullSizeTests - no fail tests passes compares
case "PASS-full-size-unnested-tuples.xml":
case "PASS-full-size-with-footnotes.xml":
case "PASS-largeTestNoMarkup.xml":
#endregion
if ( $fullSizeTests ) break; else return;
#region ./header - checked fail and pass tests and compares
case "FAIL-ix-header-child-of-html-header.xml": // Checked
case "FAIL-misplaced-ix-element-in-context.xml": // Checked - MisplacedIXElement
case "FAIL-missing-header.xml": // Checked HeaderAbsent, ReferencesAbsent, ResourcesAbsent
case "PASS-header-content-split-over-input-docs.xml":
case "PASS-header-empty.xml":
case "PASS-single-ix-header-muli-input.xml":
#endregion
if ( $header ) break; else return;
#region ./hidden - checked fail and pass tests and compares
case "FAIL-empty-hidden.xml": // Checked - xbrl.core.xml.SchemaValidationError.cvc-complex-type_2_4_b, 1871
case "FAIL-hidden-empty-tuple-content.xml": // Checked - TupleNonEmptyValidation
case "FAIL-hidden-illegal-content.xml": // Checked - xbrl.core.xml.SchemaValidationError.cvc-complex-type_2_4_a, 1871
case "FAIL-hidden-incorrect-order-in-header.xml": // Checked - xbrl.core.xml.SchemaValidationError.cvc-complex-type_2_4_d, 1871
case "FAIL-hidden-not-header-descendant.xml": // Checked xbrl.core.xml.SchemaValidationError.cvc-complex-type_2_4_a, 1871
case "PASS-hidden-nonFraction-content.xml":
case "PASS-hidden-tuple-content.xml":
#endregion
if ( $hidden ) break; else return;
#region ./html - checked fail tests (no pass/compare tests)
case "FAIL-a-name-attribute.xml": // Checked xbrl.core.xml.SchemaValidationError.cvc-complex-type_3_2_2, 1866
case "FAIL-charset-on-meta.xml": // Checked xbrl.core.xml.SchemaValidationError.cvc-complex-type_3_2_2, 1866, xbrl.core.xml.SchemaValidationError.cvc-complex-type_4, 1866
case "FAIL-empty-class-attribute.xml": // Checked xbrl.core.xml.SchemaValidationError.cvc-minLength-valid, xbrl.core.xml.SchemaValidationError.cvc-attribute_3
#endregion
if ( $html ) break; else return;
#region ./ids - checked fail tests (no pass/compare tests)
case "FAIL-id-triplication.xml": // Checked DuplicateId
case "FAIL-non-unique-id-context.xml": // Checked DuplicateId
case "FAIL-non-unique-id-footnote.xml": // Checked DuplicateId
case "FAIL-non-unique-id-fraction.xml": // Checked DuplicateId
case "FAIL-non-unique-id-nonFraction.xml": // Checked DuplicateId
case "FAIL-non-unique-id-nonNumeric.xml": // Checked DuplicateId
case "FAIL-non-unique-id-references.xml": // Checked DuplicateId
case "FAIL-non-unique-id-tuple.xml": // Checked DuplicateId
case "FAIL-non-unique-id-unit.xml": // Checked DuplicateId
#endregion
if ( $ids ) break; else return;
#region ./multiIO - checked fail and pass tests and compares
case "FAIL-multi-input-duplicate-context-ids.xml": // Checked - DuplicateId
case "FAIL-multi-input-duplicate-unit-ids.xml": // Checked - DuplicateId
case "FAIL-two-inputs-each-with-error.xml": // Checked - UnknownContext
case "FAIL-two-nonIXBRL-inputs.xml": // Checked - UnsupportedDocumentType
case "PASS-double-input-single-output.xml":
case "PASS-ix-references-06.xml":
case "PASS-ix-references-07.xml":
case "PASS-multiple-input-multiple-output.xml":
case "PASS-single-input-double-output.xml":
case "PASS-single-input.xml":
#endregion
if ( $multiIO ) break; else return;
#region ./nonFraction - checked fail and pass tests and compares
case "FAIL-nonFraction-IXBRLelement-content.xml": // Checked - NonFractionChildElementMixed
case "FAIL-nonFraction-any-ix-attribute.xml": // Checked - xbrl.core.xml.SchemaValidationError.cvc-complex-type_3_2_2, 1866, 1867, 1866, 1867
case "FAIL-nonFraction-decimals-and-precision-attrs.xml": // Checked - PrecisionAndDecimalsPresent
case "FAIL-nonFraction-double-nesting.xml": // Checked - brl.core.xml.SchemaValidationError.cvc-complex-type_2_4_d, 1871
case "FAIL-nonFraction-empty-content.xml": // Checked - NonFractionIncompleteContent
case "FAIL-nonFraction-empty-without-xsi-nil.xml": // Checked - NonFractionIncompleteContent
case "FAIL-nonFraction-invalid-sign-attr.xml": // Checked - xml.SchemaValidationError.cvc-pattern-valid, xbrl.core.xml.SchemaValidationError.cvc-attribute_3, 1839
case "FAIL-nonFraction-ix-format-expanded-name-mismatch.xml": // Checked - FormatUndefined
case "FAIL-nonFraction-ix-format-invalid-minus-sign.xml": // Checked - InvalidDataType
case "FAIL-nonFraction-ix-format-invalid.xml": // Checked - InvalidDataType
case "FAIL-nonFraction-missing-context-attr.xml": // Checked - xbrl.core.xml.SchemaValidationError.cvc-complex-type_4, 1868
case "FAIL-nonFraction-missing-name-attr.xml": // Checked - xbrl.core.xml.SchemaValidationError.cvc-complex-type_4, 1868
case "FAIL-nonFraction-missing-unit-attr.xml": // Checked - xbrl.core.xml.SchemaValidationError.cvc-complex-type_4, 1868
case "FAIL-nonFraction-mixed-nesting-2.xml": // Checked - NonFractionChildElementMixed
case "FAIL-nonFraction-mixed-nesting-3.xml": // Checked - xbrl.core.xml.SchemaValidationError.cvc-complex-type_2_4_a, 1871
case "FAIL-nonFraction-mixed-nesting.xml": // Checked - NonFractionChildElementMixed
case "FAIL-nonFraction-neither-decimals-nor-precision-attrs.xml": // Checked - PrecisionAndDecimalsAbsent
case "FAIL-nonFraction-nesting-format-mismatch-2.xml": // Checked - NonFractionNestedAttributeMismatch
case "FAIL-nonFraction-nesting-format-mismatch.xml": // Checked - NonFractionNestedAttributeMismatch
case "FAIL-nonFraction-nesting-scale-mismatch-2.xml": // Checked - NonFractionNestedAttributeMismatch
case "FAIL-nonFraction-nesting-scale-mismatch.xml": // Checked - NonFractionNestedAttributeMismatch
case "FAIL-nonFraction-nesting-unitRef-mismatch.xml": // Checked - NonFractionNestedAttributeMismatch
case "FAIL-nonFraction-nesting-xsi-nil.xml": // Checked - NonFractionNestedNilMismatch
case "FAIL-nonFraction-nil-attr-false.xml": // Checked - PrecisionAndDecimalsAbsent
case "FAIL-nonFraction-nil-decimal-conflict.xml": // Checked- PrecisionAndDecimalsPresent
case "FAIL-nonFraction-no-format-negative-number.xml": // Checked - FormatAbsentNegativeNumber
case "FAIL-nonFraction-unresolvable-ix-tupleRef-attr.xml": // Checked - UnknownTuple
case "FAIL-nonfraction-rule-no-xbrli-attributes.xml": // Checked - InvalidAttributeContent
case "FAIL-unresolvable-contextRef.xml": // Checked - UnknownContext
case "FAIL-unresolvable-unitRef.xml": // Checked = UnknownUnit
case "PASS-attribute-ix-format-nonFraction-01.xml": // Simple value 1234
case "PASS-attribute-ix-name-nonFraction-01.xml": // Value 12..345 scale 3
case "PASS-attribute-ix-scale-nonFraction-01.xml": // Value 12345 scale -3
case "PASS-attribute-ix-scale-nonFraction-04.xml": // Value 12345 scale 10
case "PASS-attribute-ix-sign-nonFraction-01.xml":
case "PASS-element-ix-nonFraction-complete.xml":
case "PASS-element-ix-nonFraction-ixt-numcomma.xml":
case "PASS-element-ix-nonFraction-ixt-numcommadot.xml":
case "PASS-element-ix-nonFraction-ixt-numdash.xml":
case "PASS-element-ix-nonFraction-ixt-numdotcomma.xml":
case "PASS-element-ix-nonFraction-ixt-numspacecomma.xml":
case "PASS-element-ix-nonFraction-ixt-numspacedot.xml":
case "PASS-nonFraction-any-attribute.xml":
case "PASS-nonFraction-comments.xml":
case "PASS-nonFraction-decimals-attr.xml":
case "PASS-nonFraction-ix-format-expanded-name-match.xml":
case "PASS-nonFraction-ix-format-valid.xml":
case "PASS-nonFraction-ix-order-attr.xml":
case "PASS-nonFraction-ix-target-attr.xml":
case "PASS-nonFraction-ix-tupleRef-attr.xml":
case "PASS-nonFraction-nesting-2.xml":
case "PASS-nonFraction-nesting-formats-2.xml":
case "PASS-nonFraction-nesting-formats.xml":
case "PASS-nonFraction-nesting-scale.xml":
case "PASS-nonFraction-nesting.xml":
case "PASS-nonFraction-precision-attr.xml":
case "PASS-nonFraction-processing-instructions.xml":
case "PASS-nonFraction-valid-scale-attr.xml":
case "PASS-nonFraction-valid-sign-attr.xml":
case "PASS-nonFraction-valid-sign-format-attr.xml":
case "PASS-nonFraction-xsi-nil-attr.xml":
case "PASS-simple-nonFraction.xml":
#endregion
if ( $nonFraction ) break; else return;
#region ./nonNumeric - checked fail and pass tests and compares
case "FAIL-element-ix-nonNumeric-escape-01.xml": // Checked - InvalidDataType
case "FAIL-nonNumeric-any-ix-attribute.xml": // Checked - xbrl.core.xml.SchemaValidationError.cvc-complex-type_3_2_2, 1866, 1867, 1866, 1867
case "FAIL-nonNumeric-empty-with-format.xml": // Checked - InvalidDataType
case "FAIL-nonNumeric-illegal-null-namespace-attr.xml": // Checked - xbrl.core.xml.SchemaValidationError.cvc-complex-type_3_2_2, 1866, 1867
case "FAIL-nonNumeric-invalid-ix-format-attr.xml": // Checked - InvalidDataType
case "FAIL-nonNumeric-ix-format-attr-wrong-namespace-binding.xml": // Checked - FormatUndefined
case "FAIL-nonNumeric-missing-contextRef-attr.xml": // Checked - xbrl.core.xml.SchemaValidationError.cvc-complex-type_4, 1868
case "FAIL-nonNumeric-missing-name-attr.xml": // Checked - xbrl.core.xml.SchemaValidationError.cvc-complex-type_4, 1868
case "FAIL-nonNumeric-no-xbrli-attributes.xml": // Checked - InvalidAttributeContent
case "FAIL-nonNumeric-unresolvable-ix-contextRef.xml": // Checked - UnknownContext
case "FAIL-nonNumeric-unresolvable-ix-tupleRef-attr.xml": // Checked - UnknownTuple
case "PASS-attribute-ix-extension-illegalPlacement-01.xml":
case "PASS-attribute-ix-name-nonNumeric-01.xml":
case "PASS-element-ix-nonNumeric-complete.xml":
case "PASS-element-ix-nonNumeric-escape-02.xml":
case "PASS-element-ix-nonNumeric-escape-03.xml":
case "PASS-element-ix-nonNumeric-escape-04.xml":
case "PASS-element-ix-nonNumeric-escape-05.xml":
case "PASS-element-ix-nonNumeric-escape-06.xml":
case "PASS-element-ix-nonNumeric-escape-07.xml":
case "PASS-element-ix-nonNumeric-ixt-datedoteu-01.xml":
case "PASS-element-ix-nonNumeric-ixt-datedotus-01.xml":
case "PASS-element-ix-nonNumeric-ixt-datedotus-02.xml":
case "PASS-element-ix-nonNumeric-ixt-datedotus-03.xml":
case "PASS-element-ix-nonNumeric-ixt-datelongdaymonthuk-01.xml":
case "PASS-element-ix-nonNumeric-ixt-datelongmonthdayus-01.xml":
case "PASS-element-ix-nonNumeric-ixt-datelongmonthyear-01.xml":
case "PASS-element-ix-nonNumeric-ixt-datelonguk-01.xml":
case "PASS-element-ix-nonNumeric-ixt-datelonguk-02.xml":
case "PASS-element-ix-nonNumeric-ixt-datelongus-01.xml":
case "PASS-element-ix-nonNumeric-ixt-datelongus-02.xml":
case "PASS-element-ix-nonNumeric-ixt-datelongyearmonth-01.xml":
case "PASS-element-ix-nonNumeric-ixt-dateshortdaymonthuk-01.xml":
case "PASS-element-ix-nonNumeric-ixt-dateshortmonthdayus-01.xml":
case "PASS-element-ix-nonNumeric-ixt-dateshortmonthyear-01.xml":
case "PASS-element-ix-nonNumeric-ixt-dateshortuk-01.xml":
case "PASS-element-ix-nonNumeric-ixt-dateshortuk-02.xml":
case "PASS-element-ix-nonNumeric-ixt-dateshortus-01.xml":
case "PASS-element-ix-nonNumeric-ixt-dateshortus-02.xml":
case "PASS-element-ix-nonNumeric-ixt-dateshortyearmonth-01.xml":
case "PASS-element-ix-nonNumeric-ixt-dateslashdaymontheu-01.xml":
case "PASS-element-ix-nonNumeric-ixt-dateslasheu-01.xml":
case "PASS-element-ix-nonNumeric-ixt-dateslasheu-02.xml":
case "PASS-element-ix-nonNumeric-ixt-dateslasheu-03.xml":
case "PASS-element-ix-nonNumeric-ixt-dateslashmonthdayus-01.xml":
case "PASS-element-ix-nonNumeric-ixt-dateslashus-01.xml":
case "PASS-element-ix-nonNumeric-ixt-dateslashus-02.xml":
case "PASS-element-ix-nonNumeric-ixt-dateslashus-03.xml":
case "PASS-element-ix-nonNumeric-ixt-dateslashus-04.xml":
case "PASS-element-ordering.xml":
case "PASS-nonNumeric-any-attribute.xml":
case "PASS-nonNumeric-empty-not-xsi-nil.xml":
case "PASS-nonNumeric-escape-with-html-base.xml":
case "PASS-nonNumeric-ix-format-attr-expanded-name-match.xml":
case "PASS-nonNumeric-ix-format-attr.xml":
case "PASS-nonNumeric-ix-order-attr.xml":
case "PASS-nonNumeric-ix-target-attr.xml":
case "PASS-nonNumeric-ix-tupleRef-attr.xml":
case "PASS-nonNumeric-nesting-in-exclude.xml":
case "PASS-nonNumeric-nesting-numerator.xml":
case "PASS-nonNumeric-nesting-text-in-exclude.xml":
case "PASS-nonNumeric-nesting.xml":
case "PASS-nonNumeric-xsi-nil.xml":
case "PASS-nonNumeric.xml":
#endregion
if ( $nonNumeric ) break; else return;
#region ./references - checked fail and pass tests and compares
case "FAIL-empty-references.xml": // Checked xbrl.core.xml.SchemaValidationError.cvc-complex-type_2_4_b, 1871
case "FAIL-ix-references-03.xml": // Checked InvalidAttributeContent
case "FAIL-ix-references-08.xml": // Checked RepeatedOtherAttributes
case "FAIL-ix-references-09.xml": // Checked DuplicateId
case "FAIL-ix-references-namespace-bindings-01.xml": // Checked ReferencesNamespaceClash
case "FAIL-ix-references-namespace-bindings-02.xml": // Checked ReferencesNamespaceClash
case "FAIL-ix-references-namespace-bindings-03.xml": // Checked ReferencesNamespaceClash
case "FAIL-ix-references-namespace-bindings-04.xml": // Checked ReferencesNamespaceClash
case "FAIL-ix-references-rule-multiple-attributes-sameValue.xml": // Checked RepeatedOtherAttributes
case "FAIL-ix-references-rule-multiple-id.xml": // Checked RepeatedIdAttribute
case "FAIL-missing-references-for-all-target-documents.xml": // Checked ReferencesAbsent
case "FAIL-missing-references.xml": // Checked ReferencesAbsent
case "FAIL-references-illegal-content.xml": // Checked xbrl.core.xml.SchemaValidationError.cvc-complex-type_2_4_a, 1871
case "FAIL-references-illegal-location.xml": // Checked xbrl.core.xml.SchemaValidationError.cvc-complex-type_2_4_a, 1871
case "FAIL-references-illegal-order-in-header.xml": // Checked xbrl.core.xml.SchemaValidationError.cvc-complex-type_2_4_a, 1871
case "PASS-element-ix-references-01.xml":
case "PASS-ix-references-01.xml":
case "PASS-ix-references-02.xml":
case "PASS-ix-references-04.xml":
case "PASS-ix-references-05.xml":
case "PASS-ix-references-rule-multiple-matched-target.xml":
case "PASS-ix-references-rule-multiple-xmlBase.xml":
case "PASS-references-copy-non-ix-attrs.xml":
case "PASS-references-ix-target-attr.xml":
case "PASS-simple-linkbaseRef.xml":
case "PASS-simple-schemaRef.xml":
case "PASS-single-references-multi-input.xml":
#endregion
if ( $references ) break; else return;
#region ./relationships - checked fail and pass tests and compares
case "FAIL-relationship-cross-duplication.xml": // Checked RelationshipCrossDuplication
case "FAIL-relationship-mixes-footnote-with-explanatory-fact.xml": // Checked RelationshipMixedToRefs
case "FAIL-relationship-with-no-namespace-attribute.xml": // Checked xbrl.core.xml.SchemaValidationError.cvc-complex-type_3_2_2, 1867
case "FAIL-relationship-with-xbrli-attribute.xml": // xbrl.core.xml.SchemaValidationError.cvc-complex-type_3_2_2, 1867
case "FAIL-relationship-with-xlink-attribute.xml": // xbrl.core.xml.SchemaValidationError.cvc-complex-type_3_2_2, 1867
case "PASS-explanatory-fact-copy-to-owner-target.xml":
case "PASS-explanatory-fact-cycle.xml":
case "PASS-explanatory-fact-not-hidden.xml":
case "PASS-explanatory-fact.xml":
case "PASS-relationship-to-multiple-explanatory-facts-multiple-outputs.xml":
case "PASS-relationship-to-multiple-explanatory-facts.xml":
case "PASS-relationship-with-xml-base.xml":
case "PASS-tuple-footnotes.xml":
#endregion
if ( $relationships ) break; else return;
#region ./resources - checked fail and pass tests and compares
case "FAIL-context-without-id.xml": // Checked - xbrl.core.xml.SchemaValidationError.cvc-complex-type_4, 1868
case "FAIL-missing-resources.xml": // Checked - ResourcesAbsent
case "FAIL-unit-without-id.xml": // Checked - xbrl.core.xml.SchemaValidationError.cvc-complex-type_4, 1868
case "PASS-empty-resources.xml":
case "PASS-simple-arcroleRef.xml":
case "PASS-simple-roleRef.xml":
#endregion
if ( $resources ) break; else return;
#region ./specificationExamples - no fail tests passes compares
case "PASS-section-10.3-example-1.xml":
case "PASS-section-11.3-example-2.xml":
case "PASS-section-15.1-example-3.xml":
case "PASS-section-15.1-example-4.xml":
#endregion
if ( $specificationExamples ) break; else return;
#region ./transformations - checked fail and pass tests and compares
case "FAIL-invalid-long-month.xml": // Checked - InvalidDataType
case "FAIL-invalid-short-month.xml": // Checked - InvalidDataType
case "FAIL-unrecognised-schema-type.xml": // Checked - FormatUndefined
case "PASS-sign-attribute-on-nonFraction-positive-input.xml":
#endregion
if ( $transformations ) break; else return;
#region ./tuple - checked fail and pass tests and compares
case "FAIL-badly-formatted-order-attr.xml": // Checked - xbrl.core.xml.SchemaValidationError.cvc-attribute_3, 1824
case "FAIL-badly-nested-tuples.xml": // Checked - TupleCycle
case "FAIL-duplicate-order-and-value-but-not-attributes.xml": // Checked - OrderDuplicate
case "FAIL-duplicate-tuple-id-different-input-docs.xml": // Checked - DuplicateTupleId
case "FAIL-duplicate-tuple-id.xml": // Checked - DuplicateTupleId
case "FAIL-duplicate-tuple-order-different-values.xml": // Checked - OrderDuplicate
case "FAIL-illegal-element-nested.xml": // Checked = InvalidTupleChild
case "FAIL-illegal-element.xml": // Checked = InvalidTupleChild
case "FAIL-missing-descendants.xml": // Checked - TupleNonEmptyValidation
case "FAIL-nested-tuple-empty.xml": // Checked - TupleNonEmptyValidation
case "FAIL-order-attr-denominator.xml": // Checked - xbrl.core.xml.SchemaValidationError.cvc-complex-type_3_2_2, 1866, 1867
case "FAIL-order-attr-inNonTuple.xml": // Checked - OrderOnNonTupleChild
case "FAIL-order-attr-numerator.xml": // Checked - xbrl.core.xml.SchemaValidationError.cvc-complex-type_3_2_2, 1866, 1867
case "FAIL-ordering-order-duplicate-stringUnequal.xml": // Checked - OrderDuplicate
case "FAIL-ordering-order-duplicate.xml": // Checked - OrderDuplicate
case "FAIL-ordering-partially-missing.xml": // Checked - OrderAbsent
case "FAIL-orphaned-tuple-content.xml": // Checked - UnknownTuple
case "FAIL-tuple-any-ix-attribute.xml": // Checked - xbrl.core.xml.SchemaValidationError.cvc-complex-type_3_2_2, 1866, 1867
case "FAIL-tuple-content-in-different-targets-tuple-not-in-default.xml": // Checked - InconsistentTargets
case "FAIL-tuple-content-in-different-targets.xml": // Checked - InconsistentTargets
case "FAIL-tuple-cycle-by-tupleRef.xml": // Checked - TupleCycle
case "FAIL-tuple-cycle-child.xml": // Checked - TupleCycle
case "FAIL-tuple-cycle-grandchildren.xml": // Checked - TupleCycle
case "FAIL-tuple-empty-no-ix-tupleID.xml": // Checked - TupleNonEmptyValidation
case "FAIL-tuple-empty.xml": // Checked - TupleNonEmptyValidation
case "FAIL-tuple-missing-name-attr.xml": // Checked - xbrl.core.xml.SchemaValidationError.cvc-complex-type_4, 1868
case "FAIL-tuple-no-xbrli-attributes.xml": // Checked - InvalidAttributeContent
case "FAIL-tuple-unresolvable-footnoteRef-attr.xml": // Checked - DanglingRelationshipToRef
case "FAIL-tuple-xsi-nil-with-tuple-ref.xml":
case "PASS-attribute-ix-name-tuple-01.xml":
case "PASS-duplicate-order-same-ws-normalized-value-with-html.xml":
case "PASS-duplicate-order-same-ws-normalized-value.xml":
case "PASS-element-ix-tuple-complete.xml":
case "PASS-element-tuple-reference-multiInput.xml":
case "PASS-element-tuple-reference.xml":
case "PASS-exotic-tuple-order.xml":
case "PASS-nested-tuple-nonEmpty.xml":
case "PASS-nested-tuple-ix-order-no-tupleRef.xml":
case "PASS-nested-tuple.xml":
case "PASS-nonFraction-nesting-reference-conflict.xml":
case "PASS-ordering-references-nesting-order.xml":
case "PASS-singleton-tuple.xml":
case "PASS-tuple-all-content-nested-noTupleID.xml":
case "PASS-tuple-any-attribute.xml":
case "PASS-tuple-ix-target-attr.xml":
case "PASS-tuple-nested-nonNumeric.xml":
case "PASS-tuple-nesting-reference-conflict.xml":
case "PASS-tuple-nonInteger-ordering-nested.xml":
case "PASS-tuple-ordering-nested.xml":
case "PASS-tuple-scope-inverted-siblings.xml":
case "PASS-tuple-scope-inverted.xml":
case "PASS-tuple-scope-nested-nonNumeric.xml":
case "PASS-tuple-scope-nonNumeric.xml":
case "PASS-tuple-xsi-nil.xml":
#endregion
if ( $tuple ) break; else return;
#region ./xmllang - checked fail and pass tests and compares
case "FAIL-xml-lang-not-in-scope-for-footnote.xml": // Checked - FootnoteWithoutXmlLangInScope
case "FAIL-xml-lang-on-ix-hidden-and-on-footnote.xml": // Checked - xbrl.core.xml.SchemaValidationError.cvc-complex-type_3_2_2, 1866, 1867
case "FAIL-xml-lang-on-ix-hidden.xml": // Checked - xbrl.core.xml.SchemaValidationError.cvc-complex-type_3_2_2, 1866, 1867
case "PASS-direct-xml-lang-not-overidden.xml": // Checked
case "PASS-xml-lang-on-xhtml.xml": // Checked
#endregion
if ( $xmllang ) break; else return;
default:
return;
}
$testDoc = new \DOMDocument();
if ( ! $testDoc->load( "$dirname$filename" ) )
{
throw new IXBRLException('Failed to load the test case document: $filename');
}
$documentElement = $testDoc->documentElement;
$xpath = new \DOMXPath( $testDoc );
$xpath->registerNamespace('tc', 'http://xbrl.org/2008/conformance' );
/**
* Get the text for an element
* @param string $elementName
* @param string $node
* @return string
*/
$getElementText = function( $elementName, $node ) use( $xpath )
{
/** @var \DOMNodeList $elements */
$elements = $xpath->query( $elementName, $node );
return count( $elements )
? $number = $elements[0]->textContent
: '';
};
/**
* Get an array of text content for an element
* @param string $elementName
* @param string $node
* @param bool $groupByTarget (optional: false) When true the array will be indexed by the named target
* @return array
*/
$getTextArray = function( $elementName, $node, $groupByTarget = false ) use( $xpath )
{
$elements = array();
foreach( $xpath->query( $elementName, $node ) as $element )
{
if ( $groupByTarget )
{
$target = $element->getAttribute(IXBRL_ATTR_TARGET);
$elements[ $target ] = $element->textContent;
}
else
{
$elements[] = $element->textContent;
}
}
return $elements;
};
$number = $getElementText('tc:number', $documentElement );
$name = $getElementText('tc:name', $documentElement );
foreach( $xpath->query( 'tc:variation', $documentElement ) as $tag => $variation )
{
/** @var \DOMElement $variation */
$id = $variation->getAttribute(IXBRL_ATTR_ID);
$description = $getElementText('tc:description', $variation );
$firstInstances = $getTextArray( 'tc:data/tc:instance[@readMeFirst="true"]', $variation );
$otherInstances = array_diff( $getTextArray( 'tc:data/tc:instance', $variation ), $firstInstances );
$result = $xpath->query( 'tc:result', $variation )[0];
$expected = $result->getAttribute('expected');
$standard = ! boolval( $result->getAttribute('nonStandardErrorCodes') );
$errors = array();
if ( $expected == 'valid' )
{
$resultInstances = $getTextArray( 'tc:instance', $result, true );
}
else
{
$resultInstances = array();
$errors = $getTextArray( 'tc:error', $result );
$extras = array();
foreach( $errors as $error )
{
switch( $error )
{
case 'xbrl.core.xml.SchemaValidationError.cvc-complex-type_3_2_2':
$extras[] = '1866';
$extras[] = '1867';
break;
case 'xbrl.core.xml.SchemaValidationError.cvc-complex-type_4':
$extras[] = '1868';
break;
case 'xbrl.core.xml.SchemaValidationError.cvc-complex-type_2_4_d':
case 'xbrl.core.xml.SchemaValidationError.cvc-complex-type_2_4_b':
case 'xbrl.core.xml.SchemaValidationError.cvc-complex-type_2_4_a':
$extras[] = '1871';
break;
case 'xbrl.core.xml.SchemaValidationError.cvc-pattern-valid':
$extras[] = '1839';
break;
case 'xbrl.core.xml.SchemaValidationError.cvc-minLength-valid':
$extras[] = '1831';
break;
case 'xbrl.core.xml.SchemaValidationError.cvc-complex-type_2_2':
$extras[] = '1842';
break;
case 'xbrl.core.xml.SchemaValidationError.cvc-attribute_3':
$extras[] = '1824';
break;
}
}
$errors = array_merge( $errors, $extras );
}
// Select the correct set of tests
switch( $testClass )
{
case IXBRL_TEST_COMPARES:
if ( $errors ) return;
break;
case IXBRL_TEST_ERRORS:
if ( ! $errors ) return;
break;
default:
break;
}
$message = "($id) $filename - $description ";
$message .= " ($expected" . ( $errors ? ": " . join( ',', $errors ) : "" ) . ")";
$log->info( $message );
// True if the test result agrees with the expected result
$success = false;
global $issues;
try
{
$documentSet = array_map( function( $document ) use( $dirname )
{
return \XBRL::resolve_path( $dirname, $document );
}, array_merge( $firstInstances, $otherInstances ) );
$predictedSet = array_map( function( $document ) use( $dirname )
{
return \XBRL::resolve_path( $dirname, $document );
}, $resultInstances );
/** @var \DOMElement[] */
$documents = XBRL_Inline::createInstanceDocument( $name, $documentSet, $cacheLocation, true );
if ( $expected == 'invalid' )
{
$log->warning( "The test result (valid) does not match the expected result (invalid)" );
$error = join( ',', $errors );
$log->warning( "The expected error is ($error)" );
$issues[] = array(
'id' => $id,
'filename' => $filename,
'variation' => $number,
'type' => 'Expected invalid result',
'expected error' => join( ', ', $errors ),
'actual error' => 'createInstanceDocument returns false',
'message' => "The test result (valid) does not match the expected result (invalid)",
);
continue;
}
// Check there are documents for each target
$x = array_diff_key( $documents, $predictedSet );
$y = array_diff_key( $predictedSet, $documents );
if ( $x || $y )
{
$missingTargets = "'" . join( ', ', array_keys( array_merge( $x, $y ) ) ) . "'";
throw new IXBRLDocumentValidationException( 'UnmatchedTarget', "There are unmatched targets in the generated instance documents: $missingTargets" );
}
// Save the instance documents
foreach( $documents as $target => $document )
{
/** @var \DOMDocument $document */
$predictedFilename = str_replace( 'predicted', 'generated', basename( $predictedSet[ $target ] ) );
// Create formatted output so
$document->formatOutput = true;
$xml = $document->saveXML();
if ( ! file_put_contents( "$outputFolder/$predictedFilename", $xml ) )
{
throw new IXBRLDocumentValidationException("Unable to saved instance document '$predictedFilename'");
}
}
// Compare the generated documents with the predicted documents
foreach( $documents as $target => $document )
{
/** @var \DOMDocument $document */
$predictedFilename = $predictedSet[ $target ];
$outputFilename = str_replace( 'predicted', 'generated', basename( $predictedFilename ) );
compare( "$outputFolder/$outputFilename", $predictedFilename );
}
$success = true;
}
catch( IXBRLSchemaValidationException $ex )
{
$validator = $ex->getValidator();
if ( $expected == 'invalid' )
{
if ( $validator->hasErrorCode( $errors ) )
{
// echo join( ', ', $errors ) . "\n";
$success = true;
}
}
if ( ! $success )
{
if ( $expected == 'valid' )
{
$log->warning( "The test result (invalid) does not match the expected result (valid)" );
$issues[] = array(
'id' => $id,
'filename' => $filename,
'variation' => $number,
'type' => 'Expected valid result',
'expected error' => 'none',
'actual error' => join( ",\n", array_map( function( $error ) use( $validator ) { return $validator->formatError( $error ); }, $validator->errors ) ),
'message' => $ex->getMessage(),
);
}
else
{
$log->warning( "The test result error does not match the expected error ($error)" );
$issues[] = array(
'id' => $id,
'filename' => $filename,
'variation' => $number,
'type' => 'Expected invalid result',
'expected error' => join( ",\n", $errors ),
'actual error' => join( ",\n", array_map( function( $error ) use( $validator ) { return $validator->formatError( $error ); }, $validator->errors ) ),
'message' => $ex->getMessage(),
);
}
$validator->displayErrors();
}
}
catch( IXBRLDocumentValidationException $ex )
{
if ( $expected == 'valid' )
{
$log->warning( "The test result (invalid) does not match the expected result (valid)" );
$issues[] = array(
'id' => $id,
'filename' => $filename,
'variation' => $number,
'type' => 'Expected valid result',
'expected error' => 'none',
'actual error' => $ex->getErrorCode(),
'message' => $ex->getMessage(),
);
}
else if ( array_search( $ex->getErrorCode(), $errors ) === false )
{
$log->warning( "The test result error does not match the expected error ($error)" );
$issues[] = array(
'id' => $id,
'filename' => $filename,
'variation' => $number,
'type' => 'Expected invalid result',
'expected error' => join( ",\n", $errors ),
'actual error' => $ex->getErrorCode(),
'message' => $ex->getMessage(),
);
}
else
{
// echo $ex->getErrorCode() . "\n";
$success = true;
}
if ( ! $success )
{
// echo $ex;
}
}
catch( IXBRLTestCompareException $ex )
{
$log->err( $ex );
$issues[] = array(
'id' => $id,
'filename' => $filename,
'variation' => $number,
'type' => 'Expected valid instance document',
'actual error' => 'IXBRLTestCompareException',
'message' => $ex->getMessage(),
);
}
catch( IXBRLException $ex )
{
$log->err( $ex );
$issues[] = array(
'id' => $id,
'filename' => $filename,
'variation' => $number,
'type' => 'Expected invalid result',
'expected error' => join( ', ', $errors ),
'actual error' => 'IXBRLException',
'message' => $ex->getMessage(),
);
}
catch( \Exception $ex )
{
$log->err( $ex );
$issues[] = array(
'id' => $id,
'filename' => $filename,
'variation' => $number,
'type' => 'Expected invalid result',
'expected error' => join( ', ', $errors ),
'actual error' => '\Exception',
'message' => $ex->getMessage(),