diff -u b/core/modules/user/user.test b/core/modules/user/user.test --- b/core/modules/user/user.test +++ b/core/modules/user/user.test @@ -926,14 +926,22 @@ class UserPictureTestCase extends DrupalWebTestCase { public static function getInfo() { return array( - 'name' => 'User picture', - 'description' => 'Assure that dimension check, extension check and image scaling work as designed.', - 'group' => 'User' + 'name' => 'User pictures', + 'description' => 'Tests user picture functionality.', + 'group' => 'User', ); } function setUp() { - parent::setUp(array('image')); + parent::setUp(array('image', 'comment')); + + $this->web_user = $this->drupalCreateUser(array( + 'access content', + 'access comments', + 'post comments', + 'skip comment approval', + )); + $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); // @see standard.install module_load_install('user'); @@ -946,8 +954,6 @@ 'weight' => 10, ); field_bundle_settings('user', 'user', $bundle_settings); - - $this->user = $this->drupalCreateUser(); } /** @@ -956,7 +962,7 @@ * @todo OINK? */ function DISABLEDtestExternalPicture() { - $this->drupalLogin($this->user); + $this->drupalLogin($this->web_user); // Set the default picture to an URI with a HTTP schema. $images = $this->drupalGetTestFiles('image'); $image = $images[0]; @@ -976,11 +982,10 @@ * Tests creation, display, and deletion of user pictures. */ function testCreateDeletePicture() { - $this->drupalLogin($this->user); - - $image = current($this->drupalGetTestFiles('image')); + $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. @@ -989,7 +994,7 @@ // Delete the picture. $edit = array(); - $this->drupalPost('user/' . $this->user->uid . '/edit', $edit, t('Remove')); + $this->drupalPost('user/' . $this->web_user->uid . '/edit', $edit, t('Remove')); $this->drupalPost(NULL, array(), t('Save')); // Verify that the image has been deleted. @@ -1000,21 +1005,32 @@ } /** - * Tests the admin form validates user picture settings. + * Tests embedded users on node pages. */ - function TODOtestUserPictureAdminFormValidation() { - $this->drupalLogin($this->drupalCreateUser(array('administer users'))); + function testPictureOnNodeComment() { + $this->drupalLogin($this->web_user); - // The default values are valid. - $this->drupalPost('admin/config/people/accounts', array(), t('Save configuration')); - $this->assertText(t('The configuration options have been saved.'), 'The default values are valid.'); + // Save a new picture. + $image = current($this->drupalGetTestFiles('image')); + $file = $this->saveUserPicture($image); + + $node = $this->drupalCreateNode(array('type' => 'article')); + + // Enable user pictures on nodes. + variable_set('theme_settings', array('toggle_node_user_picture' => TRUE)); + + // Verify that the image is displayed on the user account page. + $this->drupalGet('node/' . $node->nid); + $this->assertRaw(file_uri_target($file->uri), 'User picture found on node page.'); + + // Enable user pictures on comments, instead of nodes. + variable_set('theme_settings', array('toggle_comment_user_picture' => TRUE)); - // The form does not save with an invalid file size. $edit = array( - 'user_picture_file_size' => $this->randomName(), + 'comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]' => $this->randomString(), ); - $this->drupalPost('admin/config/people/accounts', $edit, t('Save configuration')); - $this->assertNoText(t('The configuration options have been saved.'), 'The form does not save with an invalid file size.'); + $this->drupalPost('comment/reply/' . $node->nid, $edit, t('Save')); + $this->assertRaw(file_uri_target($file->uri), 'User picture found on comment.'); } /** @@ -1022,58 +1038,14 @@ */ function saveUserPicture($image) { $edit = array('files[field_user_picture_und_0]' => drupal_realpath($image->uri)); - $this->drupalPost('user/' . $this->user->uid . '/edit', $edit, t('Save')); + $this->drupalPost('user/' . $this->web_user->uid . '/edit', $edit, t('Save')); // Load actual user data from database. - $account = user_load($this->user->uid, TRUE); + $account = user_load($this->web_user->uid, TRUE); return file_load($account->field_user_picture[LANGUAGE_NOT_SPECIFIED][0]['fid']); } } -/** - * Tests embedded users on entities. - */ -class UserAttachTestCase extends DrupalWebTestCase { - protected $profile = 'standard'; - - public static function getInfo() { - return array( - 'name' => 'Embedded user on node page', - 'description' => 'Verify that author details are shown on node and comment render.', - 'group' => 'User', - ); - } - - /** - * Tests embedded users on node pages. - */ - function testUserViewOnNodePage() { - $this->user = $this->drupalCreateUser(); - $this->drupalLogin($this->user); - $edit = array( - 'mail' => $this->user->mail, - ); - $test_image = current($this->drupalGetTestFiles('image')); - $edit['files[field_user_picture_' . LANGUAGE_NOT_SPECIFIED . '_0]'] = drupal_realpath($test_image->uri); - $this->drupalPost('user/' . $this->user->uid . '/edit', $edit, t('Save')); - - $node = $this->drupalCreateNode(array('type' => 'article')); - // Set display preferences so pictures are enabled for this content type. - variable_set('theme_settings', array('toggle_node_user_picture' => TRUE)); - variable_set('node_submitted_' . $node->type, TRUE); - $this->drupalGet('node/' . $node->nid); - $this->assertRaw('field-name-field-user-picture', 'User picture is shown on node render.'); - - // Disable picture for nodes and enable for comments. - variable_set('theme_settings', array('toggle_comment_user_picture' => TRUE)); - - $edit = array(); - $edit['comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]'] = $this->randomString(); - $this->drupalPost(NULL, $edit, t('Save')); - $this->assertRaw('field-name-field-user-picture', 'User picture is shown on comment render.'); - } -} - class UserPermissionsTestCase extends DrupalWebTestCase { protected $admin_user; protected $rid;