From 2c0718b912711a5873bcc6cf9e561f98d864f0ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Tue, 9 Apr 2024 11:24:38 +0200 Subject: [PATCH] fix(user_ldap): Fix LDAP tests with new typing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- apps/user_ldap/tests/AccessTest.php | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/apps/user_ldap/tests/AccessTest.php b/apps/user_ldap/tests/AccessTest.php index 2387dab7708bc..329cbbb56d477 100644 --- a/apps/user_ldap/tests/AccessTest.php +++ b/apps/user_ldap/tests/AccessTest.php @@ -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'); } @@ -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') @@ -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') @@ -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())