Problem/Motivation

We need to actualize the code in the tests.

Proposed resolution

Avoid deprecated code and use best practices.

Remaining tasks

  • Properly inject services: use $this->container->get('service');
    i.e.:
    /**
       * Current user service.
       *
       * @var \Drupal\Core\Session\AccountProxyInterface 
       */
      protected $currentUser;
    . . . 
      /**
       * {@inheritdoc}
       */
      public function setUp() {
        parent::setUp();
        $this->currentUser = $this->container->get('current_user');
      }
    . . . 
      public function testExample() {
        $id = $this->currentUser->id();
      }
    
  • Replace deprecated assertion methods with recommended methods or use recommended methods of assertSession instance.
  • Avoid use t() functions calls since we do not test translation functionality. https://www.drupal.org/docs/8/phpunit/phpunit-browser-test-tutorial

User interface changes

-

API changes

-

Data model changes

-

Comments

voleger created an issue. See original summary.

voleger’s picture

Status: Active » Postponed
voleger’s picture

Unblocked

FYI: simpletest UI use strict mode to run module tests since 8.6.0 version of Drupal core. So for DX it's better to avoid to use the deprecated code in the module.

voleger’s picture

Title: [PP-1] Tests refactoring (part 2) » Tests refactoring (part 2)
Status: Postponed » Active
voleger’s picture

Status: Active » Needs review
StatusFileSize
new42.11 KB

First iteration.

voleger’s picture

Revert get the raw password.

voleger’s picture

Issue summary: View changes
StatusFileSize
new20.32 KB
new51.18 KB

Deprecated code from tests was removed
Also replaced t() calls.

voleger’s picture

StatusFileSize
new2.71 KB
new51.17 KB
voleger’s picture

StatusFileSize
new1.2 KB
new51.23 KB
voleger’s picture

StatusFileSize
new1.44 KB
new52.16 KB
voleger’s picture

Tests refactored. Needs review.

  • thedut committed 629589b on 8.x-2.x authored by voleger
    Issue #2977118 by voleger: Tests refactoring (part 2)
    
thedut’s picture

Status: Needs review » Fixed

commited ! Thanks !

Status: Fixed » Closed (fixed)

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