| 7 user.test | private UserBlocksUnitTests::insertSession(array $fields = array()) |
| 8 user.test | private UserBlocksUnitTests::insertSession(array $fields = array()) |
Insert a user session into the {sessions} table. This function is used since we cannot log in more than one user at the same time in tests.
File
- modules/
user/ user.test, line 1568 - Tests for user.module.
Code
private function insertSession(array $fields = array()) {
$fields += array(
'uid' => 0,
'sid' => drupal_hash_base64(uniqid(mt_rand(), TRUE)),
'timestamp' => REQUEST_TIME,
);
db_insert('sessions')
->fields($fields)
->execute();
$this->assertEqual(db_query("SELECT COUNT(*) FROM {sessions} WHERE uid = :uid AND sid = :sid AND timestamp = :timestamp", array(':uid' => $fields['uid'], ':sid' => $fields['sid'], ':timestamp' => $fields['timestamp']))->fetchField(), 1, t('Session record inserted.'));
}
Login or register to post comments