Skip to content

Commit 120a100

Browse files
committed
Fix unit tests
1 parent a8ad002 commit 120a100

7 files changed

Lines changed: 24 additions & 10 deletions

File tree

tests/modules/core/src/Auth/Process/AttributeLimitTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ public function testNULLMetadataAttrs(): void
120120
];
121121

122122
$result = self::processFilter($config, $request);
123+
/** @psalm-var array $attributes */
123124
$attributes = $result['Attributes'];
124125
$this->assertArrayHasKey('cn', $attributes);
125126
$this->assertArrayNotHasKey('mail', $attributes);
@@ -131,6 +132,7 @@ public function testNULLMetadataAttrs(): void
131132
];
132133

133134
$result = self::processFilter($config, $request);
135+
/** @psalm-var array $attributes */
134136
$attributes = $result['Attributes'];
135137
$this->assertCount(4, $attributes);
136138
$this->assertArrayHasKey('eduPersonTargetedID', $attributes);
@@ -205,6 +207,7 @@ public function testDefaultWithAttrs(): void
205207
];
206208

207209
$result = self::processFilter($config, self::$request);
210+
/** @psalm-var array $attributes */
208211
$attributes = $result['Attributes'];
209212
$this->assertCount(2, $attributes);
210213
$this->assertArrayHasKey('cn', $attributes);
@@ -252,6 +255,7 @@ public function testMatchAttributeValues(): void
252255
];
253256

254257
$result = self::processFilter($config, self::$request);
258+
/** @psalm-var array $attributes */
255259
$attributes = $result['Attributes'];
256260
$this->assertCount(1, $attributes);
257261
$this->assertArrayHasKey('eduPersonAffiliation', $attributes);
@@ -262,6 +266,7 @@ public function testMatchAttributeValues(): void
262266
];
263267

264268
$result = self::processFilter($config, self::$request);
269+
/** @psalm-var array $attributes */
265270
$attributes = $result['Attributes'];
266271
$this->assertCount(1, $attributes);
267272
$this->assertArrayHasKey('eduPersonAffiliation', $attributes);
@@ -271,6 +276,7 @@ public function testMatchAttributeValues(): void
271276
'eduPersonAffiliation' => ['student']
272277
];
273278
$result = self::processFilter($config, self::$request);
279+
/** @psalm-var array $attributes */
274280
$attributes = $result['Attributes'];
275281
$this->assertCount(0, $attributes);
276282

@@ -330,6 +336,7 @@ public function testMatchAttributeValuesIgnoreCase(): void
330336
];
331337

332338
$result = self::processFilter($config, self::$request);
339+
/** @psalm-var array $attributes */
333340
$attributes = $result['Attributes'];
334341
$this->assertCount(1, $attributes);
335342
$this->assertArrayHasKey('eduPersonAffiliation', $attributes);
@@ -340,6 +347,7 @@ public function testMatchAttributeValuesIgnoreCase(): void
340347
];
341348

342349
$result = self::processFilter($config, self::$request);
350+
/** @psalm-var array $attributes */
343351
$attributes = $result['Attributes'];
344352
$this->assertCount(1, $attributes);
345353
$this->assertArrayHasKey('eduPersonAffiliation', $attributes);
@@ -384,6 +392,7 @@ public function testMatchAttributeValuesRegex(): void
384392
];
385393

386394
$result = self::processFilter($config, $state);
395+
/** @psalm-var array $attributes */
387396
$attributes = $result['Attributes'];
388397
$this->assertCount(1, $attributes);
389398
$this->assertArrayHasKey('eduPersonEntitlement', $attributes);
@@ -403,6 +412,7 @@ public function testMatchAttributeValuesRegex(): void
403412
];
404413

405414
$result = self::processFilter($config, $state);
415+
/** @psalm-var array $attributes */
406416
$attributes = $result['Attributes'];
407417
$this->assertCount(1, $attributes);
408418
$this->assertArrayHasKey('eduPersonEntitlement', $attributes);
@@ -422,6 +432,7 @@ public function testMatchAttributeValuesRegex(): void
422432
];
423433

424434
$result = self::processFilter($config, $state);
435+
/** @psalm-var array $attributes */
425436
$attributes = $result['Attributes'];
426437
$this->assertCount(1, $attributes);
427438
$this->assertArrayHasKey('eduPersonEntitlement', $attributes);
@@ -449,6 +460,7 @@ public function testMatchAttributeValuesRegex(): void
449460
]
450461
];
451462
$result = self::processFilter($config, $state);
463+
/** @psalm-var array $attributes */
452464
$attributes = $result['Attributes'];
453465
$this->assertCount(1, $attributes);
454466
$this->assertArrayHasKey('eduPersonEntitlement', $attributes);

tests/modules/core/src/Auth/Process/CardinalitySingleTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,13 @@ private function processFilter(array $config, array $request): array
4545
protected function setUp(): void
4646
{
4747
Configuration::loadFromArray([], '[ARRAY]', 'simplesaml');
48+
<<<<<<< HEAD
4849
$this->httpUtils = $this->getMockBuilder(Utils\HTTP::class)
4950
->setMethods(['redirectTrustedURL'])
5051
->getMock();
52+
=======
53+
$this->httpUtils = $this->createStub(Utils\HTTP::class);
54+
>>>>>>> d7b3e17e7 (Fix unit tests)
5155
}
5256

5357

tests/modules/core/src/Auth/Process/CardinalityTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ private function processFilter(array $config, array $request): array
4646
protected function setUp(): void
4747
{
4848
Configuration::loadFromArray([], '[ARRAY]', 'simplesaml');
49-
$this->httpUtils = $this->getMockBuilder(Utils\HTTP::class)
50-
->setMethods(['redirectTrustedURL'])
51-
->getMock();
49+
$this->httpUtils = $this->createStub(Utils\HTTP::class);
5250
}
5351

5452

tests/modules/core/src/Auth/UserPassBaseTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function testAuthenticateECPCallsLoginAndSetsAttributes(): void
3030

3131
$stub = $this->getMockBuilder(UserPassBase::class)
3232
->disableOriginalConstructor()
33-
->setMethods(['login'])
33+
->onlyMethods(['login'])
3434
->getMockForAbstractClass();
3535

3636
$stub->expects($this->once())
@@ -110,7 +110,7 @@ public function testAuthenticateECPCallsLoginWithForcedUsername(): void
110110

111111
$stub = $this->getMockBuilder(UserPassBase::class)
112112
->disableOriginalConstructor()
113-
->setMethods(['login'])
113+
->onlyMethods(['login'])
114114
->getMockForAbstractClass();
115115

116116
$stub->expects($this->once())

tests/modules/core/src/Auth/UserPassOrgBaseTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function testRememberOrganizationEnabled(): void
3636
/** @var \SimpleSAML\Module\core\Auth\UserPassOrgBase $mockUserPassOrgBase */
3737
$mockUserPassOrgBase = $this->getMockBuilder(\SimpleSAML\Module\core\Auth\UserPassOrgBase::class)
3838
->setConstructorArgs([['AuthId' => 'my-org'], &$config])
39-
->setMethods([])
39+
->onlyMethods([])
4040
->getMockForAbstractClass();
4141
$this->assertTrue($mockUserPassOrgBase->getRememberOrganizationEnabled());
4242
}

tests/src/SimpleSAML/Store/RedisStoreTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ protected function setUp(): void
3939
$this->config = [];
4040

4141
$this->mocked_redis = $this->getMockBuilder(Client::class)
42-
->setMethods(['get', 'set', 'setex', 'del', 'disconnect', '__destruct'])
42+
->onlyMethods(['get', 'set', 'setex', 'del', 'disconnect', '__destruct'])
4343
->disableOriginalConstructor()
4444
->getMock();
4545

tests/src/SimpleSAML/Store/StoreFactoryTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ public function redisStore(): void
8989
/** @psalm-var \SimpleSAML\Store\RedisStore $store */
9090
$store = StoreFactory::getInstance($storeType);
9191
$store->redis = $this->getMockBuilder(Client::class)
92-
->setMethods(['get', 'set', 'setex', 'del', 'disconnect', '__destruct'])
93-
->disableOriginalConstructor()
94-
->getMock();
92+
->onlyMethods(['get', 'set', 'setex', 'del', 'disconnect', '__destruct'])
93+
->disableOriginalConstructor()
94+
->getMock();
9595

9696
$this->assertInstanceOf(Store\RedisStore::class, $store);
9797
}

0 commit comments

Comments
 (0)