1
1
<?php
2
2
3
+ // @codeCoverageIgnoreStart
4
+
3
5
if ( defined ( 'DATA_VALUES_JAVASCRIPT_VERSION ' ) ) {
4
6
// Do not initialize more than once.
5
7
return 1 ;
26
28
// Resource Loader module registration
27
29
$ GLOBALS ['wgResourceModules ' ] = array_merge (
28
30
$ GLOBALS ['wgResourceModules ' ],
29
- include ( __DIR__ . '/DataValues.resources.mw.php ' ),
30
- include ( __DIR__ . '/js/ValueParsers.resources.mw.php ' ),
31
- include ( __DIR__ . '/js/ValueFormatters.resources.mw.php ' )
31
+ include ( __DIR__ . '/lib/resources.php ' ),
32
+ include ( __DIR__ . '/src/resources.mw.php ' ),
33
+ include ( __DIR__ . '/src/valueParsers/resources.mw.php ' ),
34
+ include ( __DIR__ . '/src/valueFormatters/resources.mw.php ' )
32
35
);
33
36
34
37
// API module registration
48
51
* @param \ResourceLoader &$resourceLoader
49
52
* @return boolean
50
53
*/
51
- $ GLOBALS ['wgHooks ' ]['ResourceLoaderTestModules ' ][] = function ( array &$ testModules , \ResourceLoader &$ resourceLoader ) {
52
- // Register DataValue QUnit tests. Take the predefined test definitions and make them
53
- // suitable for registration with MediaWiki's resource loader.
54
- $ ownModules = include ( __DIR__ . '/DataValues.tests.qunit.php ' );
55
- $ ownModulesTemplate = array (
56
- 'localBasePath ' => __DIR__ ,
57
- 'remoteExtPath ' => '.. ' . substr ( __DIR__ , strlen ( $ GLOBALS ['IP ' ] ) ),
58
- );
59
- foreach ( $ ownModules as $ ownModuleName => $ ownModule ) {
60
- $ testModules ['qunit ' ][ $ ownModuleName ] = $ ownModule + $ ownModulesTemplate ;
61
- }
62
- return true ;
63
- };
64
-
65
- /**
66
- * Hook to add QUnit test cases.
67
- * @see https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderTestModules
68
- * @since 0.1
69
- *
70
- * @param array &$testModules
71
- * @param \ResourceLoader &$resourceLoader
72
- * @return boolean
73
- */
74
- $ GLOBALS ['wgHooks ' ]['ResourceLoaderTestModules ' ][] = function ( array &$ testModules , \ResourceLoader &$ resourceLoader ) {
75
- // @codeCoverageIgnoreStart
76
- $ moduleTemplate = array (
77
- 'localBasePath ' => __DIR__ . '/js/tests/ValueParsers ' ,
78
- 'remoteExtPath ' => '.. ' . substr ( __DIR__ , strlen ( $ GLOBALS ['IP ' ] ) ) . '/js/tests/ValueParsers ' ,
79
- );
80
-
81
- $ testModules ['qunit ' ]['ext.valueParsers.tests ' ] = $ moduleTemplate + array (
82
- 'scripts ' => array (
83
- 'ValueParser.tests.js ' ,
84
- ),
85
- 'dependencies ' => array (
86
- 'valueParsers.parsers ' ,
87
- ),
88
- );
89
-
90
- $ testModules ['qunit ' ]['ext.valueParsers.factory ' ] = $ moduleTemplate + array (
91
- 'scripts ' => array (
92
- 'ValueParserFactory.tests.js ' ,
93
- ),
94
- 'dependencies ' => array (
95
- 'qunit.parameterize ' ,
96
- 'valueParsers.factory ' ,
97
- 'valueParsers.parsers ' ,
98
- ),
99
- );
100
-
101
- $ testModules ['qunit ' ]['ext.valueParsers.parsers ' ] = $ moduleTemplate + array (
102
- 'scripts ' => array (
103
- 'parsers/BoolParser.tests.js ' ,
104
- 'parsers/GlobeCoordinateParser.tests.js ' ,
105
- 'parsers/FloatParser.tests.js ' ,
106
- 'parsers/IntParser.tests.js ' ,
107
- 'parsers/StringParser.tests.js ' ,
108
- 'parsers/TimeParser.tests.js ' ,
109
- 'parsers/QuantityParser.tests.js ' ,
110
- 'parsers/NullParser.tests.js ' ,
111
- ),
112
- 'dependencies ' => array (
113
- 'ext.valueParsers.tests ' ,
114
- 'util.inherit ' ,
115
- ),
116
- );
117
-
118
- return true ;
119
- // @codeCoverageIgnoreEnd
120
- };
121
-
122
- /**
123
- * Adding valueFormatters QUnit tests.
124
- * @see https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderTestModules
125
- * @since 0.1
126
- *
127
- * @param array &$testModules
128
- * @param \ResourceLoader &$resourceLoader
129
- * @return boolean
130
- */
131
54
$ GLOBALS ['wgHooks ' ]['ResourceLoaderTestModules ' ][] = function (
132
55
array &$ testModules ,
133
56
\ResourceLoader &$ resourceLoader
134
57
) {
135
- // @codeCoverageIgnoreStart
136
- $ moduleTemplate = array (
137
- 'localBasePath ' => __DIR__ . '/js/tests/ValueFormatters ' ,
138
- 'remoteExtPath ' => '.. ' . substr ( __DIR__ , strlen ( $ GLOBALS ['IP ' ] ) ) . '/js/tests/ValueFormatters ' ,
58
+ $ testModules ['qunit ' ] = array_merge (
59
+ $ testModules ['qunit ' ],
60
+ include ( __DIR__ . '/tests/lib/resources.php ' ),
61
+ include ( __DIR__ . '/tests/src/resources.php ' ),
62
+ include ( __DIR__ . '/tests/src/valueFormatters/resources.php ' ),
63
+ include ( __DIR__ . '/tests/src/valueParsers/resources.php ' )
139
64
);
140
65
141
- $ testModules ['qunit ' ]['ext.valueFormatters.tests ' ] = $ moduleTemplate + array (
142
- 'scripts ' => array (
143
- 'ValueFormatter.tests.js ' ,
144
- ),
145
- 'dependencies ' => array (
146
- 'valueFormatters ' ,
147
- 'valueFormatters.ValueFormatter ' ,
148
- ),
149
- );
150
-
151
- $ testModules ['qunit ' ]['ext.valueFormatters.factory ' ] = $ moduleTemplate + array (
152
- 'scripts ' => array (
153
- 'ValueFormatterFactory.tests.js ' ,
154
- ),
155
- 'dependencies ' => array (
156
- 'qunit.parameterize ' ,
157
- 'valueFormatters.factory ' ,
158
- 'valueFormatters.formatters ' ,
159
- ),
160
- );
161
-
162
- $ testModules ['qunit ' ]['ext.valueFormatters.formatters ' ] = $ moduleTemplate + array (
163
- 'scripts ' => array (
164
- 'formatters/NullFormatter.tests.js ' ,
165
- 'formatters/StringFormatter.tests.js ' ,
166
- ),
167
- 'dependencies ' => array (
168
- 'ext.valueFormatters.tests ' ,
169
- 'util.inherit ' ,
170
- 'valueFormatters.formatters ' ,
171
- ),
172
- );
173
-
174
66
return true ;
175
- // @codeCoverageIgnoreEnd
176
- };
67
+ };
0 commit comments