Verified Commit 67343dfe authored by Jess's avatar Jess
Browse files

Issue #3399992 by mstrelan, smustgrave, xjm: Fix strict type errors in test traits

(cherry picked from commit c304b092)
parent 8d0385f8
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -391,7 +391,7 @@ public function testLineBreakFilter() {
    $this->assertFilteredString($filter, $tests);

    // Very long string hitting PCRE limits.
    $limit = max(ini_get('pcre.backtrack_limit'), ini_get('pcre.recursion_limit'));
    $limit = max((int) ini_get('pcre.backtrack_limit'), (int) ini_get('pcre.recursion_limit'));
    $source = $this->randomMachineName($limit);
    $result = _filter_autop($source);
    $this->assertEquals($result, '<p>' . $source . "</p>\n", 'Line break filter can process very long strings.');
+3 −4
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@

namespace Drupal\Tests\user\Traits;

use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Database\DatabaseExceptionWrapper;
use Drupal\Core\Database\SchemaObjectExistsException;
use Drupal\Core\Entity\EntityStorageException;
@@ -191,7 +190,7 @@ protected function createUser(array $permissions = [], $name = NULL, $admin = FA
    $account->save();

    $valid_user = $account->id() !== NULL;
    $this->assertTrue($valid_user, new FormattableMarkup('User created with name %name and pass %pass', ['%name' => $edit['name'], '%pass' => $edit['pass']]));
    $this->assertTrue($valid_user, "User created with name {$edit['name']} and pass {$edit['pass']}");
    if (!$valid_user) {
      return FALSE;
    }
@@ -271,7 +270,7 @@ protected function createRole(array $permissions, $rid = NULL, $name = NULL, $we
    }
    $result = $role->save();

    $this->assertSame(SAVED_NEW, $result, new FormattableMarkup('Created role ID @rid with name @name.', ['@name' => var_export($role->label(), TRUE), '@rid' => var_export($role->id(), TRUE)]));
    $this->assertSame(SAVED_NEW, $result, "Created role ID {$role->id()} with name {$role->label()}.");

    if ($result === SAVED_NEW) {
      // Grant the specified permissions to the role, if any.
@@ -302,7 +301,7 @@ protected function checkPermissions(array $permissions) {
    $valid = TRUE;
    foreach ($permissions as $permission) {
      if (!in_array($permission, $available)) {
        $this->fail(new FormattableMarkup('Invalid permission %permission.', ['%permission' => $permission]));
        $this->fail("Invalid permission $permission.");
        $valid = FALSE;
      }
    }
+1 −1
Original line number Diff line number Diff line
@@ -137,7 +137,7 @@ protected function htmlOutput($message = NULL) {
   */
  protected function initBrowserOutputFile() {
    $browser_output_file = getenv('BROWSERTEST_OUTPUT_FILE');
    $this->htmlOutputEnabled = is_file($browser_output_file);
    $this->htmlOutputEnabled = is_string($browser_output_file) && is_file($browser_output_file);
    $this->htmlOutputBaseUrl = getenv('BROWSERTEST_OUTPUT_BASE_URL') ?: $GLOBALS['base_url'];
    if ($this->htmlOutputEnabled) {
      $this->htmlOutputFile = $browser_output_file;
+1 −2
Original line number Diff line number Diff line
@@ -3,7 +3,6 @@
namespace Drupal\Tests;

use Behat\Mink\Driver\BrowserKitDriver;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\Session\AccountInterface;
@@ -161,7 +160,7 @@ protected function drupalLogin(AccountInterface $account) {

    // @see ::drupalUserIsLoggedIn()
    $account->sessionId = $this->getSession()->getCookie(\Drupal::service('session_configuration')->getOptions(\Drupal::request())['name']);
    $this->assertTrue($this->drupalUserIsLoggedIn($account), new FormattableMarkup('User %name successfully logged in.', ['%name' => $account->getAccountName()]));
    $this->assertTrue($this->drupalUserIsLoggedIn($account), "User {$account->getAccountName()} successfully logged in.");

    $this->loggedInUser = $account;
    $this->container->get('current_user')->setAccount($account);