Skip to content

Commit

Permalink
setConfig in tests that use it, not all
Browse files Browse the repository at this point in the history
  • Loading branch information
driusan committed Mar 7, 2023
1 parent 7c096eb commit b7c1d4a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions test/unittests/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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';
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -696,6 +697,8 @@ public function testUpdatePasswordWithoutExpiry()
->method('settingEnabled')
->willReturn(false);

$this->_factory->setConfig($mockConfig);

$this->_user->updatePassword(
new \Password(\Utility::randomString(16))
);
Expand Down

0 comments on commit b7c1d4a

Please # to comment.