From 96b496a360c324f64ec824465e8d3dcc13076999 Mon Sep 17 00:00:00 2001 From: Eli Zoller Date: Mon, 23 Nov 2020 11:16:19 -0700 Subject: [PATCH] fix deprecations in tests --- tests/src/Functional/AddMediaToNodeTest.php | 2 +- tests/src/Functional/IslandoraImageFormatterTest.php | 4 ++-- .../src/Functional/JsonldSelfReferenceReactionTest.php | 2 +- tests/src/Functional/LinkHeaderTest.php | 5 ++--- tests/src/Functional/MediaSourceUpdateTest.php | 10 +++++----- tests/src/Functional/ViewModeAlterReactionTest.php | 2 +- 6 files changed, 12 insertions(+), 13 deletions(-) diff --git a/tests/src/Functional/AddMediaToNodeTest.php b/tests/src/Functional/AddMediaToNodeTest.php index 856f004f..5e53a761 100644 --- a/tests/src/Functional/AddMediaToNodeTest.php +++ b/tests/src/Functional/AddMediaToNodeTest.php @@ -3,7 +3,7 @@ namespace Drupal\Tests\islandora\Functional; use Drupal\Core\Url; -use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait; +use Drupal\Tests\field\Traits\EntityReferenceTestTrait; /** * Tests the RelatedLinkHeader view alter. diff --git a/tests/src/Functional/IslandoraImageFormatterTest.php b/tests/src/Functional/IslandoraImageFormatterTest.php index aa85162c..6baf1bfc 100644 --- a/tests/src/Functional/IslandoraImageFormatterTest.php +++ b/tests/src/Functional/IslandoraImageFormatterTest.php @@ -34,7 +34,7 @@ class IslandoraImageFormatterTest extends IslandoraFunctionalTestBase { 'type' => 'islandora_image', 'settings' => ['image_style' => NULL, 'image_link' => 'content'], ]; - $display = entity_get_display('media', $testImageMediaType->id(), 'default'); + $display = $this->container->get('entity_display.repository')->getViewDisplay('media', $testImageMediaType->id(), 'default'); $display->setComponent('field_media_image', $display_options) ->removeComponent('created') ->removeComponent('uid') @@ -81,7 +81,7 @@ class IslandoraImageFormatterTest extends IslandoraFunctionalTestBase { $elements = $this->xpath( '//a[@href=:path]/img[@src=:url and @alt=:alt and @title=:title]', [ - ':path' => $node->url(), + ':path' => $node->toUrl()->toString(), ':url' => file_url_transform_relative(file_create_url($file->getFileUri())), ':alt' => 'Some Alt', ':title' => 'Some Title', diff --git a/tests/src/Functional/JsonldSelfReferenceReactionTest.php b/tests/src/Functional/JsonldSelfReferenceReactionTest.php index 7f99d625..52242118 100644 --- a/tests/src/Functional/JsonldSelfReferenceReactionTest.php +++ b/tests/src/Functional/JsonldSelfReferenceReactionTest.php @@ -154,7 +154,7 @@ class JsonldSelfReferenceReactionTest extends IslandoraFunctionalTestBase { list($file, $media) = $this->makeMediaAndFile($account); $media_url = $media->url('canonical', ['absolute' => TRUE]); - $file_url = $file->url('canonical', ['absolute' => TRUE]); + $file_url = $file->createFileUrl(FALSE); $this->drupalGet($media_url); $this->assertSession()->statusCodeEquals(200); diff --git a/tests/src/Functional/LinkHeaderTest.php b/tests/src/Functional/LinkHeaderTest.php index 472986c2..2ec35ff5 100644 --- a/tests/src/Functional/LinkHeaderTest.php +++ b/tests/src/Functional/LinkHeaderTest.php @@ -135,15 +135,14 @@ class LinkHeaderTest extends IslandoraFunctionalTestBase { public function testMediaLinkHeaders() { // Get the file to check its url in the response headers. - $file_url = $this->file->url('canonical', ['absolute' => TRUE]); + $file_url = $this->file->createFileUrl(FALSE); $rest_url = Url::fromRoute('islandora.media_source_update', ['media' => $this->media->id()]) ->setAbsolute() ->toString(); - $media_url = $this->media->url('canonical', ['absolute' => TRUE]); + $media_url = $this->media->toUrl('canonical', ['absolute' => TRUE]); // Perform a GET request as anonymous. $this->drupalGet($media_url, [], ['Cache-Control: no-cache']); - // Check link headers. $this->assertTrue( $this->validateLinkHeaderWithUrl('describes', $file_url, '', 'text/plain') == 1, diff --git a/tests/src/Functional/MediaSourceUpdateTest.php b/tests/src/Functional/MediaSourceUpdateTest.php index 6994f2ab..fdea6aef 100644 --- a/tests/src/Functional/MediaSourceUpdateTest.php +++ b/tests/src/Functional/MediaSourceUpdateTest.php @@ -84,7 +84,7 @@ class MediaSourceUpdateTest extends IslandoraFunctionalTestBase { // Update without Content-Type header should fail with 400. $options = [ - 'auth' => [$this->account->getUsername(), $this->account->pass_raw], + 'auth' => [$this->account->getAccountName(), $this->account->pass_raw], 'http_errors' => FALSE, 'body' => $file_contents, ]; @@ -93,7 +93,7 @@ class MediaSourceUpdateTest extends IslandoraFunctionalTestBase { // Update without body should fail with 400. $options = [ - 'auth' => [$this->account->getUsername(), $this->account->pass_raw], + 'auth' => [$this->account->getAccountName(), $this->account->pass_raw], 'http_errors' => FALSE, 'headers' => [ 'Content-Type' => 'text/plain', @@ -104,7 +104,7 @@ class MediaSourceUpdateTest extends IslandoraFunctionalTestBase { // Should be successful. $options = [ - 'auth' => [$this->account->getUsername(), $this->account->pass_raw], + 'auth' => [$this->account->getAccountName(), $this->account->pass_raw], 'http_errors' => FALSE, 'headers' => [ 'Content-Type' => 'text/plain', @@ -116,10 +116,10 @@ class MediaSourceUpdateTest extends IslandoraFunctionalTestBase { // GET the media and compare file and metadata. $options = [ - 'auth' => [$this->account->getUsername(), $this->account->pass_raw], + 'auth' => [$this->account->getAccountName(), $this->account->pass_raw], 'http_errors' => FALSE, ]; - $url = $this->media->url('canonical', ['absolute' => TRUE]); + $url = $this->media->toUrl('canonical', ['absolute' => TRUE])->toString(); $response = $client->request('GET', $url . '?_format=json', $options); $updated = json_decode($response->getBody(), TRUE); diff --git a/tests/src/Functional/ViewModeAlterReactionTest.php b/tests/src/Functional/ViewModeAlterReactionTest.php index 04f07e00..14f26032 100644 --- a/tests/src/Functional/ViewModeAlterReactionTest.php +++ b/tests/src/Functional/ViewModeAlterReactionTest.php @@ -64,7 +64,7 @@ class ViewModeAlterReactionTest extends IslandoraFunctionalTestBase { $this->drupalLogin($account); // Stash the node's url. - $url = $this->referencer->url('canonical', ['absolute' => TRUE]); + $url = $this->referencer->toUrl('canonical', ['absolute' => TRUE]); $this->drupalGet($url); // Make sure we're viewing the default (e.g. the media field is displayed).