o365-moodle icon indicating copy to clipboard operation
o365-moodle copied to clipboard

PHP Fatal error Declaration of auth_oidc\tests\mockoidcclient

Open aspark21 opened this issue 1 year ago • 2 comments

Moodle 4.4 PHP 8.1 auth_oidc master

PHP Fatal error: Declaration of auth_oidc\tests\mockoidcclient::getauthrequestparams($promptlogin = false, array $stateparams = [], array $extraparams = []) must be compatible with auth_oidc\oidcclient::getauthrequestparams($promptlogin = false, array $stateparams = [], array $extraparams = [], bool $selectaccount = false) in /var/www/html/auth/oidc/classes/tests/mockoidcclient.php on line 48

aspark21 avatar Jul 08 '24 17:07 aspark21

Hello, I have the same error:

vendor/bin/phpunit --testsuite auth_oidc_testsuite
Moodle 4.1.11+ (Build: 20240705), 2976e22a13ff650f122f8106b2bd885a1fc96d28
Php: 8.1.28, pgsql: 14.0 (Debian 14.0-1.pgdg110+1), OS: Linux 6.5.0-41-generic x86_64
PHPUnit 9.5.28 by Sebastian Bergmann and contributors.

...........
Fatal error: Declaration of auth_oidc\tests\mockoidcclient::getauthrequestparams($promptlogin = false, array $stateparams = [], array $extraparams = []) must be compatible with auth_oidc\oidcclient::getauthrequestparams($promptlogin = false, array $stateparams = [], array $extraparams = [], bool $selectaccount = false) in /var/www/cambrian401/auth/oidc/classes/tests/mockoidcclient.php on line 48

CarlosArceLopera avatar Jul 09 '24 18:07 CarlosArceLopera

+1

I have the same issue.

There is a method signature mismatch in the getauthrequestparams method in the mockoidcclient class that causes compatibility issues. The parent method in the oidcclient class includes an additional parameter bool $selectaccount = false which is not present in mockoidcclient.

Steps to Reproduce

  1. Run the test suite for the auth_oidc_oidcclient_testcase class. vendor/bin/phpunit --testsuite auth_oidc_testsuite

The test suite fails with the following error message:

There was 1 error:

1) auth_oidc_oidcclient_testcase::test_creds_getters_and_setters
Declaration of auth_oidc\tests\mockoidcclient::getauthrequestparams($promptlogin = false, array $stateparams = Array, array $extraparams = Array) should be compatible with auth_oidc\oidcclient::getauthrequestparams($promptlogin = false, array $stateparams = Array, array $extraparams = Array, bool $selectaccount = false)

/var/www/mysite/auth/oidc/classes/tests/mockoidcclient.php:48
/var/www/mysite/auth/oidc/classes/tests/mockoidcclient.php:33
/var/www/mysite/lib/classes/component.php:137
/var/www/mysite/auth/oidc/tests/oidcclient_test.php:50
/var/www/mysite/lib/phpunit/classes/advanced_testcase.php:80
phpvfscomposer:///var/www/mysite/vendor/phpunit/phpunit/phpunit:97

Environment Moodle 4.1.11+ (Build: 20240705), Php: 7.4.33, mysqli: 8.0.38, OS: Linux 6.8.0-36-generic x86_64

Proposed Solution Update the method signature of getauthrequestparams in the mockoidcclient class to include the $selectaccount parameter and match the parent class.

// Update this method in mockoidcclient
public function getauthrequestparams($promptlogin = false, array $stateparams = [], array $extraparams = [], bool $selectaccount = false) {
    // Method implementation
}

rajandangi avatar Jul 12 '24 05:07 rajandangi

Hi all,

The fix to this issue has been included in the release from yesterday. Many thanks to @CarlosArceLopera for providing the solution.

Regards, Lai

weilai-irl avatar Oct 18 '24 09:10 weilai-irl