87 {
88
89 $packageWithoutExtra = array(
90 'name' => 'components/packagewithoutextra',
91 'type' => 'component',
92 );
93 $packages = array($packageWithoutExtra);
94 $expected = array(
95 'baseUrl' => 'components',
96 );
97 $tests[] = array($packages, array(), $expected);
98
99
100 $packages = array($packageWithoutExtra);
101 $expected = array(
102 'baseUrl' => 'components',
103 );
104 $tests[] = array($packages, array('component-dir' => 'otherdir'), $expected);
105
106
107 $packages = array($packageWithoutExtra);
108 $expected = array(
109 'baseUrl' => '/another/path',
110 );
111 $tests[] = array($packages, array('component-baseurl' => '/another/path'), $expected);
112
113
114 $jquery = array(
115 'name' => 'components/jquery',
116 'type' => 'component',
117 'extra' => array(
118 'component' => array(
119 'scripts' => array(
120 'jquery.js',
121 )
122 )
123 )
124 );
125 $packages = array($jquery);
126 $expected = array(
127 'baseUrl' => 'components',
128 );
129 $tests[] = array($packages, array(), $expected);
130
131
132 $underscore = array(
133 'name' => 'components/underscore',
134 'type' => 'component',
135 'extra' => array(
136 'component' => array(
137 'shim' => array(
138 'exports' => '_',
139 ),
140 ),
141 ),
142 'baseUrl' => 'components',
143 );
144 $packages = array($underscore);
145 $expected = array(
146 'shim' => array(
147 'underscore' => array(
148 'exports' => '_',
149 ),
150 ),
151 'baseUrl' => 'components',
152 );
153 $tests[] = array($packages, array(), $expected);
154
155
156 $backbone = array(
157 'name' => 'components/backbone',
158 'type' => 'component',
159 'extra' => array(
160 'component' => array(
161 'scripts' => array(
162 'backbone.js'
163 ),
164 'shim' => array(
165 'exports' => 'Backbone',
166 'deps' => array(
167 'underscore',
168 'jquery'
169 ),
170 ),
171 ),
172 ),
173 );
174 $packages = array($backbone);
175 $expected = array(
176 'shim' => array(
177 'backbone' => array(
178 'exports' => 'Backbone',
179 'deps' => array(
180 'underscore',
181 'jquery'
182 ),
183 ),
184 ),
185 'baseUrl' => 'components',
186 );
187 $tests[] = array($packages, array(), $expected);
188
189
190 $packages = array($backbone, $jquery);
191 $expected = array(
192 'shim' => array(
193 'backbone' => array(
194 'exports' => 'Backbone',
195 'deps' => array(
196 'underscore',
197 'jquery'
198 ),
199 ),
200 ),
201 'baseUrl' => 'components',
202 );
203 $tests[] = array($packages, array(), $expected);
204
205
206 $packageWithConfig = array(
207 'name' => 'components/packagewithconfig',
208 'type' => 'component',
209 'extra' => array(
210 'component' => array(
211 'config' => array(
212 'color' => 'blue',
213 ),
214 ),
215 ),
216 );
217 $packages = array($packageWithConfig);
218 $expected = array(
219 'config' => array(
220 'packagewithconfig' => array(
221 'color' => 'blue',
222 ),
223 ),
224 'baseUrl' => 'components',
225 );
226 $tests[] = array($packages, array(), $expected);
227
228
229 $packageWithScripts = array(
230 'name' => 'components/foobar',
231 'type' => 'component',
232 'extra' => array(
233 'component' => array(
234 'scripts' => array(
235 'tests/ComponentInstaller/Test/Resources/test.js',
236 ),
237 ),
238 ),
239 'is-root' => true,
240 );
241 $packages = array($packageWithScripts);
242 $expected = array(
243 'packages' => array(
244 array(
245 'name' => 'foobar',
246 'main' => 'foobar-built.js'
247 ),
248 ),
249 'baseUrl' => 'components',
250 );
251 $tests[] = array($packages, array(), $expected);
252
253
254 $packageWithScripts = array(
255 'name' => 'components/foobar2',
256 'extra' => array(
257 'component' => array(
258 'scripts' => array(
259 'tests/ComponentInstaller/Test/Resources/*.js',
260 ),
261 ),
262 ),
263 'is-root' => true,
264 );
265 $packages = array($packageWithScripts);
266 $expected = array(
267 'packages' => array(
268 array(
269 'name' => 'foobar2',
270 'main' => 'foobar2-built.js'
271 ),
272 ),
273 'baseUrl' => 'components',
274 );
275 $tests[] = array($packages, array(), $expected);
276
277
278 $package = array(
279 'name' => 'components/foobar3',
280 'extra' => array(
281 'component' => array(
282 'config' => array(
283 'color' => 'blue',
284 ),
285 ),
286 ),
287 );
288 $packages = array($package);
290 'component' => array(
291 'waitSeconds' => 3,
292 'baseUrl' => 'public',
293 ),
294 );
295 $expected = array(
296 'config' => array(
297 'foobar3' => array(
298 'color' => 'blue',
299 ),
300 ),
301 'baseUrl' => 'public',
302 'waitSeconds' => 3,
303 );
304 $tests[] = array($packages,
$config, $expected);
305
306
307 $package = array(
308 'name' => 'components/foobar3',
309 'extra' => array(
310 'component' => array(
311 'config' => array(
312 'color' => 'blue',
313 ),
314 ),
315 ),
316 );
317 $packages = array($package);
319 'component' => array(
320 'waitSeconds' => 3,
321 'baseUrl' => 'public',
322 'config' => array(
323 'foobar3' => array(
324 'color' => 'red',
325 ),
326 ),
327 ),
328 );
329 $expected = array(
330 'config' => array(
331 'foobar3' => array(
332 'color' => 'red',
333 ),
334 ),
335 'baseUrl' => 'public',
336 'waitSeconds' => 3,
337 );
338 $tests[] = array($packages,
$config, $expected);
339
340 return $tests;
341 }