Révision 5587145e
Ajouté par Assos Assos il y a presque 7 ans
drupal7/modules/user/user.test | ||
---|---|---|
465 | 465 |
); |
466 | 466 |
} |
467 | 467 |
|
468 |
/** |
|
469 |
* Retrieves password reset email and extracts the login link. |
|
470 |
*/ |
|
471 |
public function getResetURL() { |
|
472 |
// Assume the most recent email. |
|
473 |
$_emails = $this->drupalGetMails(); |
|
474 |
$email = end($_emails); |
|
475 |
$urls = array(); |
|
476 |
preg_match('#.+user/reset/.+#', $email['body'], $urls); |
|
477 |
|
|
478 |
return $urls[0]; |
|
479 |
} |
|
480 |
|
|
468 | 481 |
/** |
469 | 482 |
* Tests password reset functionality. |
470 | 483 |
*/ |
... | ... | |
478 | 491 |
$this->drupalPost('user/password', $edit, t('E-mail new password')); |
479 | 492 |
// Confirm the password reset. |
480 | 493 |
$this->assertText(t('Further instructions have been sent to your e-mail address.'), 'Password reset instructions mailed message displayed.'); |
494 |
|
|
495 |
// Create an image field to enable an Ajax request on the user profile page. |
|
496 |
$field = array( |
|
497 |
'field_name' => 'field_avatar', |
|
498 |
'type' => 'image', |
|
499 |
'settings' => array(), |
|
500 |
'cardinality' => 1, |
|
501 |
); |
|
502 |
field_create_field($field); |
|
503 |
|
|
504 |
$instance = array( |
|
505 |
'field_name' => $field['field_name'], |
|
506 |
'entity_type' => 'user', |
|
507 |
'label' => 'Avatar', |
|
508 |
'bundle' => 'user', |
|
509 |
'required' => FALSE, |
|
510 |
'settings' => array(), |
|
511 |
'widget' => array( |
|
512 |
'type' => 'image_image', |
|
513 |
'settings' => array(), |
|
514 |
), |
|
515 |
); |
|
516 |
field_create_instance($instance); |
|
517 |
|
|
518 |
$resetURL = $this->getResetURL(); |
|
519 |
$this->drupalGet($resetURL); |
|
520 |
|
|
521 |
// Check successful login. |
|
522 |
$this->drupalPost(NULL, NULL, t('Log in')); |
|
523 |
|
|
524 |
// Make sure the Ajax request from uploading a file does not invalidate the |
|
525 |
// reset token. |
|
526 |
$image = current($this->drupalGetTestFiles('image')); |
|
527 |
$edit = array( |
|
528 |
'files[field_avatar_und_0]' => drupal_realpath($image->uri), |
|
529 |
); |
|
530 |
$this->drupalPostAJAX(NULL, $edit, 'field_avatar_und_0_upload_button'); |
|
531 |
|
|
532 |
// Change the forgotten password. |
|
533 |
$password = user_password(); |
|
534 |
$edit = array('pass[pass1]' => $password, 'pass[pass2]' => $password); |
|
535 |
$this->drupalPost(NULL, $edit, t('Save')); |
|
536 |
$this->assertText(t('The changes have been saved.'), 'Forgotten password changed.'); |
|
481 | 537 |
} |
482 | 538 |
|
483 | 539 |
/** |
... | ... | |
1529 | 1585 |
// Setup date/time settings for Los Angeles time. |
1530 | 1586 |
variable_set('date_default_timezone', 'America/Los_Angeles'); |
1531 | 1587 |
variable_set('configurable_timezones', 1); |
1532 |
variable_set('date_format_medium', 'Y-m-d H:i T'); |
|
1588 |
|
|
1589 |
// Override the 'medium' date format, which is the default for node |
|
1590 |
// creation time. Since we are testing time zones with Daylight Saving |
|
1591 |
// Time, and need to future proof against changes to the zoneinfo database, |
|
1592 |
// we choose the 'I' format placeholder instead of a human-readable zone |
|
1593 |
// name. With 'I', a 1 means the date is in DST, and 0 if not. |
|
1594 |
variable_set('date_format_medium', 'Y-m-d H:i I'); |
|
1533 | 1595 |
|
1534 | 1596 |
// Create a user account and login. |
1535 | 1597 |
$web_user = $this->drupalCreateUser(); |
... | ... | |
1547 | 1609 |
|
1548 | 1610 |
// Confirm date format and time zone. |
1549 | 1611 |
$this->drupalGet("node/$node1->nid"); |
1550 |
$this->assertText('2007-03-09 21:00 PST', 'Date should be PST.');
|
|
1612 |
$this->assertText('2007-03-09 21:00 0', 'Date should be PST.');
|
|
1551 | 1613 |
$this->drupalGet("node/$node2->nid"); |
1552 |
$this->assertText('2007-03-11 01:00 PST', 'Date should be PST.');
|
|
1614 |
$this->assertText('2007-03-11 01:00 0', 'Date should be PST.');
|
|
1553 | 1615 |
$this->drupalGet("node/$node3->nid"); |
1554 |
$this->assertText('2007-03-20 21:00 PDT', 'Date should be PDT.');
|
|
1616 |
$this->assertText('2007-03-20 21:00 1', 'Date should be PDT.');
|
|
1555 | 1617 |
|
1556 | 1618 |
// Change user time zone to Santiago time. |
1557 | 1619 |
$edit = array(); |
... | ... | |
1562 | 1624 |
|
1563 | 1625 |
// Confirm date format and time zone. |
1564 | 1626 |
$this->drupalGet("node/$node1->nid"); |
1565 |
$this->assertText('2007-03-10 02:00 CLST', 'Date should be Chile summer time; five hours ahead of PST.');
|
|
1627 |
$this->assertText('2007-03-10 02:00 1', 'Date should be Chile summer time; five hours ahead of PST.');
|
|
1566 | 1628 |
$this->drupalGet("node/$node2->nid"); |
1567 |
$this->assertText('2007-03-11 05:00 CLT', 'Date should be Chile time; four hours ahead of PST');
|
|
1629 |
$this->assertText('2007-03-11 05:00 0', 'Date should be Chile time; four hours ahead of PST');
|
|
1568 | 1630 |
$this->drupalGet("node/$node3->nid"); |
1569 |
$this->assertText('2007-03-21 00:00 CLT', 'Date should be Chile time; three hours ahead of PDT.');
|
|
1631 |
$this->assertText('2007-03-21 00:00 0', 'Date should be Chile time; three hours ahead of PDT.');
|
|
1570 | 1632 |
} |
1571 | 1633 |
} |
1572 | 1634 |
|
Formats disponibles : Unified diff
Update to 7.56