From 01131fef7b42a4b13039be98efa245b5e5e4c194 Mon Sep 17 00:00:00 2001 From: Tim van Dijen Date: Sun, 4 Aug 2024 23:00:05 +0200 Subject: [PATCH] Fix unit tests --- .github/workflows/php.yml | 2 ++ tests/src/TestCase/AuthSource/Ldap/LdapBindTest.php | 2 +- tests/src/TestCase/AuthSource/NegotiateTest.php | 12 ++++++------ tests/src/TestCase/CertificatesTest.php | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index dd51d7d..ccbb17e 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -183,6 +183,7 @@ jobs: coverage: pcov env: KRB5_LINUX_LIBS: libkrb5-dev + APACHE_RUN_DIR: /var/run/apache2 - name: Setup problem matchers for PHP run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" @@ -258,6 +259,7 @@ jobs: coverage: none env: KRB5_LINUX_LIBS: libkrb5-dev + APACHE_RUN_DIR: /var/run/apache2 - name: Setup problem matchers for PHP run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" diff --git a/tests/src/TestCase/AuthSource/Ldap/LdapBindTest.php b/tests/src/TestCase/AuthSource/Ldap/LdapBindTest.php index 792248d..bb32c92 100644 --- a/tests/src/TestCase/AuthSource/Ldap/LdapBindTest.php +++ b/tests/src/TestCase/AuthSource/Ldap/LdapBindTest.php @@ -25,7 +25,7 @@ public function testBindSuccesful(): void $connectionMock = $this->getMockBuilder(Ldap::class)->onlyMethods( ['bind'], )->disableOriginalConstructor()->getMock(); - $connectionMock->expects($this->once())->method('bind')->willReturn(true); + $connectionMock->expects($this->once())->method('bind'); $confTest = new TestCase\AuthSource\Ldap\Bind( new TestData([ 'authSourceData' => Configuration::loadFromArray($authSourceData), diff --git a/tests/src/TestCase/AuthSource/NegotiateTest.php b/tests/src/TestCase/AuthSource/NegotiateTest.php index fcb2afe..3ab6cf9 100644 --- a/tests/src/TestCase/AuthSource/NegotiateTest.php +++ b/tests/src/TestCase/AuthSource/NegotiateTest.php @@ -49,10 +49,10 @@ public function testNegotiateSuccess(): void $KRB5NegotiateAuthMock = $this->getMockBuilder(KRB5NegotiateAuth::class)->onlyMethods( ['doAuthentication', 'getAuthenticatedUser'], )->disableOriginalConstructor()->getMock(); - $KRB5NegotiateAuthMock->expects($this->any())->method('doAuthentication')->will($this->returnValue(true)); - $KRB5NegotiateAuthMock->expects($this->any())->method('getAuthenticatedUser')->will( - $this->returnValue('testuser@example.org'), - ); + $KRB5NegotiateAuthMock->expects($this->any())->method('doAuthentication')->willReturn(true); + $KRB5NegotiateAuthMock->expects($this->any()) + ->method('getAuthenticatedUser') + ->willReturn('testuser@example.org'); $testData = new TestData([ 'handle' => $KRB5NegotiateAuthMock, ]); @@ -67,7 +67,7 @@ public function testNegotiateNoAuthorzation(): void $KRB5NegotiateAuthMock = $this->getMockBuilder(KRB5NegotiateAuth::class)->onlyMethods( ['doAuthentication', 'getAuthenticatedUser'], )->disableOriginalConstructor()->getMock(); - $KRB5NegotiateAuthMock->expects($this->any())->method('doAuthentication')->will($this->returnValue(false)); + $KRB5NegotiateAuthMock->expects($this->any())->method('doAuthentication')->willReturn(false); $testData = new TestData([ 'handle' => $KRB5NegotiateAuthMock, ]); @@ -82,7 +82,7 @@ public function testNegotiateError(): void $KRB5NegotiateAuthMock = $this->getMockBuilder(KRB5NegotiateAuth::class)->onlyMethods( ['doAuthentication', 'getAuthenticatedUser'], )->disableOriginalConstructor()->getMock(); - $KRB5NegotiateAuthMock->expects($this->any())->method('doAuthentication')->will($this->returnValue(false)); + $KRB5NegotiateAuthMock->expects($this->any())->method('doAuthentication')->willReturn(false); $testData = new TestData([ 'handle' => $KRB5NegotiateAuthMock, 'authorization' => 'test', diff --git a/tests/src/TestCase/CertificatesTest.php b/tests/src/TestCase/CertificatesTest.php index d3b2159..046cf81 100644 --- a/tests/src/TestCase/CertificatesTest.php +++ b/tests/src/TestCase/CertificatesTest.php @@ -18,7 +18,7 @@ class TestCertificatesTest extends \PHPUnit\Framework\TestCase public static function setUpBeforeClass(): void { - self::$certdir = getcwd() . '/vendor/simplesamlphp/xml-security/tests/resources/certificates/'; + self::$certdir = getcwd() . '/vendor/simplesamlphp/xml-security/resources/certificates/'; } public function testCertExpired(): void