Projet

Général

Profil

Révision b0dc3a2e

Ajouté par Julien Enselme il y a plus de 7 ans

Update to Drupal 7.52

Voir les différences:

drupal7/modules/simpletest/simpletest.test
322 322
 * Test internal testing framework browser.
323 323
 */
324 324
class SimpleTestBrowserTestCase extends DrupalWebTestCase {
325

  
326
  /**
327
   * A flag indicating whether a cookie has been set in a test.
328
   *
329
   * @var bool
330
   */
331
  protected static $cookieSet = FALSE;
332

  
325 333
  public static function getInfo() {
326 334
    return array(
327 335
      'name' => 'SimpleTest browser',
......
380 388
    $urls = $this->xpath('//a[text()=:text]', array(':text' => 'A second "even more weird" link, in memory of George O\'Malley'));
381 389
    $this->assertEqual($urls[0]['href'], 'link2', 'Match with mixed single and double quotes.');
382 390
  }
391

  
392
  /**
393
   * Tests that cookies set during a request are available for testing.
394
   */
395
  public function testCookies() {
396
    // Check that the $this->cookies property is populated when a user logs in.
397
    $user = $this->drupalCreateUser();
398
    $edit = array('name' => $user->name, 'pass' => $user->pass_raw);
399
    $this->drupalPost('<front>', $edit, t('Log in'));
400
    $this->assertEqual(count($this->cookies), 1, 'A cookie is set when the user logs in.');
401

  
402
    // Check that the name and value of the cookie match the request data.
403
    $cookie_header = $this->drupalGetHeader('set-cookie', TRUE);
404

  
405
    // The name and value are located at the start of the string, separated by
406
    // an equals sign and ending in a semicolon.
407
    preg_match('/^([^=]+)=([^;]+)/', $cookie_header, $matches);
408
    $name = $matches[1];
409
    $value = $matches[2];
410

  
411
    $this->assertTrue(array_key_exists($name, $this->cookies), 'The cookie name is correct.');
412
    $this->assertEqual($value, $this->cookies[$name]['value'], 'The cookie value is correct.');
413

  
414
    // Set a flag indicating that a cookie has been set in this test.
415
    // @see SimpleTestBrowserTestCase::testCookieDoesNotBleed().
416
    self::$cookieSet = TRUE;
417
  }
418

  
419
  /**
420
   * Tests that the cookies from a previous test do not bleed into a new test.
421
   *
422
   * @see SimpleTestBrowserTestCase::testCookies().
423
   */
424
  public function testCookieDoesNotBleed() {
425
    // In order for this test to be effective it should always run after the
426
    // testCookies() test.
427
    $this->assertTrue(self::$cookieSet, 'Tests have been executed in the expected order.');
428
    $this->assertEqual(count($this->cookies), 0, 'No cookies are present at the start of a new test.');
429
  }
430

  
383 431
}
384 432

  
385 433
class SimpleTestMailCaptureTestCase extends DrupalWebTestCase {

Formats disponibles : Unified diff