Skip to content

Commit

Permalink
fix(user_ldap): Fix LDAP tests with new typing
Browse files Browse the repository at this point in the history
Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc committed Apr 9, 2024
1 parent 6d7ff2e commit 2c0718b
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions apps/user_ldap/tests/AccessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -481,15 +481,14 @@ public function testSetPasswordWithLdapNotAvailable() {
$this->connection
->expects($this->once())
->method('getConnectionResource')
->willReturn($connection);
->willThrowException(new \OC\ServerNotAvailableException('Connection to LDAP server could not be established'));
$this->ldap
->expects($this->once())
->method('isResource')
->with($connection)
->willReturn(false);
->expects($this->never())
->method('isResource');

/** @noinspection PhpUnhandledExceptionInspection */
$this->assertFalse($this->access->setPassword('CN=foo', 'MyPassword'));
$this->expectException(\OC\ServerNotAvailableException::class);
$this->expectExceptionMessage('Connection to LDAP server could not be established');
$this->access->setPassword('CN=foo', 'MyPassword');
}


Expand All @@ -505,11 +504,6 @@ public function testSetPasswordWithRejectedChange() {
->expects($this->any())
->method('getConnectionResource')
->willReturn($connection);
$this->ldap
->expects($this->once())
->method('isResource')
->with($connection)
->willReturn(true);
$this->ldap
->expects($this->once())
->method('modReplace')
Expand All @@ -529,11 +523,6 @@ public function testSetPassword() {
->expects($this->any())
->method('getConnectionResource')
->willReturn($connection);
$this->ldap
->expects($this->once())
->method('isResource')
->with($connection)
->willReturn(true);
$this->ldap
->expects($this->once())
->method('modReplace')
Expand Down Expand Up @@ -567,7 +556,7 @@ protected function prepareMocksForSearchTests(
->expects($this->any())
->method('isResource')
->willReturnCallback(function ($resource) {
return is_resource($resource) || is_object($resource);
return is_object($resource);
});
$this->ldap
->expects($this->any())
Expand Down

0 comments on commit 2c0718b

Please sign in to comment.