Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Fatal error Declaration of auth_oidc\tests\mockoidcclient #2596

Open
aspark21 opened this issue Jul 8, 2024 · 2 comments · May be fixed by #2598, #2603, #2604 or #2605
Open

PHP Fatal error Declaration of auth_oidc\tests\mockoidcclient #2596

aspark21 opened this issue Jul 8, 2024 · 2 comments · May be fixed by #2598, #2603, #2604 or #2605
Assignees
Labels
Issue type - bug Bugs in existing code that needs to be fixed. Plugin - auth_oidc Status - PR ready / pending release Dev is done and PR ready. Will be included in the next release.
Milestone

Comments

@aspark21
Copy link

aspark21 commented Jul 8, 2024

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

@CarlosArceLopera
Copy link

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 CarlosArceLopera linked a pull request Jul 10, 2024 that will close this issue
@rajandangi
Copy link

rajandangi commented Jul 12, 2024

+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
}

@weilai-irl weilai-irl added this to the 2024-09 milestone Jul 15, 2024
@weilai-irl weilai-irl self-assigned this Jul 15, 2024
@weilai-irl weilai-irl added Issue type - bug Bugs in existing code that needs to be fixed. Status - In Progress WIP Plugin - auth_oidc labels Jul 15, 2024
@weilai-irl weilai-irl added Status - PR ready / pending release Dev is done and PR ready. Will be included in the next release. and removed Status - In Progress WIP labels Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue type - bug Bugs in existing code that needs to be fixed. Plugin - auth_oidc Status - PR ready / pending release Dev is done and PR ready. Will be included in the next release.
Projects
None yet
4 participants