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

Task/refactoring reset password route #10

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

Spiker1992
Copy link

Added an action class that processes send request code
Added repository of messages
Added error message fectory that returns WP_ERROR class
Added class that returns default response structure

Added an action class that processes send request code
Added repository of messages
Added error message fectory that returns WP_ERROR class
Added class that returns default response structure
Copy link
Owner

@dominic-ks dominic-ks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK great, mostly looks fine. Couple of minor points on naming etc. and there's one type error there.

So I guess then we're really moving everything out of the API requests themselves and putting all the functionality into different classes for ease of testing?

inc/api/api.route.reset-password.php Outdated Show resolved Hide resolved
@@ -0,0 +1,9 @@
<?php

class Error_Message_Registry
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can class names be prepended with BDPWR_ please?

inc/class/class.reset-password-action.php Outdated Show resolved Hide resolved
@@ -0,0 +1,12 @@
<?php

class Response_Repository {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can class names be prepended with BDPWR_ please?

inc/class/class.wp-error-message-factor.php Outdated Show resolved Hide resolved
@Spiker1992
Copy link
Author

So I guess then we're really moving everything out of the API requests themselves and putting all the functionality into different classes for ease of testing?

Yes, and reusability. The reason why this refactoring mostly grabbed my attention is because this repo already has a code to perform a password reset. The new feature only needs to have support for one extra field. So, by adding a base action class, all I need to do, other than adding a route entry, is decorate the base class with support for that new field.

- Appended BDPWR_ to class names
- Fixed issue with data passed into handle() method for Reset_Password_Action within password reset route
@Spiker1992
Copy link
Author

@dominic-ks I pushed changes, should be fine now.

@Spiker1992 Spiker1992 requested a review from dominic-ks October 27, 2020 15:29
@dominic-ks
Copy link
Owner

@Spiker1992 Hey sorry for the delay, busy week. Have you tested this code OK? I've loaded up this pull request and when I call /bdpwr/v1/reset-password I get a fatal error: Uncaught TypeError: Argument 1 passed to BDPWR_Reset_Password_Action::handle() must be of the type array, object given ?

@Spiker1992
Copy link
Author

Spiker1992 commented Nov 2, 2020

@dominic-ks I haven't tested it... I have to say, I have no idea how to test it. I would like to add PHPUnit first, #12, and then add a test for this endpoint before dealing with this PR.

I think it would take 10-20 minutes to set up an initial test for this endpoint, which should be quicker than me figuring out how to test it manually :S

@dominic-ks
Copy link
Owner

OK well I think then I'm going to work on adding some more contributing docs to this repo with info on that then, I'll let you know when that's done.

@Spiker1992
Copy link
Author

@dominic-ks Ok. I will add a branch to test this PR using PHPUnit and then patch issues in here.

@dominic-ks
Copy link
Owner

@Spiker1992 Hey, FYI - I've added a CONTRIBUTING.md file to the project which I think will help. Let me know if you get any questions.

@Spiker1992
Copy link
Author

Spiker1992 commented Nov 7, 2020

@dominic-ks ok, great, thanks.

Btw, I have added an initial test set up for endpoint tests and added a success test for all the endpoints - Spiker1992@67ea200. I can create a PR from that commit into my PR for units test if you up for it?

Btw, do you know of any WP auto formatting packages for Visual Code? Given that WP requires PHP 7.4, it would have been nice for the WP team to update their coding standards to reflect new functionality :(

@Spiker1992
Copy link
Author

@dominic-ks, forgot to ask, which PHP version are you supporting?

@Spiker1992
Copy link
Author

@dominic-ks found codesniffer repo for this - https://github.com/WordPress/WordPress-Coding-Standards

…on class

Issue was due to the call back function receiving `WP_REST_Request` class.
@Spiker1992
Copy link
Author

@dominic-ks I have tested this endpoint and it should now work.

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

Successfully merging this pull request may close these issues.

2 participants