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

feat: migrate from deprecated PublicEmitter to IEventDispatcher #856

Merged
merged 7 commits into from
Jul 3, 2024

Conversation

bdovaz
Copy link
Contributor

@bdovaz bdovaz commented May 31, 2024

Fixes #853

@bdovaz bdovaz force-pushed the migrate-to-event-dispatcher branch from 1c609b4 to 618cfe9 Compare May 31, 2024 20:55
@bdovaz
Copy link
Contributor Author

bdovaz commented May 31, 2024

@blizzz I have doubts with these lines:

interface PublicEmitter {

Should I remove them? I don't really know what this file is for, I come from the .NET world. 😅

@blizzz
Copy link
Member

blizzz commented Jun 3, 2024

@blizzz I have doubts with these lines:

interface PublicEmitter {

Should I remove them? I don't really know what this file is for, I come from the .NET world. 😅

So that's for testing, and the PublicEmitter is a private interface from the server, so it was stubbed here. By dropping that interface from lib/GroupManager.php we may do not need the stub anymore, and the entry can be removed just as well.

@bdovaz
Copy link
Contributor Author

bdovaz commented Jun 4, 2024

@blizzz I have doubts with these lines:

interface PublicEmitter {

Should I remove them? I don't really know what this file is for, I come from the .NET world. 😅

So that's for testing, and the PublicEmitter is a private interface from the server, so it was stubbed here. By dropping that interface from lib/GroupManager.php we may do not need the stub anymore, and the entry can be removed just as well.

Removed! PR ready to review!

Copy link

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

@blizzz
Copy link
Member

blizzz commented Jun 21, 2024

There is failing CI. I see this also in an unrelated PR, so it do not think it is related to your changes. Nevertheless, I want to have this sorted out first so we have a green CI by default :)

@blizzz
Copy link
Member

blizzz commented Jun 26, 2024

There is failing CI. I see this also in an unrelated PR, so it do not think it is related to your changes. Nevertheless, I want to have this sorted out first so we have a green CI by default :)

It was a regression within server, but fixed now.

@blizzz blizzz force-pushed the migrate-to-event-dispatcher branch from cfc9a46 to dd4c0e6 Compare June 26, 2024 09:21
@bdovaz
Copy link
Contributor Author

bdovaz commented Jun 26, 2024

@blizzz fixed php lint issues, rerun please!

@blizzz
Copy link
Member

blizzz commented Jun 26, 2024

Now unit tests, they need adjustements. The IEventDispatcher has to be passed here https://github.com/nextcloud/user_saml/blob/master/tests/unit/GroupManagerTest.php#L57-L58 and maybe we want to check that dispatchTyped() is called with the correct event class.

@bdovaz
Copy link
Contributor Author

bdovaz commented Jun 27, 2024

@blizzz done! Please rerun, thanks!

Is there any way to run the tests locally so that I don't depend on you to approve the workflow execution? Because looking at this file it seems that it depends on the fact that they must be executed through the workflow:

require_once __DIR__.'/../../../../lib/base.php';

@blizzz
Copy link
Member

blizzz commented Jun 28, 2024

If you have user_saml in an apps folder in a server checkout running locally will work. composer i && composer run test:unit should be sufficient then.

@bdovaz bdovaz force-pushed the migrate-to-event-dispatcher branch from ce3d502 to 7a4b3c5 Compare June 28, 2024 20:35
@bdovaz
Copy link
Contributor Author

bdovaz commented Jun 28, 2024

@blizzz now I hope that everything is corrected, locally at least everything works correctly.

My problem was that I did not understand well the PHPUnit API and expects method when we want to check multiple invocations with different parameters of a method.

In my case I have not used the "at" method that is used in "UserBackendTest.php" because it says that it is deprecated and will be removed in the next version of PHPUnit. I could correct the one in "UserBackendTest.php" but I don't want to do it in this PR to avoid touching files that I should not.

@bdovaz
Copy link
Contributor Author

bdovaz commented Jun 29, 2024

@blizzz I don't understand the errors that appear in the MySQL workflow, if the tests are exactly the same and in other database providers they have worked correctly (SQLite and PostgreSQL) how is it possible that in MySQL not and with this error?

1) OCA\User_SAML\Tests\GroupManagerTest::testUpdateUserGroups
Creation of dynamic property OCA\User_SAML\Tests\GroupManagerTest::$eventDispatcher is deprecated

/home/runner/actions-runner/_work/user_saml/user_saml/apps/user_saml/tests/unit/GroupManagerTest.php:50

https://github.com/nextcloud/user_saml/actions/runs/9718183419/job/26826566029?pr=856

image

@bdovaz
Copy link
Contributor Author

bdovaz commented Jun 29, 2024

@blizzz I have corrected it anyway, it is that the field at class level was missing. The strange thing as I say is that it fails in some workflows but not in others. Apart from the fact that it is a warning but in reality it considers it an error.

You can run the build again.

bdovaz and others added 6 commits June 29, 2024 12:15
Signed-off-by: Borja Domínguez Vázquez <borja.dominguez@hotmail.com>
Signed-off-by: Borja Domínguez <iam.n3uro@gmail.com>
Signed-off-by: Borja Domínguez Vázquez <borja.dominguez@hotmail.com>
Signed-off-by: Borja Domínguez <iam.n3uro@gmail.com>
Signed-off-by: Borja Domínguez Vázquez <borja.dominguez@hotmail.com>
Signed-off-by: Borja Domínguez Vázquez <borja.dominguez@hotmail.com>
Signed-off-by: Borja Domínguez Vázquez <borja.dominguez@hotmail.com>
Signed-off-by: Borja Domínguez Vázquez <borja.dominguez@hotmail.com>
@bdovaz bdovaz force-pushed the migrate-to-event-dispatcher branch from 5174efb to 65ad97b Compare June 29, 2024 10:16
@blizzz
Copy link
Member

blizzz commented Jul 2, 2024

@blizzz I have corrected it anyway, it is that the field at class level was missing. The strange thing as I say is that it fails in some workflows but not in others. Apart from the fact that it is a warning but in reality it considers it an error.

You can run the build again.

Thanks! Dynamic properties were deprecated in PHP 8.2, so earlier ones would pass.

@bdovaz
Copy link
Contributor Author

bdovaz commented Jul 2, 2024

@blizzz have passed all the checks!

Merge whenever you want, I'm all set!

Thanks.

@blizzz blizzz merged commit 9c4e9bd into nextcloud:master Jul 3, 2024
45 checks passed
@blizzz
Copy link
Member

blizzz commented Jul 3, 2024

Great! Thank you @bdovaz !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use IEventDispatcher in GroupManager.php
2 participants