Projet

Général

Profil

Paste
Télécharger (20,4 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / link / tests / link.validate.test @ 39a181a4

1
<?php
2

    
3
/**
4
 * @file
5
 * Tests that exercise the validation functions in the link module.
6
 */
7

    
8
/**
9
 * Validate Test Case.
10
 */
11
class LinkValidateTestCase extends LinkBaseTestClass {
12

    
13
  /**
14
   * Create Link.
15
   */
16
  protected function createLink($url, $title, $attributes = array()) {
17
    return array(
18
      'url' => $url,
19
      'title' => $title,
20
      'attributes' => $attributes,
21
    );
22
  }
23

    
24
  /**
25
   * Takes a url, and sees if it can validate that the url is valid.
26
   *
27
   * @codingStandardsIgnoreStart
28
   */
29
  protected function link_test_validate_url($url) {
30
    // @codingStandardsIgnoreEnd
31

    
32
    $field_name = $this->createLinkField();
33

    
34
    $label = $this->randomName();
35
    $settings = array(
36
      'title' => $label,
37
      $field_name => array(
38
        LANGUAGE_NONE => array(
39
          array(
40
            'title' => $label,
41
            'url' => $url,
42
          ),
43
        ),
44
      ),
45
    );
46

    
47
    $node = $this->drupalCreateNode($settings);
48

    
49
    $this->assertNotNull($node, ' has been created.', 'Node created');
50

    
51
    $this->assertEqual($url, $node->{$field_name}[LANGUAGE_NONE][0]['url']);
52
  }
53

    
54
}
55

    
56
/**
57
 * Class for Validate Test.
58
 */
59
class LinkValidateTest extends LinkValidateTestCase {
60

    
61
  /**
62
   * Get Info.
63
   */
64
  public static function getInfo() {
65
    return array(
66
      'name' => 'Link Validation Tests',
67
      'description' => 'Tests the field validation.',
68
      'group' => 'Link',
69
    );
70
  }
71

    
72
  /**
73
   * Validate basic URL.
74
   *
75
   * @codingStandardsIgnoreStart
76
   */
77
  public function test_link_validate_basic_url() {
78
    // @codingStandardsIgnoreEnd
79
    $this->link_test_validate_url('http://www.example.com');
80
  }
81

    
82
  /**
83
   * Test if we're stopped from posting a bad url on default validation.
84
   *
85
   * @codingStandardsIgnoreStart
86
   */
87
  public function test_link_validate_bad_url_validate_default() {
88
    // @codingStandardsIgnoreEnd
89
    $this->web_user = $this->drupalCreateUser(array(
90
      'administer content types',
91
      'administer fields',
92
      'administer nodes',
93
      'administer filters',
94
      'access content',
95
      'create page content',
96
      'access administration pages',
97
    ));
98
    $this->drupalLogin($this->web_user);
99

    
100
    // Create field.
101
    $name = strtolower($this->randomName());
102
    $edit = array(
103
      'fields[_add_new_field][label]' => $name,
104
      'fields[_add_new_field][field_name]' => $name,
105
      'fields[_add_new_field][type]' => 'link_field',
106
      'fields[_add_new_field][widget_type]' => 'link_field',
107
    );
108
    $this->drupalPost('admin/structure/types/manage/page/fields', $edit, t('Save'));
109
    $this->drupalPost(NULL, array(), t('Save field settings'));
110
    $this->drupalPost(NULL, array(), t('Save settings'));
111

    
112
    // Is field created?
113
    $this->assertRaw(t('Saved %label configuration', array('%label' => $name)), 'Field added');
114
    node_types_rebuild();
115
    menu_rebuild();
116

    
117
    // Create page form.
118
    $this->drupalGet('node/add/page');
119
    $field_name = 'field_' . $name;
120
    $this->assertField('edit-field-' . $name . '-und-0-title', 'Title found');
121
    $this->assertField('edit-field-' . $name . '-und-0-url', 'URL found');
122

    
123
    $edit = array(
124
      'title' => 'Simple Title',
125
      $field_name . '[und][0][url]' => 'edik:naw',
126
    );
127

    
128
    $this->drupalPost(NULL, $edit, t('Save'));
129
    $this->assertText(t('The value @value provided for @field is not a valid URL.', array(
130
      '@value' => 'edik:naw',
131
      '@field' => $name,
132
    )));
133
  }
134

    
135
  /**
136
   * Test if we're stopped from posting a bad url with validation on.
137
   *
138
   * @codingStandardsIgnoreStart
139
   */
140
  public function test_link_validate_bad_url_validate_on() {
141
    // @codingStandardsIgnoreEnd
142
    $this->web_user = $this->drupalCreateUser(array(
143
      'administer content types',
144
      'administer fields',
145
      'administer nodes',
146
      'administer filters',
147
      'access content',
148
      'create page content',
149
      'access administration pages',
150
    ));
151
    $this->drupalLogin($this->web_user);
152

    
153
    // Create field.
154
    $name = strtolower($this->randomName());
155
    $edit = array(
156
      'fields[_add_new_field][label]' => $name,
157
      'fields[_add_new_field][field_name]' => $name,
158
      'fields[_add_new_field][type]' => 'link_field',
159
      'fields[_add_new_field][widget_type]' => 'link_field',
160
    );
161
    $this->drupalPost('admin/structure/types/manage/page/fields', $edit, t('Save'));
162
    $this->drupalPost(NULL, array(), t('Save field settings'));
163
    $this->drupalPost(NULL, array('instance[settings][validate_url]' => TRUE), t('Save settings'));
164

    
165
    // Is field created?
166
    $this->assertRaw(t('Saved %label configuration', array('%label' => $name)), 'Field added');
167
    node_types_rebuild();
168
    menu_rebuild();
169

    
170
    // Create page form.
171
    $this->drupalGet('node/add/page');
172
    $field_name = 'field_' . $name;
173
    $this->assertField('edit-field-' . $name . '-und-0-title', 'Title found');
174
    $this->assertField('edit-field-' . $name . '-und-0-url', 'URL found');
175

    
176
    $edit = array(
177
      'title' => 'Simple Title',
178
      $field_name . '[und][0][url]' => 'edik:naw',
179
    );
180

    
181
    $this->drupalPost(NULL, $edit, t('Save'));
182
    $this->assertText(t('The value @value provided for @field is not a valid URL.', array(
183
      '@field' => $name,
184
      '@value' => 'edik:naw',
185
    )));
186

    
187
  }
188

    
189
  /**
190
   * Test if we can post a bad url if the validation is expressly turned off.
191
   *
192
   * @codingStandardsIgnoreStart
193
   */
194
  public function test_link_validate_bad_url_validate_off() {
195
    // @codingStandardsIgnoreEnd
196
    $this->web_user = $this->drupalCreateUser(array(
197
      'administer content types',
198
      'administer fields',
199
      'administer nodes',
200
      'administer filters',
201
      'access content',
202
      'create page content',
203
      'access administration pages',
204
    ));
205
    $this->drupalLogin($this->web_user);
206

    
207
    // Create field.
208
    $name = strtolower($this->randomName());
209
    $edit = array(
210
      'fields[_add_new_field][label]' => $name,
211
      'fields[_add_new_field][field_name]' => $name,
212
      'fields[_add_new_field][type]' => 'link_field',
213
      'fields[_add_new_field][widget_type]' => 'link_field',
214
    );
215
    $this->drupalPost('admin/structure/types/manage/page/fields', $edit, t('Save'));
216
    $this->drupalPost(NULL, array(), t('Save field settings'));
217
    $this->drupalPost(NULL, array('instance[settings][validate_url]' => FALSE), t('Save settings'));
218

    
219
    // @codingStandardsIgnoreLine
220
    /*$instance_details = db_query("SELECT * FROM {field_config_instance} WHERE field_name = :field_name AND bundle = 'page'", array(':field_name' => 'field_'. $name))->fetchObject();
221
    $this->fail('<pre>'. print_r($instance_details, TRUE) .'</pre>');
222
    $this->fail('<pre>'. print_r(unserialize($instance_details->data), TRUE) .'</pre>');*/
223

    
224
    // Is field created?
225
    $this->assertRaw(t('Saved %label configuration', array('%label' => $name)), 'Field added');
226
    node_types_rebuild();
227
    menu_rebuild();
228

    
229
    // Create page form.
230
    $this->drupalGet('node/add/page');
231
    $field_name = 'field_' . $name;
232
    $this->assertField('edit-field-' . $name . '-und-0-title', 'Title found');
233
    $this->assertField('edit-field-' . $name . '-und-0-url', 'URL found');
234

    
235
    $edit = array(
236
      'title' => 'Simple Title',
237
      $field_name . '[und][0][url]' => 'edik:naw',
238
    );
239

    
240
    $this->drupalPost(NULL, $edit, t('Save'));
241
    $this->assertNoText(t('The value %value provided for %field is not a valid URL.', array(
242
      '%field' => $name,
243
      '%value' => 'edik:naw',
244
    )));
245
  }
246

    
247
  /**
248
   * Validate switching between validation status.
249
   *
250
   * Test if a bad url can sneak through un-filtered if we play with the
251
   * validation...
252
   *
253
   * @codingStandardsIgnoreStart
254
   */
255
  public function x_test_link_validate_switching_between_validation_status() {
256
    // @codingStandardsIgnoreEnd
257
    $this->acquireContentTypes(1);
258
    $this->web_user = $this->drupalCreateUser(array(
259
      'administer content types',
260
      'administer fields',
261
      'administer nodes',
262
      'access administration pages',
263
      'access content',
264
      'create ' . $this->content_types[0]->type . ' content',
265
      'edit any ' . $this->content_types[0]->type . ' content',
266
    ));
267
    $this->drupalLogin($this->web_user);
268
    variable_set('node_options_' . $this->content_types[0]->name, array(
269
      'status',
270
      'promote',
271
    ));
272
    $field_settings = array(
273
      'type' => 'link',
274
      'widget_type' => 'link',
275
      'type_name' => $this->content_types[0]->name,
276
      // <-- This is needed or we have an error.
277
      'attributes' => array(),
278
      'validate_url' => 0,
279
    );
280

    
281
    $field = $this->createField($field_settings, 0);
282

    
283
    $this->acquireNodes(2);
284

    
285
    $this->drupalGet('node/' . $this->nodes[0]->nid);
286

    
287
    $edit = array();
288
    $title = $this->randomName();
289
    $url = 'javascript:alert("http://example.com/' . $this->randomName() . '")';
290
    $edit[$field['field_name'] . '[0][url]'] = $url;
291
    $edit[$field['field_name'] . '[0][title]'] = $title;
292

    
293
    $this->drupalPost('node/' . $this->nodes[0]->nid . '/edit', $edit, t('Save'));
294
    // $this->pass($this->content);.
295
    // @codingStandardsIgnoreLine
296
    $this->assertNoText(t('The value %value provided for %field is not a valid URL.', array(
297
      '%field' => $name,
298
      '%value' => trim($url),
299
    )));
300

    
301
    // Make sure we get a new version!
302
    $node = node_load($this->nodes[0]->nid, NULL, TRUE);
303
    $this->assertEqual($url, $node->{$field['field_name']}[0]['url']);
304

    
305
    $this->drupalGet('node/' . $node->nid);
306
    $this->assertNoRaw($url, 'Make sure Javascript does not display.');
307

    
308
    // Turn the array validation back _on_.
309
    $edit = array('validate_url' => TRUE);
310
    $node_type_link = str_replace('_', '-', $node->type);
311
    // @codingStandardsIgnoreLine
312
    // $this->drupalGet('admin/content/node-type/'. $node_type_link .'/fields'); ///'. $field['field_name']);
313
    // $this->fail($this->content);.
314
    $this->drupalPost('admin/content/node-type/' . $node_type_link . '/fields/' . $field['field_name'], $edit, t('Save field settings'));
315

    
316
    $this->drupalGet('node/' . $node->nid);
317
    // This actually works because the display_url goes through the core
318
    // url() function.  But we should have a test that makes sure it continues
319
    // to work.
320
    $this->assertNoRaw($url, 'Make sure Javascript does not display.');
321
    // $this->fail($this->content);.
322
  }
323

    
324
  /**
325
   * Validate that '<front>' is a valid url.
326
   *
327
   * @codingStandardsIgnoreStart
328
   */
329
  public function test_link_front_url() {
330
    // @codingStandardsIgnoreEnd
331
    $this->link_test_validate_url('<front>');
332
  }
333

    
334
  /**
335
   * Validate that an internal url would be accepted.
336
   *
337
   * @codingStandardsIgnoreStart
338
   */
339
  public function test_link_internal_url() {
340
    // @codingStandardsIgnoreEnd
341
    // Create the content first.
342
    $node = $this->drupalCreateNode();
343

    
344
    $link = 'node/' . $node->nid;
345
    $this->link_test_validate_url($link);
346
    $type = link_url_type($link);
347
    $this->assertEqual(LINK_INTERNAL, $type, 'Test ' . $link . ' is an internal link.');
348
  }
349

    
350
  /**
351
   * Validate a simple mailto.
352
   *
353
   * @codingStandardsIgnoreStart
354
   */
355
  public function test_link_mailto() {
356
    // @codingStandardsIgnoreEnd
357
    $this->link_test_validate_url('mailto:jcfiala@gmail.com');
358
  }
359

    
360
  /**
361
   * Check link external https.
362
   *
363
   * @codingStandardsIgnoreStart
364
   */
365
  public function test_link_external_https() {
366
    // @codingStandardsIgnoreEnd
367
    $this->link_test_validate_url('https://www.example.com/');
368
  }
369

    
370
  /**
371
   * Check link FTP.
372
   *
373
   * @codingStandardsIgnoreStart
374
   */
375
  public function test_link_ftp() {
376
    // @codingStandardsIgnoreEnd
377
    $this->link_test_validate_url('ftp://www.example.com/');
378
  }
379

    
380
}
381

    
382
/**
383
 * Validate Test News.
384
 */
385
class LinkValidateTestNews extends LinkValidateTestCase {
386

    
387
  /**
388
   * Get Info.
389
   */
390
  public static function getInfo() {
391
    return array(
392
      'name' => 'Link News Validation Tests',
393
      'description' => 'Tests the field validation for usenet urls.',
394
      'group' => 'Link',
395
    );
396
  }
397

    
398
  /**
399
   * Validate a news link to a message group.
400
   *
401
   * @codingStandardsIgnoreStart
402
   */
403
  public function test_link_news() {
404
    // @codingStandardsIgnoreEnd
405
    $this->link_test_validate_url('news:comp.infosystems.www.misc');
406
  }
407

    
408
  /**
409
   * Validate a news link to a message id.  Said ID copied off of google groups.
410
   *
411
   * @codingStandardsIgnoreStart
412
   */
413
  public function test_link_news_message() {
414
    // @codingStandardsIgnoreEnd
415
    $this->link_test_validate_url('news:hj0db8$vrm$1@news.eternal-september.org');
416
  }
417

    
418
}
419

    
420
/**
421
 * Validate Specific URL.
422
 */
423
class LinkValidateSpecificURL extends LinkValidateTestCase {
424

    
425
  /**
426
   * Get Info.
427
   */
428
  public static function getInfo() {
429
    return array(
430
      'name' => 'Link Specific URL Validation Tests',
431
      'description' => 'Tests field validation with unusual urls',
432
      'group' => 'Link',
433
    );
434
  }
435

    
436
  /**
437
   * Lets throw in a lot of umlouts for testing!
438
   *
439
   * @codingStandardsIgnoreStart
440
   */
441
  public function test_umlout_url() {
442
    // @codingStandardsIgnoreEnd
443
    $this->link_test_validate_url('http://üÜü.exämple.com/nöde');
444
  }
445

    
446
  /**
447
   * Check umlout mailto.
448
   *
449
   * @codingStandardsIgnoreStart
450
   */
451
  public function test_umlout_mailto() {
452
    // @codingStandardsIgnoreEnd
453
    $this->link_test_validate_url('mailto:Üser@exÅmple.com');
454
  }
455

    
456
  /**
457
   * Check german b in url.
458
   *
459
   * @codingStandardsIgnoreStart
460
   */
461
  public function test_german_b_url() {
462
    // @codingStandardsIgnoreEnd
463
    $this->link_test_validate_url('http://www.test.com/ßstuff');
464
  }
465

    
466
  /**
467
   * Check Special in url.
468
   *
469
   * @codingStandardsIgnoreStart
470
   */
471
  public function test_special_n_url() {
472
    // @codingStandardsIgnoreEnd
473
    $this->link_test_validate_url('http://www.testÑñ.com/');
474
  }
475

    
476
  /**
477
   * Curly Brackets in query.
478
   *
479
   * @codingStandardsIgnoreStart
480
   */
481
  public function test_curly_brackets_in_query() {
482
    // @codingStandardsIgnoreEnd
483
    $this->link_test_validate_url('http://www.healthyteennetwork.org/index.asp?Type=B_PR&SEC={2AE1D600-4FC6-4B4D-8822-F1D5F072ED7B}&DE={235FD1E7-208D-4363-9854-4E6775EB8A4C}');
484
  }
485

    
486
  /**
487
   * Here, we're testing that a very long url is stored properly in the db.
488
   *
489
   * Basically, trying to test http://drupal.org/node/376818
490
   *
491
   * @codingStandardsIgnoreStart
492
   */
493
  public function testLinkURLFieldIsBig() {
494
    // @codingStandardsIgnoreEnd
495
    $long_url = 'http://th.wikipedia.org/wiki/%E0%B9%82%E0%B8%A3%E0%B8%87%E0%B9%80%E0%B8%A3%E0%B8%B5%E0%B8%A2%E0%B8%99%E0%B9%80%E0%B8%9A%E0%B8%8D%E0%B8%88%E0%B8%A1%E0%B8%A3%E0%B8%B2%E0%B8%8A%E0%B8%B9%E0%B8%97%E0%B8%B4%E0%B8%A8_%E0%B8%99%E0%B8%84%E0%B8%A3%E0%B8%A8%E0%B8%A3%E0%B8%B5%E0%B8%98%E0%B8%A3%E0%B8%A3%E0%B8%A1%E0%B8%A3%E0%B8%B2%E0%B8%8A';
496
    $this->link_test_validate_url($long_url);
497
  }
498

    
499
}
500

    
501
/**
502
 * Validate Url Light.
503
 *
504
 * A series of tests of links, only going against the link_validate_url function
505
 * in link.module.
506
 *
507
 * Validation is guided by the rules in http://tools.ietf.org/html/rfc1738 !
508
 */
509
class LinkValidateUrlLight extends DrupalWebTestCase {
510

    
511
  /**
512
   * Get Info.
513
   */
514
  public static function getInfo() {
515
    return array(
516
      'name' => 'Link Light Validation Tests',
517
      'description' => 'Tests the link_validate_url() function by itself, without invoking the full drupal/cck lifecycle.',
518
      'group' => 'Link',
519
    );
520
  }
521

    
522
  /**
523
   * Setup.
524
   */
525
  public function setUp() {
526
    parent::setUp('link');
527
  }
528

    
529
  /**
530
   * Name Link Type.
531
   *
532
   * Translates the LINK type constants to english for display and debugging of
533
   * tests.
534
   *
535
   * @codingStandardsIgnoreStart
536
   */
537
  public function name_Link_Type($type) {
538
    // @codingStandardsIgnoreEnd
539
    switch ($type) {
540
      case LINK_FRONT:
541
        return "Front";
542

    
543
      case LINK_EMAIL:
544
        return "Email";
545

    
546
      case LINK_NEWS:
547
        return "Newsgroup";
548

    
549
      case LINK_INTERNAL:
550
        return "Internal Link";
551

    
552
      case LINK_EXTERNAL:
553
        return "External Link";
554

    
555
      case FALSE:
556
        return "Invalid Link";
557

    
558
      default:
559
        return "Bad Value:" . $type;
560
    }
561
  }
562

    
563
  /**
564
   * Make sure that a link labeled <front> works.
565
   */
566
  public function testValidateFrontLink() {
567
    $valid = link_validate_url('<front>');
568
    $this->assertEqual(LINK_FRONT, $valid, 'Make sure that front link is verified and identified');
569
  }
570

    
571
  /**
572
   * Validate Email Link.
573
   */
574
  public function testValidateEmailLink() {
575
    $valid = link_validate_url('mailto:bob@example.com');
576
    $this->assertEqual(LINK_EMAIL, $valid, "Make sure a basic mailto is verified and identified");
577
  }
578

    
579
  /**
580
   * Validate Email Link Bad.
581
   */
582
  public function testValidateEmailLinkBad() {
583
    $valid = link_validate_url(':bob@example.com');
584
    $this->assertEqual(FALSE, $valid, 'Make sure just a bad address is correctly failed');
585
  }
586

    
587
  /**
588
   * Validate Newsgroup Link.
589
   */
590
  public function testValidateNewsgroupLink() {
591
    $valid = link_validate_url('news:comp.infosystems.www.misc');
592
    $this->assertEqual(LINK_NEWS, $valid, 'Make sure link to newsgroup validates as news.');
593
  }
594

    
595
  /**
596
   * Validate News Article Link.
597
   */
598
  public function testValidateNewsArticleLink() {
599
    $valid = link_validate_url('news:hj0db8$vrm$1@news.eternal-september.org');
600
    $this->assertEqual(LINK_NEWS, $valid, 'Make sure link to specific article validates as news.');
601
  }
602

    
603
  /**
604
   * Validate Bad Newsgroup Link.
605
   */
606
  public function testValidateBadNewsgroupLink() {
607
    $valid = link_validate_url('news:comp.bad_name.misc');
608
    $this->assertEqual(FALSE, $valid, 'newsgroup names can\'t contain underscores, so it should come back as invalid.');
609
  }
610

    
611
  /**
612
   * Validate Internal Links.
613
   */
614
  public function testValidateInternalLinks() {
615
    $tempfile = drupal_tempnam('public://files', 'test');
616
    $links = array(
617
      'rss.xml',
618
      file_uri_target($tempfile),
619
      drupal_realpath($tempfile),
620
    );
621

    
622
    foreach ($links as $link) {
623
      $type = link_url_type($link);
624
      $this->assertEqual(LINK_INTERNAL, $type, 'Test ' . $link . ' is an internal link.');
625
      $valid = link_validate_url($link);
626
      $this->assertTrue($valid, 'Test ' . $link . ' is valid internal link.');
627
    }
628
  }
629

    
630
  /**
631
   * Validate External Links.
632
   */
633
  public function testValidateExternalLinks() {
634
    $links = array(
635
      'http://localhost:8080/',
636
      'www.example.com',
637
      'www.example.com/',
638
      'http://username:p%40ssw0rd!@www.example.com/',
639
      'http://@www.example.com/',
640
      'http://username:@www.example.com/',
641
      'http://username:password@www.example.com:8080/',
642
      'http://127.0.0.1:80/',
643
      'http://127.173.24.255:4723/',
644
      '127.173.24.255:4723/',
645
      'http://255.255.255.255:4823/',
646
      'www.test-site.com',
647
      'http://example.com/index.php?q=node/123',
648
      'http://example.com/?first_name=Joe Bob&last_name=Smith',
649
      // Anchors.
650
      'http://www.example.com/index.php#test',
651
      'http://www.example.com/index.php#this@that.',
652
      'http://www.example.com/index.php#',
653
      'http://www.cnn.com/video/#/video/politics/2008/12/09/intv.madeleine.albright.cnn',
654
      'http://www.archive.org/stream/aesopsfables00aesorich#page/n7/mode/2up',
655
      'http://www.example.com/blah/#this@that?',
656
    );
657

    
658
    // Test all of the protocols.
659
    $allowed_protocols = variable_get('filter_allowed_protocols', array(
660
      'http',
661
      'https',
662
      'ftp',
663
      'news',
664
      'nntp',
665
      'telnet',
666
      'mailto',
667
      'irc',
668
      'ssh',
669
      'sftp',
670
      'webcal',
671
    ));
672

    
673
    foreach ($allowed_protocols as $protocol) {
674
      if ($protocol !== 'news' && $protocol !== 'mailto') {
675
        $links[] = $protocol . '://www.example.com';
676
      }
677
    }
678
    foreach ($links as $link) {
679
      $type = link_url_type($link);
680
      $this->assertEqual(LINK_EXTERNAL, $type, 'Testing that ' . $link . ' is an external link.');
681
      $valid = link_validate_url($link);
682
      $this->assertTrue($valid, 'Test ' . $link . ' is valid external link.');
683
      // The following two lines are commented out and only used for
684
      // comparisons.
685
      // $valid2 = valid_url($link, TRUE);
686
      // $this->assertEqual(TRUE, $valid2, "Using valid_url() on $link.");.
687
    }
688
  }
689

    
690
  /**
691
   * Check Invalid External Links.
692
   */
693
  public function testInvalidExternalLinks() {
694
    $links = array(
695
      'http://www.ex ample.com/',
696
      // Bad ip!
697
      'http://25.0.0/',
698
      'http://4827.0.0.2/',
699
      // ß not allowed in domain names!
700
      'http://www.testß.com/',
701
      // Bad TLD.
702
      'http://.www.foo.bar./',
703
      // Domains can't have sections starting with a dash.
704
      // 'http://www.-fudge.com/',
705
      'http://example.com/index.php?page=this\that',
706
      'example@example.com',
707
    );
708
    foreach ($links as $link) {
709
      $valid = link_validate_url($link);
710
      $this->assertEqual(FALSE, $valid, 'Testing that ' . $link . ' is not a valid link.');
711
    }
712
  }
713

    
714
}