public function realistic_dummy_content_DatabaseTestCase::testUser in Realistic Dummy Content 7
File
- api/
tests/ realistic_dummy_content_api.db.test, line 158 - This file contains the testing code which requires the database. These tests are slower than the unit tests so we want to limit them.
Class
- realistic_dummy_content_DatabaseTestCase
- The test case
Code
public function testUser() {
// Create a user with devel_generate
module_load_include('inc', 'devel_generate');
devel_create_users(1, 0);
// Load the user and view
$user = user_load(2);
$filename = $user->picture->filename;
$this
->assertTrue(drupal_substr($filename, 0, drupal_strlen('dummyfile')) == 'dummyfile', 'The user\'s picture file was replaced as expected. We know this because the filename starts with the string "dummyfile"');
$current_picture = $user->picture;
user_save($user);
$user = user_load($user->uid);
$this
->assertTrue($current_picture == $user->picture, 'The dummy file generation happens when the user is first created, not when it is resaved.');
}