Tests creation, display, and deletion of user pictures.
function testCreateDeletePicture() {
$this
->drupalLogin($this->web_user);
// Save a new picture.
$image = current($this
->drupalGetTestFiles('image'));
$file = $this
->saveUserPicture($image);
// Verify that the image is displayed on the user account page.
$this
->drupalGet('user');
$this
->assertRaw(file_uri_target($file->uri), 'User picture found on user account page.');
// Delete the picture.
$edit = array();
$this
->drupalPost('user/' . $this->web_user->uid . '/edit', $edit, t('Remove'));
$this
->drupalPost(NULL, array(), t('Save'));
// Call system_cron() to clean up the file. Make sure the timestamp
// of the file is older than DRUPAL_MAXIMUM_TEMP_FILE_AGE.
db_update('file_managed')
->fields(array(
'timestamp' => REQUEST_TIME - (DRUPAL_MAXIMUM_TEMP_FILE_AGE + 1),
))
->condition('fid', $file->fid)
->execute();
drupal_cron_run();
// Verify that the image has been deleted.
$this
->assertFalse(file_load($file->fid), 'File was removed from the database.');
// Clear out PHP's file stat cache so we see the current value.
clearstatcache(TRUE, $file->uri);
$this
->assertFalse(is_file($file->uri), 'File was removed from the file system.');
}