diff --git a/test/unittests/UserTest.php b/test/unittests/UserTest.php index 31b7d6afaf1..e2b0eb20083 100644 --- a/test/unittests/UserTest.php +++ b/test/unittests/UserTest.php @@ -276,7 +276,7 @@ class UserTest extends TestCase protected function setUp(): void { parent::setUp(); - $this->_factory = \NDB_Factory::singleton(); + $this->_factory = &\NDB_Factory::singleton(); $this->_factory->reset(); $this->_configMock = $this->_factory->Config(CONFIG_XML); $database = $this->_configMock->getSetting('database'); @@ -291,8 +291,6 @@ protected function setUp(): void $this->_mockDB = $mockdb; $this->_mockConfig = $mockconfig; - $this->_factory->setConfig($this->_mockConfig); - $this->_userInfoComplete = $this->_userInfo; $this->_userInfoComplete['ID'] = '1'; $this->_userInfoComplete['Privilege'] = '1'; @@ -661,6 +659,9 @@ public function testUpdatePasswordWithExpiration() // Cause usePwnedPasswordsAPI config option to return false. $mockConfig = &$this->_mockConfig; '@phan-var \PHPUnit\Framework\MockObject\MockObject $mockConfig'; + + $this->_factory->setConfig($mockConfig); + $mockConfig->expects($this->any()) ->method('settingEnabled') ->willReturn(false); @@ -696,6 +697,8 @@ public function testUpdatePasswordWithoutExpiry() ->method('settingEnabled') ->willReturn(false); + $this->_factory->setConfig($mockConfig); + $this->_user->updatePassword( new \Password(\Utility::randomString(16)) );