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');
Comments
Comment #2
avpadernoComment #5
avpaderno