Projet

Général

Profil

Révision 175ce36f

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

-a

Voir les différences:

drupal7/modules/path/path.test
21 21
    parent::setUp('path');
22 22

  
23 23
    // Create test user and login.
24
    $web_user = $this->drupalCreateUser(array('create page content', 'edit own page content', 'administer url aliases', 'create url aliases'));
24
    $web_user = $this->drupalCreateUser(array('create page content', 'edit own page content', 'administer url aliases', 'create url aliases', 'access content overview'));
25 25
    $this->drupalLogin($web_user);
26 26
  }
27 27

  
......
160 160
    $this->drupalGet($edit['path[alias]']);
161 161
    $this->assertNoText($node1->title, 'Alias was successfully deleted.');
162 162
    $this->assertResponse(404);
163

  
164
    // Create third test node.
165
    $node3 = $this->drupalCreateNode();
166

  
167
    // Create an invalid alias with a leading slash and verify that the slash
168
    // is removed when the link is generated. This ensures that URL aliases
169
    // cannot be used to inject external URLs.
170
    // @todo The user interface should either display an error message or
171
    //   automatically trim these invalid aliases, rather than allowing them to
172
    //   be silently created, at which point the functional aspects of this
173
    //   test will need to be moved elsewhere and switch to using a
174
    //   programmatically-created alias instead.
175
    $alias = $this->randomName(8);
176
    $edit = array('path[alias]' => '/' . $alias);
177
    $this->drupalPost('node/' . $node3->nid . '/edit', $edit, t('Save'));
178
    $this->drupalGet('admin/content');
179
    // This checks the link href before clicking it, rather than using
180
    // DrupalWebTestCase::assertUrl() after clicking it, because the test
181
    // browser does not always preserve the correct number of slashes in the
182
    // URL when it visits internal links; using DrupalWebTestCase::assertUrl()
183
    // would actually make the test pass unconditionally on the testbot (or
184
    // anywhere else where Drupal is installed in a subdirectory).
185
    $link_xpath = $this->xpath('//a[normalize-space(text())=:label]', array(':label' => $node3->title));
186
    $link_href = (string) $link_xpath[0]['href'];
187
    $link_prefix = base_path() . (variable_get('clean_url', 0) ? '' : '?q=');
188
    $this->assertEqual($link_href, $link_prefix . $alias);
189
    $this->clickLink($node3->title);
190
    $this->assertResponse(404);
163 191
  }
164 192

  
165 193
  /**

Formats disponibles : Unified diff