Skip to content

Commit 2e492ee

Browse files
committed
Static tests
1 parent 52f98fe commit 2e492ee

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

test/unittests/Database_Test.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,7 @@ protected function setUp(): void
9292
$this->factory = NDB_Factory::singleton();
9393
$this->factory->reset();
9494
$this->config = $this->factory->Config(CONFIG_XML);
95-
$database = $this->config->getSetting('database');
9695
$this->DB = $this->factory->database();
97-
98-
$this->factory->setDatabase($this->DB);
99-
$this->factory->setConfig($this->config);
10096
}
10197

10298
/**

test/unittests/UserTest.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,6 @@ protected function setUp(): void
279279
$this->_factory = \NDB_Factory::singleton();
280280
$this->_factory->reset();
281281
$this->_configMock = $this->_factory->Config(CONFIG_XML);
282-
$database = $this->_configMock->getSetting('database');
283282
$this->_dbMock = $this->_factory->database();
284283

285284
$mockconfig = $this->getMockBuilder('NDB_Config')->getMock();
@@ -312,6 +311,7 @@ protected function setUp(): void
312311
$this->_userInfo['Password_hash'] = $passwordHash;
313312
$this->_userInfoComplete['Password_hash'] = $passwordHash;
314313

314+
$this->_setUpTestDoublesForFactoryUser();
315315
$this->_user = \User::factory(self::USERNAME);
316316
}
317317

@@ -339,7 +339,6 @@ protected function tearDown(): void
339339
*/
340340
public function testFactoryRetrievesUserInfo()
341341
{
342-
$this->_setUpTestDoublesForFactoryUser();
343342
$this->_user = \User::factory(self::USERNAME);
344343
//validate _user Info
345344
$this->assertEquals($this->_userInfoComplete, $this->_user->getData());
@@ -354,7 +353,6 @@ public function testFactoryRetrievesUserInfo()
354353
*/
355354
public function testGetDataForLanguagePreferences()
356355
{
357-
$this->_setUpTestDoublesForFactoryUser();
358356
$this->_user = \User::factory(self::USERNAME);
359357
$this->assertEquals(
360358
$this->_userInfoComplete['language_preference'],
@@ -370,7 +368,6 @@ public function testGetDataForLanguagePreferences()
370368
*/
371369
public function testGetFullname()
372370
{
373-
$this->_setUpTestDoublesForFactoryUser();
374371
$this->_user = \User::factory(self::USERNAME);
375372
$this->assertEquals(
376373
$this->_userInfoComplete['Real_name'],
@@ -386,7 +383,6 @@ public function testGetFullname()
386383
*/
387384
public function testGetId()
388385
{
389-
$this->_setUpTestDoublesForFactoryUser();
390386
$this->_user = \User::factory(self::USERNAME);
391387
$this->assertEquals(
392388
$this->_userInfoComplete['ID'],
@@ -402,7 +398,6 @@ public function testGetId()
402398
*/
403399
public function testGetUsername()
404400
{
405-
$this->_setUpTestDoublesForFactoryUser();
406401
$this->_user = \User::factory(self::USERNAME);
407402
$this->assertEquals(
408403
$this->_userInfoComplete['UserID'],
@@ -662,10 +657,10 @@ public function testUpdatePasswordWithExpiration()
662657

663658
// Cause usePwnedPasswordsAPI config option to return false.
664659
$mockConfig = &$this->_mockConfig;
665-
'@phan-var \PHPUnit\Framework\MockObject\MockObject $mockConfig';
666660

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

663+
'@phan-var \PHPUnit\Framework\MockObject\MockObject $mockConfig';
669664
$mockConfig->expects($this->any())
670665
->method('settingEnabled')
671666
->willReturn(false);
@@ -701,6 +696,7 @@ public function testUpdatePasswordWithoutExpiry()
701696
->method('settingEnabled')
702697
->willReturn(false);
703698

699+
$mockConfig = &$this->_mockConfig;
704700
$this->_factory->setConfig($mockConfig);
705701

706702
$this->_user->updatePassword(

0 commit comments

Comments
 (0)