Open aspark21 opened 1 month ago
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
+1
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
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
}
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