Mercurial > hg > isophonics-drupal-site
diff core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php @ 18:af1871eacc83
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:33:08 +0100 |
parents | c2387f117808 |
children |
line wrap: on
line diff
--- a/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php Thu Feb 28 13:21:36 2019 +0000 +++ b/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php Thu May 09 15:33:08 2019 +0100 @@ -2,10 +2,11 @@ namespace Drupal\Tests\image\Functional; +use Drupal\Core\Url; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\field\Entity\FieldStorageConfig; use Drupal\Tests\TestFileCreationTrait; -use Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait; +use Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait; use Drupal\user\RoleInterface; use Drupal\image\Entity\ImageStyle; @@ -63,7 +64,7 @@ // Test for existence of link to image styles configuration. $this->drupalPostForm(NULL, [], "{$field_name}_settings_edit"); - $this->assertLinkByHref(\Drupal::url('entity.image_style.collection'), 0, 'Link to image styles configuration is found'); + $this->assertLinkByHref(Url::fromRoute('entity.image_style.collection')->toString(), 0, 'Link to image styles configuration is found'); // Remove 'administer image styles' permission from testing admin user. $admin_user_roles = $this->adminUser->getRoles(TRUE); @@ -74,7 +75,7 @@ // Test for absence of link to image styles configuration. $this->drupalPostForm(NULL, [], "{$field_name}_settings_edit"); - $this->assertNoLinkByHref(\Drupal::url('entity.image_style.collection'), 'Link to image styles configuration is absent when permissions are insufficient'); + $this->assertNoLinkByHref(Url::fromRoute('entity.image_style.collection')->toString(), 'Link to image styles configuration is absent when permissions are insufficient'); // Restore 'administer image styles' permission to testing admin user user_role_change_permissions(reset($admin_user_roles), ['administer image styles' => TRUE]); @@ -169,7 +170,7 @@ $elements = $this->xpath( '//a[@href=:path]/img[@src=:url and @alt=:alt and @width=:width and @height=:height]', [ - ':path' => $node->url(), + ':path' => $node->toUrl()->toString(), ':url' => file_url_transform_relative(file_create_url($image['#uri'])), ':width' => $image['#width'], ':height' => $image['#height'], @@ -277,7 +278,7 @@ $node = $node_storage->load($nid); $file = $node->{$field_name}->entity; - $url = file_url_transform_relative(file_create_url(ImageStyle::load('medium')->buildUrl($file->getFileUri()))); + $url = file_url_transform_relative(ImageStyle::load('medium')->buildUrl($file->getFileUri())); $this->assertTrue($this->cssSelect('img[width=40][height=20][class=image-style-medium][src="' . $url . '"]')); // Add alt/title fields to the image and verify that they are displayed. @@ -358,7 +359,7 @@ $this->drupalGet('node/' . $node->id()); // Verify that no image is displayed on the page by checking for the class // that would be used on the image field. - $this->assertNoPattern('<div class="(.*?)field--name-' . strtr($field_name, '_', '-') . '(.*?)">', 'No image displayed when no image is attached and no default image specified.'); + $this->assertSession()->responseNotMatches('<div class="(.*?)field--name-' . strtr($field_name, '_', '-') . '(.*?)">', 'No image displayed when no image is attached and no default image specified.'); $cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags'); $this->assertTrue(!preg_match('/ image_style\:/', $cache_tags_header), 'No image style cache tag found.'); @@ -377,7 +378,7 @@ \Drupal::entityManager()->clearCachedFieldDefinitions(); $field_storage = FieldStorageConfig::loadByName('node', $field_name); $default_image = $field_storage->getSetting('default_image'); - $file = \Drupal::entityManager()->loadEntityByUuid('file', $default_image['uuid']); + $file = \Drupal::service('entity.repository')->loadEntityByUuid('file', $default_image['uuid']); $this->assertTrue($file->isPermanent(), 'The default image status is permanent.'); $image = [ '#theme' => 'image', @@ -448,7 +449,7 @@ $private_field_storage = FieldStorageConfig::loadByName('node', $private_field_name); $default_image = $private_field_storage->getSetting('default_image'); - $file = \Drupal::entityManager()->loadEntityByUuid('file', $default_image['uuid']); + $file = \Drupal::service('entity.repository')->loadEntityByUuid('file', $default_image['uuid']); $this->assertEqual('private', file_uri_scheme($file->getFileUri()), 'Default image uses private:// scheme.'); $this->assertTrue($file->isPermanent(), 'The default image status is permanent.'); // Create a new node with no image attached and ensure that default private