From b7c1d4afc2ab3022492a6cdca9050dd2cf674700 Mon Sep 17 00:00:00 2001 From: Dave MacFarlane Date: Tue, 7 Mar 2023 15:53:42 -0500 Subject: [PATCH] setConfig in tests that use it, not all --- test/unittests/UserTest.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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)) );