Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/user/tests/src/Functional/UserPictureTest.php @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | c75dbcec494b |
children |
comparison
equal
deleted
inserted
replaced
4:a9cd425dd02b | 5:12f9dff5fda9 |
---|---|
1 <?php | 1 <?php |
2 | 2 |
3 namespace Drupal\Tests\user\Functional; | 3 namespace Drupal\Tests\user\Functional; |
4 | 4 |
5 use Drupal\Core\Database\Database; | |
5 use Drupal\image\Entity\ImageStyle; | 6 use Drupal\image\Entity\ImageStyle; |
6 use Drupal\Tests\BrowserTestBase; | 7 use Drupal\Tests\BrowserTestBase; |
7 use Drupal\file\Entity\File; | 8 use Drupal\file\Entity\File; |
8 use Drupal\Tests\TestFileCreationTrait; | 9 use Drupal\Tests\TestFileCreationTrait; |
9 | 10 |
71 $this->drupalPostForm('user/' . $this->webUser->id() . '/edit', $edit, t('Remove')); | 72 $this->drupalPostForm('user/' . $this->webUser->id() . '/edit', $edit, t('Remove')); |
72 $this->drupalPostForm(NULL, [], t('Save')); | 73 $this->drupalPostForm(NULL, [], t('Save')); |
73 | 74 |
74 // Call file_cron() to clean up the file. Make sure the timestamp | 75 // Call file_cron() to clean up the file. Make sure the timestamp |
75 // of the file is older than the system.file.temporary_maximum_age | 76 // of the file is older than the system.file.temporary_maximum_age |
76 // configuration value. | 77 // configuration value. We use an UPDATE statement because using the API |
77 db_update('file_managed') | 78 // would set the timestamp. |
79 Database::getConnection()->update('file_managed') | |
78 ->fields([ | 80 ->fields([ |
79 'changed' => REQUEST_TIME - ($this->config('system.file')->get('temporary_maximum_age') + 1), | 81 'changed' => REQUEST_TIME - ($this->config('system.file')->get('temporary_maximum_age') + 1), |
80 ]) | 82 ]) |
81 ->condition('fid', $file->id()) | 83 ->condition('fid', $file->id()) |
82 ->execute(); | 84 ->execute(); |
105 $this->config('system.theme.global')->set('features.node_user_picture', TRUE)->save(); | 107 $this->config('system.theme.global')->set('features.node_user_picture', TRUE)->save(); |
106 | 108 |
107 $image_style_id = $this->config('core.entity_view_display.user.user.compact')->get('content.user_picture.settings.image_style'); | 109 $image_style_id = $this->config('core.entity_view_display.user.user.compact')->get('content.user_picture.settings.image_style'); |
108 $style = ImageStyle::load($image_style_id); | 110 $style = ImageStyle::load($image_style_id); |
109 $image_url = file_url_transform_relative($style->buildUrl($file->getfileUri())); | 111 $image_url = file_url_transform_relative($style->buildUrl($file->getfileUri())); |
110 $alt_text = 'Profile picture for user ' . $this->webUser->getUsername(); | 112 $alt_text = 'Profile picture for user ' . $this->webUser->getAccountName(); |
111 | 113 |
112 // Verify that the image is displayed on the node page. | 114 // Verify that the image is displayed on the node page. |
113 $this->drupalGet('node/' . $node->id()); | 115 $this->drupalGet('node/' . $node->id()); |
114 $elements = $this->cssSelect('.node__meta .field--name-user-picture img[alt="' . $alt_text . '"][src="' . $image_url . '"]'); | 116 $elements = $this->cssSelect('.node__meta .field--name-user-picture img[alt="' . $alt_text . '"][src="' . $image_url . '"]'); |
115 $this->assertEqual(count($elements), 1, 'User picture with alt text found on node page.'); | 117 $this->assertEqual(count($elements), 1, 'User picture with alt text found on node page.'); |