Problem/Motivation

UserRestrictionsBasicTest::testUserRestrictionsRecordExists() contains the following lines.

$restriction = $this->storage->load($this->id);
$this->assertTrue($restriction, 'User restriction exists in the database');

That assertion compares an object with a Boolean value, and it causes the test to fail with an error similar to the following one.

    Drupal\Tests\user_restrictions\Functional\UserRestrictionsBasicTest::testUserRestrictionsRecordExists
    User restriction exists in the database
    Failed asserting that Drupal\user_restrictions\Entity\UserRestrictions
    Object &0000000000000e8d0000000000000000 (
        'entityTypeId' => 'user_restrictions'
        'enforceIsNew' => null
        'typedData' => null
        'cacheContexts' => Array &0 ()
        'cacheTags' => Array &1 ()
        'cacheMaxAge' => -1
        '_serviceIds' => Array &2 ()
        '_entityStorages' => Array &3 ()
        'originalId' => 'test_rule_1'
        'status' => true
        'uuid' => '9a9b542b-a12b-4952-8840-755fe2689901'
        'isUninstalling' => false
        'langcode' => 'en'
        'third_party_settings' => Array &4 ()
        '_core' => Array &5 (
            'default_config_hash' =>
    'rUaHmRn6U4BJoxTT6udUZK185CLaa7GvEJ4rXo6BbFY'
        )
        'trustedData' => false
        'dependencies' => Array &6 ()
        'isSyncing' => false
        'name' => 'test_rule_1'
        'pattern' => '^lol.*'
        'label' => 'Test rule #1'
        'access_type' => false
        'expiry' => 2147483647
        'rule_type' => 'name'
    ) is true.

 

Proposed resolution

  • Replace $this->assertTrue($restriction, 'User restriction exists in the database'); with $this->assertNotNull($restriction, 'The user restriction exists in the database');
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

avpaderno created an issue. See original summary.

avpaderno’s picture

Status: Active » Needs review

  • avpaderno committed d2d14d42 on 2.0.x
    Issue #3547444: UserRestrictionsBasicTest::...
avpaderno’s picture

Status: Needs review » Fixed

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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