Projet

Général

Profil

Révision a192dc0b

Ajouté par Assos Assos il y a environ 8 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/feeds/tests/http_request.test
51 51
    $this->assertEqual($links[0], 'http://example.com/rss.xml');
52 52
  }
53 53

  
54
  /**
55
   * Tests http_request_create_absolute_url().
56
   */
57
  public function testHTTPRequestCreateAbsoluteUrl() {
58
    $test_urls = array(
59
      // Rels that do not start with "/".
60
      array(
61
        'rel'    => 'h',
62
        'base'   => 'http://www',
63
        'expected' => 'http://www/h',
64
      ),
65
      array(
66
        'rel'    => 'h',
67
        'base'   => 'http://www/',
68
        'expected' => 'http://www/h',
69
      ),
70
      array(
71
        'rel'    => 'h',
72
        'base'   => 'http://www/?c;d=e#f',
73
        'expected' => 'http://www/h',
74
      ),
75
      array(
76
        'rel'    => 'h',
77
        'base'   => 'http://www/a/b',
78
        'expected' => 'http://www/a/h',
79
      ),
80

  
81
      array(
82
        'rel'    => 'h/j',
83
        'base'   => 'http://www',
84
        'expected' => 'http://www/h/j',
85
      ),
86
      array(
87
        'rel'    => 'h/j',
88
        'base'   => 'http://www/',
89
        'expected' => 'http://www/h/j',
90
      ),
91
      array(
92
        'rel'    => 'h/j',
93
        'base'   => 'http://www/?c;d=e#f',
94
        'expected' => 'http://www/h/j',
95
      ),
96
      array(
97
        'rel'    => 'h/j',
98
        'base'   => 'http://www/a/b',
99
        'expected' => 'http://www/a/h/j',
100
      ),
101
      array(
102
        'rel'    => 'h/j',
103
        'base'   => 'http://www/a/b/',
104
        'expected' => 'http://www/a/b/h/j',
105
      ),
106

  
107
      // Rels that start with "/".
108
      array(
109
        'rel'    => '/h',
110
        'base'   => 'http://www',
111
        'expected' => 'http://www/h',
112
      ),
113
      array(
114
        'rel'    => '/h',
115
        'base'   => 'http://www/',
116
        'expected' => 'http://www/h',
117
      ),
118
      array(
119
        'rel'    => '/h',
120
        'base'   => 'http://www/?c;d=e#f',
121
        'expected' => 'http://www/h',
122
      ),
123
      array(
124
        'rel'    => '/h',
125
        'base'   => 'http://www/a/b',
126
        'expected' => 'http://www/h',
127
      ),
128

  
129
      array(
130
        'rel'    => '/h/j',
131
        'base'   => 'http://www',
132
        'expected' => 'http://www/h/j',
133
      ),
134
      array(
135
        'rel'    => '/h/j',
136
        'base'   => 'http://www/',
137
        'expected' => 'http://www/h/j',
138
      ),
139
      array(
140
        'rel'    => '/h/j',
141
        'base'   => 'http://www/?c;d=e#f',
142
        'expected' => 'http://www/h/j',
143
      ),
144
      array(
145
        'rel'    => '/h/j',
146
        'base'   => 'http://www/a/b',
147
        'expected' => 'http://www/h/j',
148
      ),
149
      array(
150
        'rel'    => '/h/j',
151
        'base'   => 'http://www/a/b/',
152
        'expected' => 'http://www/h/j',
153
      ),
154

  
155
      // Rels that contain ".".
156
      array(
157
        'rel'    => './h',
158
        'base'   => 'http://www',
159
        'expected' => 'http://www/h',
160
      ),
161
      array(
162
        'rel'    => './h',
163
        'base'   => 'http://www/',
164
        'expected' => 'http://www/h',
165
      ),
166
      array(
167
        'rel'    => './h',
168
        'base'   => 'http://www/?c;d=e#f',
169
        'expected' => 'http://www/h',
170
      ),
171
      array(
172
        'rel'    => './h',
173
        'base'   => 'http://www/a/b',
174
        'expected' => 'http://www/a/h',
175
      ),
176

  
177
      array(
178
        'rel'    => './h/j',
179
        'base'   => 'http://www',
180
        'expected' => 'http://www/h/j',
181
      ),
182
      array(
183
        'rel'    => './h/j',
184
        'base'   => 'http://www/',
185
        'expected' => 'http://www/h/j',
186
      ),
187
      array(
188
        'rel'    => './h/j',
189
        'base'   => 'http://www/?c;d=e#f',
190
        'expected' => 'http://www/h/j',
191
      ),
192
      array(
193
        'rel'    => './h/j',
194
        'base'   => 'http://www/a/b',
195
        'expected' => 'http://www/a/h/j',
196
      ),
197
      array(
198
        'rel'    => './h/j',
199
        'base'   => 'http://www/a/b/',
200
        'expected' => 'http://www/a/b/h/j',
201
      ),
202

  
203
      array(
204
        'rel'    => 'h/./j',
205
        'base'   => 'http://www',
206
        'expected' => 'http://www/h/j',
207
      ),
208
      array(
209
        'rel'    => 'h/./j',
210
        'base'   => 'http://www/',
211
        'expected' => 'http://www/h/j',
212
      ),
213
      array(
214
        'rel'    => 'h/./j',
215
        'base'   => 'http://www/?c;d=e#f',
216
        'expected' => 'http://www/h/j',
217
      ),
218
      array(
219
        'rel'    => 'h/./j',
220
        'base'   => 'http://www/a/b',
221
        'expected' => 'http://www/a/h/j',
222
      ),
223
      array(
224
        'rel'    => 'h/./j',
225
        'base'   => 'http://www/a/b/',
226
        'expected' => 'http://www/a/b/h/j',
227
      ),
228

  
229
      array(
230
        'rel'    => '/h/./j',
231
        'base'   => 'http://www',
232
        'expected' => 'http://www/h/j',
233
      ),
234
      array(
235
        'rel'    => '/h/./j',
236
        'base'   => 'http://www/',
237
        'expected' => 'http://www/h/j',
238
      ),
239
      array(
240
        'rel'    => '/h/./j',
241
        'base'   => 'http://www/?c;d=e#f',
242
        'expected' => 'http://www/h/j',
243
      ),
244
      array(
245
        'rel'    => '/h/./j',
246
        'base'   => 'http://www/a/b',
247
        'expected' => 'http://www/h/j',
248
      ),
249
      array(
250
        'rel'    => '/h/./j',
251
        'base'   => 'http://www/a/b/',
252
        'expected' => 'http://www/h/j',
253
      ),
254

  
255
      // Rels that starts with "../".
256
      array(
257
        'rel'    => '../h/j',
258
        'base'   => 'http://www',
259
        'expected' => 'http://www/h/j',
260
      ),
261
      array(
262
        'rel'    => '../h/j',
263
        'base'   => 'http://www/',
264
        'expected' => 'http://www/h/j',
265
      ),
266
      array(
267
        'rel'    => '../h/j',
268
        'base'   => 'http://www/?c;d=e#f',
269
        'expected' => 'http://www/h/j',
270
      ),
271
      array(
272
        'rel'    => '../h/j',
273
        'base'   => 'http://www/a/b',
274
        'expected' => 'http://www/h/j',
275
      ),
276
      array(
277
        'rel'    => '../h/j',
278
        'base'   => 'http://www/a/b/',
279
        'expected' => 'http://www/a/h/j',
280
      ),
281
      array(
282
        'rel'    => '../h/j',
283
        'base'   => 'http://www/a/b/c/',
284
        'expected' => 'http://www/a/b/h/j',
285
      ),
286

  
287
      // Rels that start with "../../".
288
      array(
289
        'rel'    => '../../h/j',
290
        'base'   => 'http://www',
291
        'expected' => 'http://www/h/j',
292
      ),
293
      array(
294
        'rel'    => '../../h/j',
295
        'base'   => 'http://www/',
296
        'expected' => 'http://www/h/j',
297
      ),
298
      array(
299
        'rel'    => '../../h/j',
300
        'base'   => 'http://www/?c;d=e#f',
301
        'expected' => 'http://www/h/j',
302
      ),
303
      array(
304
        'rel'    => '../../h/j',
305
        'base'   => 'http://www/a/b',
306
        'expected' => 'http://www/h/j',
307
      ),
308
      array(
309
        'rel'    => '../../h/j',
310
        'base'   => 'http://www/a/b/',
311
        'expected' => 'http://www/h/j',
312
      ),
313
      array(
314
        'rel'    => '../../h/j',
315
        'base'   => 'http://www/a/b/c/',
316
        'expected' => 'http://www/a/h/j',
317
      ),
318
      array(
319
        'rel'    => '../../h/j',
320
        'base'   => 'http://www/a/b/c/d',
321
        'expected' => 'http://www/a/h/j',
322
      ),
323

  
324
      // Crazy rels.
325
      array(
326
        'rel'    => 'h/../../j/./k',
327
        'base'   => 'http://www/a/b/c/',
328
        'expected' => 'http://www/a/b/j/k',
329
      ),
330
      array(
331
        'rel'    => 'h/../../j/./k',
332
        'base'   => 'http://www/a/b/c/d',
333
        'expected' => 'http://www/a/b/j/k',
334
      ),
335
      array(
336
        'rel'    => '../../../',
337
        'base'   => 'http://www/a/b/c/',
338
        'expected' => 'http://www/',
339
      ),
340
      array(
341
        'rel'    => 'h/j/k/../../',
342
        'base'   => 'http://www/a/b/c/',
343
        'expected' => 'http://www/a/b/c/h',
344
      ),
345
    );
346

  
347
    foreach ($test_urls as $test_url) {
348
      $result_url = http_request_create_absolute_url($test_url['rel'], $test_url['base']);
349
      $this->assertEqual($test_url['expected'], $result_url, format_string('Creating an absolute URL from base @base and rel @rel resulted into @expected (actual: @actual).', array(
350
        '@actual' => var_export($result_url, TRUE),
351
        '@expected' => var_export($test_url['expected'], TRUE),
352
        '@rel' => var_export($test_url['rel'], TRUE),
353
        '@base' => var_export($test_url['base'], TRUE),
354
      )));
355
    }
356

  
357
  }
358

  
54 359
}

Formats disponibles : Unified diff