Projet

Général

Profil

Révision c8740e19

Ajouté par Assos Assos il y a plus de 9 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/link/tests/link.validate.test
34 34
      $field_name . '[und][0][url]' => $url,
35 35
    );
36 36
    $this->drupalPost(NULL, $edit, t('Save'));
37
    $this->assertRaw(t(' has been created.'), 'Node created');
37
    $this->assertRaw(' has been created.', 'Node created');
38 38

  
39 39
    $nid = 1; //$matches[1];
40 40

  
......
90 90
    // create page form
91 91
    $this->drupalGet('node/add/page');
92 92
    $field_name = 'field_' . $name;
93
    $this->assertField('edit-field-'. $name .'-und-0-title', 'Title found');
94
    $this->assertField('edit-field-'. $name .'-und-0-url', 'URL found');
93
    $this->assertField('edit-field-' . $name . '-und-0-title', 'Title found');
94
    $this->assertField('edit-field-' . $name . '-und-0-url', 'URL found');
95 95

  
96 96

  
97 97
    $edit = array(
98 98
      'title' => 'Simple Title',
99
      $field_name .'[und][0][url]' => 'edik:naw',
99
      $field_name . '[und][0][url]' => 'edik:naw',
100 100
    );
101 101

  
102 102
    $this->drupalPost(NULL, $edit, t('Save'));
103
    $this->assertText(t('The value provided for @field is not a valid URL.', array('@field' => $name)));
103
    $this->assertText(t('The value @value provided for @field is not a valid URL.', array('@value' => 'edik:naw', '@field' => $name)));
104 104
  }
105 105

  
106 106
  /**
......
135 135
    // create page form
136 136
    $this->drupalGet('node/add/page');
137 137
    $field_name = 'field_' . $name;
138
    $this->assertField('edit-field-'. $name .'-und-0-title', 'Title found');
139
    $this->assertField('edit-field-'. $name .'-und-0-url', 'URL found');
138
    $this->assertField('edit-field-' . $name . '-und-0-title', 'Title found');
139
    $this->assertField('edit-field-' . $name . '-und-0-url', 'URL found');
140 140

  
141 141

  
142 142
    $edit = array(
143 143
      'title' => 'Simple Title',
144
      $field_name .'[und][0][url]' => 'edik:naw',
144
      $field_name . '[und][0][url]' => 'edik:naw',
145 145
    );
146 146

  
147 147
    $this->drupalPost(NULL, $edit, t('Save'));
148
    $this->assertText(t('The value provided for @field is not a valid URL.', array('@field' => $name)));
148
    $this->assertText(t('The value @value provided for @field is not a valid URL.', array('@field' => $name, '@value' => 'edik:naw')));
149 149

  
150 150
  }
151 151

  
......
185 185
    // create page form
186 186
    $this->drupalGet('node/add/page');
187 187
    $field_name = 'field_' . $name;
188
    $this->assertField('edit-field-'. $name .'-und-0-title', 'Title found');
189
    $this->assertField('edit-field-'. $name .'-und-0-url', 'URL found');
188
    $this->assertField('edit-field-' . $name . '-und-0-title', 'Title found');
189
    $this->assertField('edit-field-' . $name . '-und-0-url', 'URL found');
190 190

  
191 191

  
192 192
    $edit = array(
193 193
      'title' => 'Simple Title',
194
      $field_name .'[und][0][url]' => 'edik:naw',
194
      $field_name . '[und][0][url]' => 'edik:naw',
195 195
    );
196 196

  
197 197
    $this->drupalPost(NULL, $edit, t('Save'));
198
    $this->assertNoText(t('The value provided for @field is not a valid URL.', array('@field' => $name)));
198
    $this->assertNoText(t('The value %value provided for %field is not a valid URL.', array('%field' => $name, '%value' => 'edik:naw')));
199 199
  }
200 200

  
201 201
  /**
......
207 207
                                             'administer nodes',
208 208
                                             'access administration pages',
209 209
                                             'access content',
210
                                             'create '. $this->content_types[0]->type .' content',
211
                                             'edit any '. $this->content_types[0]->type .' content'));
210
                                             'create ' . $this->content_types[0]->type . ' content',
211
                                             'edit any ' . $this->content_types[0]->type . ' content'));
212 212
    $this->drupalLogin($this->web_user);
213
    variable_set('node_options_'. $this->content_types[0]->name, array('status', 'promote'));
213
    variable_set('node_options_' . $this->content_types[0]->name, array('status', 'promote'));
214 214
    $field_settings = array(
215 215
      'type' => 'link',
216 216
      'widget_type' => 'link',
......
227 227

  
228 228
    $node = node_load($this->nodes[0]->nid);
229 229

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

  
232 232
    $edit = array();
233 233
    $title = $this->randomName();
234 234
    $url = 'javascript:alert("http://example.com/' . $this->randomName() . '")';
235
    $edit[$field['field_name'] .'[0][url]'] = $url;
236
    $edit[$field['field_name'] .'[0][title]'] = $title;
235
    $edit[$field['field_name'] . '[0][url]'] = $url;
236
    $edit[$field['field_name'] . '[0][title]'] = $title;
237 237

  
238
    $this->drupalPost('node/'. $this->nodes[0]->nid .'/edit', $edit, t('Save'));
238
    $this->drupalPost('node/' . $this->nodes[0]->nid . '/edit', $edit, t('Save'));
239 239
    //$this->pass($this->content);
240
    $this->assertNoText(t('The value provided for %field is not a valid URL.', array('%field' => $name)));
240
    $this->assertNoText(t('The value %value provided for %field is not a valid URL.', array('%field' => $name, '%value' => trim($url))));
241 241

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

  
246
    $this->drupalGet('node/'. $node->nid);
246
    $this->drupalGet('node/' . $node->nid);
247 247
    $this->assertNoRaw($url, 'Make sure Javascript does not display.');
248 248

  
249 249
    // Turn the array validation back _on_.
......
251 251
    $node_type_link = str_replace('_', '-', $node->type);
252 252
    //$this->drupalGet('admin/content/node-type/'. $node_type_link .'/fields'); ///'. $field['field_name']);
253 253
    //$this->fail($this->content);
254
    $this->drupalPost('admin/content/node-type/'. $node_type_link .'/fields/'. $field['field_name'], $edit, t('Save field settings'));
254
    $this->drupalPost('admin/content/node-type/' . $node_type_link . '/fields/' . $field['field_name'], $edit, t('Save field settings'));
255 255

  
256
    $this->drupalGet('node/'. $node->nid);
256
    $this->drupalGet('node/' . $node->nid);
257 257
    // This actually works because the display_url goes through the core
258 258
    // url() function.  But we should have a test that makes sure it continues
259 259
    // to work.
......
382 382
      case FALSE:
383 383
        return "Invalid Link";
384 384
      default:
385
        return "Bad Value:". $type;
385
        return "Bad Value:" . $type;
386 386
    }
387 387
  }
388 388

  
......
460 460
    $allowed_protocols = variable_get('filter_allowed_protocols', array('http', 'https', 'ftp', 'news', 'nntp', 'telnet', 'mailto', 'irc', 'ssh', 'sftp', 'webcal'));
461 461
    foreach ($allowed_protocols as $protocol) {
462 462
      if ($protocol !== 'news' && $protocol !== 'mailto') {
463
        $links[] = $protocol .'://www.example.com';
463
        $links[] = $protocol . '://www.example.com';
464 464
      }
465 465
    }
466 466
    foreach ($links as $link) {
467 467
      $valid = link_validate_url($link);
468
      $this->assertEqual(LINK_EXTERNAL, $valid, 'Testing that '. $link .' is a valid external link.');
468
      $this->assertEqual(LINK_EXTERNAL, $valid, 'Testing that ' . $link . ' is a valid external link.');
469 469
      // The following two lines are commented out and only used for comparisons.
470 470
      //$valid2 = valid_url($link, TRUE);
471 471
      //$this->assertEqual(TRUE, $valid2, "Using valid_url() on $link.");
......
488 488
    );
489 489
    foreach ($links as $link) {
490 490
      $valid = link_validate_url($link);
491
      $this->assertEqual(FALSE, $valid, 'Testing that '. $link .' is not a valid link.');
491
      $this->assertEqual(FALSE, $valid, 'Testing that ' . $link . ' is not a valid link.');
492 492
    }
493 493
  }
494 494
}

Formats disponibles : Unified diff