Problem/Motivation

There are a few deprecated methods shown when checking with "drupal-check" utility:

111/111 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 ------ -------------------------------------------------------------------------------------------------------------------------- 
  Line   entity_browser_testing/web/modules/contrib/entity_browser/src/Plugin/EntityBrowser/FieldWidgetDisplay/ImageThumbnail.php  
 ------ -------------------------------------------------------------------------------------------------------------------------- 
  98     Call to deprecated method isSubclassOf() of class Drupal\Core\Entity\EntityTypeInterface.                                 
 ------ -------------------------------------------------------------------------------------------------------------------------- 

 ------ -------------------------------------------------------------------------------------------------------- 
  Line   entity_browser_testing/web/modules/contrib/entity_browser/tests/src/Functional/EntityBrowserUITest.php  
 ------ -------------------------------------------------------------------------------------------------------- 
  70     Call to deprecated method getUsername() of class Drupal\user\Entity\User.                               
 ------ -------------------------------------------------------------------------------------------------------- 

 ------ ---------------------------------------------------------------------------------------------------------------- 
  Line   entity_browser_testing/web/modules/contrib/entity_browser/tests/src/Functional/EntityBrowserUpdateHookTest.php  
 ------ ---------------------------------------------------------------------------------------------------------------- 
  43     Call to deprecated method assertRaw() of class Drupal\Tests\BrowserTestBase.                                    
  44     Call to deprecated method assertRaw() of class Drupal\Tests\BrowserTestBase.                                    
  56     Call to deprecated method assertEqual() of class Drupal\Tests\BrowserTestBase.                                  
  67     Call to deprecated method assertEqual() of class Drupal\Tests\BrowserTestBase.                                  
 ------ ---------------------------------------------------------------------------------------------------------------- 

 ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- 


                                                                                                                        
 [ERROR] Found 6 errors                                                                                                 
                                                                                                                        

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

ChaseOnTheWeb created an issue. See original summary.

sergiu stici’s picture

Status: Active » Needs review
StatusFileSize
new3.61 KB

Here is the patch, please review.

oknate’s picture

Status: Needs review » Needs work

We don't want to change the deprecated class. This is for backwards compatibility. The rest of the patch looks fine, as a start.

diff --git a/tests/src/FunctionalJavascript/EntityBrowserJavascriptTestBase.php b/tests/src/FunctionalJavascript/EntityBrowserJavascriptTestBase.php
index bece737..84aacbc 100644
--- a/tests/src/FunctionalJavascript/EntityBrowserJavascriptTestBase.php
+++ b/tests/src/FunctionalJavascript/EntityBrowserJavascriptTestBase.php
@@ -7,7 +7,7 @@ use Drupal\Core\Field\FieldStorageDefinitionInterface;
 use Drupal\file\Entity\File;
 use Drupal\field\Entity\FieldConfig;
 use Drupal\field\Entity\FieldStorageConfig;
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 
 /**
  * Base class for Entity browser Javascript functional tests.
@@ -19,7 +19,7 @@ use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
  *
  * @see \Drupal\FunctionalJavascriptTests\JavascriptTestBase for more info.
  */
-abstract class EntityBrowserJavascriptTestBase extends JavascriptTestBase {
+abstract class EntityBrowserJavascriptTestBase extends WebDriverTestBase {
oknate’s picture

Title: Drupal 9 Deprecated Code Report » Pass Drupal 9 Deprecated Code Report using drupal-check
Issue summary: View changes
oknate’s picture

Issue summary: View changes
Issue tags: +Novice
oknate’s picture

StatusFileSize
new3.33 KB

Here's an updated patch. The last patch, #2 was actually fine, except for changing the deprecated class. It just missed one:

Call to deprecated method getUsername() of class Drupal\user\Entity\User.

Adding that one.

oknate’s picture

Status: Needs work » Needs review
berdir’s picture

Status: Needs review » Needs work
  1. +++ b/tests/src/Functional/EntityBrowserUITest.php
    @@ -67,7 +67,7 @@ class EntityBrowserUITest extends BrowserTestBase {
         $file = File::load(1);
         // Test entity browser token that has upload location configured to
         // public://[current-user:account-name]/.
    -    $this->assertEquals($file->getFileUri(), 'public://' . $account->getUsername() . '/' . $file->getFilename(), 'Image has the correct uri.');
    +    $this->assertEquals($file->getFileUri(), 'public://' . $account->getDisplayName() . '/' . $file->getFilename(), 'Image has the correct uri.');
    

    This is the wrong method, as the token, based on the comment above is account name, not token name. By default, they are the same, but display name runs through an alter hook and could be changed.

  2. +++ b/tests/src/Functional/EntityBrowserUpdateHookTest.php
    @@ -53,7 +53,7 @@ class EntityBrowserUpdateHookTest extends UpdatePathTestBase {
     
         $this->assertNull($browser->get('submit_text'), 'Old submit text is gone');
    -    $this->assertEqual($browser->get('widgets.a4ad947c-9669-497c-9988-24351955a02f.settings.submit_text'), 'All animals are created equal', 'New submit text appears on the widget.');
    +    $this->assertEquals( 'All animals are created equal', $browser->get('widgets.a4ad947c-9669-497c-9988-24351955a02f.settings.submit_text'), 'New submit text appears on the widget.');
    

    "( '", unnecessary space.

  3. +++ b/tests/src/Functional/EntityBrowserUpdateHookTest.php
    @@ -64,7 +64,7 @@ class EntityBrowserUpdateHookTest extends UpdatePathTestBase {
     
    -    $this->assertEqual($view->get('display.default.display_options.fields.entity_browser_select.table'), 'node', 'Data table in "entity_browser_select" replaced with data field.');
    +    $this->assertEquals( 'node', $view->get('display.default.display_options.fields.entity_browser_select.table'), 'Data table in "entity_browser_select" replaced with data field.');
       }
    

    same.

oknate’s picture

Status: Needs work » Needs review
StatusFileSize
new2.14 KB
new3.33 KB

Thanks! I should have run it through my coder linter. And thanks for pointing out that it should be getAccountName() not getDisplayName().

berdir’s picture

Status: Needs review » Reviewed & tested by the community

  • oknate committed 7ba427f on 8.x-2.x
    Issue #3042583 by oknate, Sergiu Stici: Pass Drupal 9 Deprecated Code...

  • oknate committed 2c6e515 on 8.x-1.x
    Issue #3042583 by oknate, Sergiu Stici: Pass Drupal 9 Deprecated Code...
oknate’s picture

Committed, thanks!

oknate’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: -midcamp2019

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.