-
Notifications
You must be signed in to change notification settings - Fork 846
Separate the connection library into its own package. #12399
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
Conversation
|
It's hard for me to comment in detail until I see how this is invoked from the existing code. The class itself seems really clean. I somewhat prefer injecting implementations using filters rather than setters, or perhaps even referring to classes directly, since that's the WordPress way of doing things. Setters have a way of introducing tons of boilerplate. So instead of: // in the invoking class
$connection = new Jetpack_Connection();
$connection->set_option_backend( new Jetpack_Options() );
$connection->set_something_else( new Jetpack_Foo() );We would do either: // somewhere in Jetpack_Connection
apply_filters( 'jetpack_options_manager' )->write( 'foo', 'bar' );or // somewhere in Jetpack_Connection
(new Jetpack_Options)->write( 'foo', 'bar' ); // this shorthand is PHP 5.4+Also, as a matter of style, I don't think calling something "foo_backend" is very explanatory. If it's an implementation of an interface, you might call it "foo_impl". But generally, you want the suffix to be a verb or a role. For example:
|
|
Nit pick: Could we rename the |
|
Thanks a lot for your reviews, @gravityrail and @enejb . I have implemented the fixes, the main changes are:
|
I agree! Just a random thought: should we start by extracting an XMLRPC package first? |
This is an automated check which relies on |
|
@roccotripaldi thanks for taking a look! Yes, I thought the XMLRPC bit would be also moved into the connection package, because it's a crucial part of the communication mechanism. |
| 'args' => array( 'jetpack_uncompact_option_name', false ), | ||
| 'return' => true, | ||
| ) ); | ||
| \WP_Mock::userFunction( 'is_multisite', array( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of setting this us so many times can we just set it once and then overwrite it when we need to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I need to make it more DRY, thanks!
tyxla
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice work, Igor!
I've left some questions.
| @@ -0,0 +1,2 @@ | |||
| composer.lock | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have composer.lock ignored in every package:
Line 2 in 40d0573
| /**/composer.lock |
So this shouldn't be necessary.
| @@ -0,0 +1,2 @@ | |||
| composer.lock | |||
| vendor/ | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I wouldn't expect us to have to run composer install in every package to make this work inside Jetpack. I think ideally we should just run a single composer install inside the Jetpack root, and that'd get us all dependencies we need.
Even if what I said above isn't true for some reason, would it make sense to move this to the packages/.gitignore file so it would be applicable to all the packages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're still deciding on this, but yes, I thought we were going to have dev dependencies in separate packages that will be needed, for example, for running unit tests in isolation.
But whatever we decide, you're right, we can move that up a level to the parent gitignore file.
| "require": {}, | ||
| "require-dev": { | ||
| "phpunit/phpunit": "7.*.*", | ||
| "10up/wp_mock": "0.4.2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My concern with WP_Mock is that it would introduce a new way of testing things, so we'd have to refactor all our existing tests to use it. Also, it moves away from the traditional means of writing tests, followed in WP core development. Should we try to stay as close to WP core as possible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with WP Core tests is that it requires a working WordPress installation, whereas this approach allows us to really isolate the components and run unit tests as they were meant to be run. I don't see a problem with having separate testing frameworks as long as they don't get in our way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for elaborating. To be fair, I really love your idea ❤️
However, isn't it too far from us? Our current tests rely on having a working WordPress installation, and many of them actually would need more than just mocking one or two WordPress functions/classes.
Ideally, our plugin and tests would work without WordPress, but we have to be fair that this seems a bit far from what we currently have. And also I think it would cause a challenge for migrating to independent packages, at least initially.
I wonder if we could and should postpone the tests migration to non-WP-Core based ones to another time, when we can focus better on it?
| "version": "1.0.0", | ||
| "require": {}, | ||
| "require-dev": { | ||
| "phpunit/phpunit": "7.*.*", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My expectation is to have a unified tests package that we could use as a dependency in each of our packages. Then, each package could have its own tests and have them run easily. I'm planning to experiment with that soon, see https://github.com/Automattic/jpop-issues/issues/3889#issuecomment-496414966
In the meantime, does it make sense to not introduce different means of test bootstrapping and running, and have the tests work the same and live in the same place that the existing Jetpack tests do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same discussion is better held here, I think:
https://github.com/Automattic/jpop-issues/issues/3889#issuecomment-496495374
| @@ -0,0 +1,262 @@ | |||
| <?php | |||
|
|
|||
| namespace Jetpack\V7\Connection; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still not convinced about the versioning in the namespace. What's the benefit we're getting with it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the new work on the autoloader that @enejb is doing, I think we will be able to let go of versions in namespaces. I'll work on that, thanks for pointing it out!
| * | ||
| * @param Integer $user_id the user identifier. | ||
| */ | ||
| public static function disconnect_user( $user_id ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we can totally get rid of any static methods in the new implementation. Not necessary for the first pass, of course, just wanted to hear your thoughts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree, this was added in the early stages when I wasn't yet sure how namespaced classes and functions would work. I agree that when using objects, we should rely on instance methods as much as possible.
| public function generate_secrets( $action, $user_id, $exp ) { | ||
| $callable = $this->get_secret_callable(); | ||
|
|
||
| $secret_name = 'jetpack_' . $action . '_' . $user_id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| $secret_name = 'jetpack_' . $action . '_' . $user_id; | |
| $secret_name = 'jetpack_' . $action . '_' . $user_id; |
| * | ||
| * @param Jetpack_Options an option manager object. | ||
| */ | ||
| $this->option_manager = apply_filters( 'jetpack_connection_option_manager', false ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found it unexpected that a get_something method actually sets that something. Should we have the corresponding set_option_manager method defined and called in the right time so the dependency injection is done more visibly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this has been discussed earlier here: #12399 (comment)
And we decided to go the other way to stay closer to the way WordPress uses filters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lovely, thanks for elaborating 👍 I like that approach very much :)
| * | ||
| * @param Jetpack_Options an option manager object. | ||
| */ | ||
| $this->option_manager = apply_filters( 'jetpack_connection_option_manager', false ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we end up running (false)->update_option() and (false)->get_option() if we default to false for option manager? Should we default to new Jetpack\V7\Options\Manager or a new object of its inheriting class (just noticed that's this one is abstract).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, there needs to be a sane default or better error handling in case the manager is not set. I don't think there's going to be a case when this happens at runtime, though - it's a matter of an improperly set up class.
| @@ -0,0 +1,243 @@ | |||
| <?php | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use /src instead of /lib?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing, let's stick to one schema everywhere, thanks!
|
Caution: This PR has changes that must be merged to WordPress.com |
|
zinigor, Your synced wpcom patch D28891-code has been updated. |
|
Drive-by comment: I think we decided to prefix packages with |
|
zinigor, Your synced wpcom patch D28891-code has been updated. |
enejb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in the Options_Manager class we should avoid using the word option. Since that can be implied.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just use get instead of get_option ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make this private? Should it be called outside this class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we call this just update?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make this private as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just this just delete?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we make this just is_network
|
zinigor, Your synced wpcom patch D28891-code has been updated. |
7a4d3f3 to
7df90c1
Compare
b4f32c0 to
5e2c656
Compare
|
zinigor, Your synced wpcom patch D28891-code has been updated. |
|
Just wanted to mention again here that the Connection Manager Interface that I have added was only intended as a tool to enforce method creation. I wanted to remove the interface in the end, and if you feel like things can be done differently, please feel free to change whatever you need. Especially in light of Enej's review regarding naming - now is probably the best way to agree on the best naming strategy. One more thing: I have tried to fix tests in 5e2c656, but for some reason the files were not properly excluded. Tests in D28891-code were properly excluded, but the latest changes in this PR have overwritten the diff, please look at the diff history to see what I did to make the tests pass. |
|
I'm going to merge this, though it's not fully done yet. Still to do:
|
* Add Custom Autoloader (#12447) * Try Custom Autoloader * spelling fix Co-Authored-By: Marin Atanasov <[email protected]> * minor space fix Co-Authored-By: Marin Atanasov <[email protected]> * minor space fix. Co-Authored-By: Marin Atanasov <[email protected]> * Updated to make it even simpler * test plugin * a Toy plugin :) 🚂 * Minor update * Minor update * Fixes typo * delete file * Minor updates * Added limitaionts section to readme * ooops * Fix readme * Turn the jetpack-autoloader into a package. * fixes to the jetpack a custom plugin * typo Co-Authored-By: Marin Atanasov <[email protected]> * remove scripts to "a" no longer needed thanks to @enejb magic * Update packages/autoloader/README.md fixes more wording in the readme Co-Authored-By: Miguel Lezama <[email protected]> * Update the version numbers of packages insead of branches * forgot about the plugin * update "a" composer * Update the a composer lock file. * Revert "Update the a composer lock file." This reverts commit 90f2cb8dbc50e15caf19fa0b88e1ee201f8f21c5. * typo fix Co-Authored-By: Miguel Lezama <[email protected]> * Rebased against master, testes that a plugin works as expected * Remove not needed code * Minor readme fix * Remoce Space * Add filter to prevent the autoloader from loading a particular version * add b toy plugin depending on Jetpack Logo 1.0.1 Co-Authored-By: Marin Atanasov <[email protected]> * minor space fix Co-Authored-By: Miguel Lezama <[email protected]> * Update a comment * Fix phpcs fixes * Make the remove class_map from the global name space, fix phpcs issues * Add the autoload_packages to be ignored. * Add debug info * Remove versions from composer.json of packages * Add missing vendor to namespace * Fix typo * Fix typo and add punctuation * Fix a typo * Update .gitignore Co-Authored-By: Jeremy Herve <[email protected]> * Update all the composer files * Take into account the @dev and always use the dev-* version * Bug Fix load the latest version! * Update the logic when enqueing the classes * Update to use Namespaces * Add tests to make sure that the enqueing works as expected * Fix suggestions from Marin * Remove generateClassMap method * Fix the tests, rename the fucntion name to be more accurate * More fixes to the tests. * FuN * Making it all work again * Update the lock file * Minor * Remove unused plugins (#12529) * Removed unnecessary gitignore lines. * Separate the connection library into its own package. (#12399) * Added an interface as a guide for the new package methods. * Add package structure * Initialized the composer library, added gitignore. * Removed phpunit from connection dependencies. * Added first real code to the connection manager class, as well as tests for it. * Renamed the test folder to tests. * Made the option name be a class constant. * Added 10up's WP_Mock as a dependency, refactored the injection to use filters instead of setters. * Changed the internal method accessibility to protected. * Initialized an empty package repo for the options manager. * Added the options package as a dependency to the master repo. * Added a package structure placeholder for the options manager. * Added the first test for the delete option method. * Added the update method and a test for it. * Added a test for the grouped option deletion. * Added the group updater method and a test for it. * Added the grouped option getter and a test for it. * Added a test for the noncompact option getter. * Added tests for network option manipulation. * Removed autoloader requirement in favour of the existing one. * Added the connection manager secret generator to actual Jetpack class. * Removed individual gitignore files in favor of a parent-level file, props @tyxla! * Moved packages source code into src folders. * Removed the V7 part of the namespace. * Remove v7 from namespace in the Manager Interface * Remove V7 from namespaces * Add Automattic to the namespace * Rename jetpack-[name] packages to [name] * Update composer lock * Adding a package for Jetpack Constants * Attempting to fix WPCOM tests. * Excluding packages folder from linting for PHP 5.6 and earlier. * adjust syntax in connection tests * removing new unit tests. i'm not sure why they are failing. we can re-add them later. * reverting last commit, and fixing tests in `packages/options` * ah, one more * remove an un-needed linting hack (#12543) * Composer: avoid duplicate repositories key (#12546) * Composer: avoid duplicate repositories key Rely on wildcard instead. See #12483 * Revert changes in composer.lock * Revert changes in composer.lock * Revert changes in composer.lock * Packages: Make logo package tests independent (#12514) * Move package tests to package directory * Add some dev deps to logo package * Ignore vendor of all packages * Add a logo package simple bootstrap * Add a logo package phpunit config * Cleanup package tests from Jetpack phpunit config * Remove WP prefix from class name * Make sure composer is installed * Try: add SCOPE to travis matrix * Try: Disable older PHP versions * Replace WP_Mock with PHPMock * Enable php 7.0 in Travis again * Make phpunit version more permissive * Fix setUp signature * Play with phpunit versions * Try enabling CI for feature branch * Try enabling CI for feature branch * Try enabling CI for feature branch * Revert latest changes * Try adding the branch to the whitelist * Enable PHP 5.6 again * Use php-mock instead of php-mock-phpunit * Run composer phpunit for all packages * Make mocking method protected * Add parent teardown * Remove whitelisted branch * Run only for packages with tests * remove trailing slash 🤔 * nope * not sure what I am doing * add debug statements * run only if we have `php` tests @zinigor @tyxla we need to normalise de connection one * Jetpack Options Package: just class map existing options class (#12562) * instead of a new implementation of jetpack options, let's class map it * Packages: Fix connection tests and allow them to run in CI (#12560) * Use php-mock instead of wp_mock * Add phpunit script * Migrate tests from wp_mock to phpmock * Make tests run in CI * Run travis only for packages that have the php test dir * Revert "Jetpack Options Package: just class map existing options class (#12562)" (#12571) This reverts commit 0e3ac7a. * Packages: Finish the constants package (#12558) * PSR-4 constants * Actually add namespacing to the constants class * Update composer.lock * Fix phpcs errors and add some docs * Add a package README * Move constant tests to the package * Update Jetpack to use the constants package * Fix constants usage in options package * Rename README variable Co-Authored-By: Miguel Lezama <[email protected]> * Fix typo Co-Authored-By: Miguel Lezama <[email protected]> * Use plural Co-Authored-By: Miguel Lezama <[email protected]> * Making Jetpack_Options a classmapped package. (#12577) * Making Jetpack_Options a classmapped package. * Update Jetpack to use new JITM package (#12516) * Update Jetpack to use new JITM package * Add instructions on package installation and usage (#12576) * Add instructions on package installation and usage * Move content about installing Composer to the doc regarding development environment. Add a pointer to that section in the packages' readme * Explain how to install Composer on systems other than macOS. Props @aldavigdis * Update docs/development-environment.md Co-Authored-By: Jeremy Herve <[email protected]> * Apply suggestions from code review Co-Authored-By: Jeremy Herve <[email protected]> * Add reference to Composer installation in the section that explains how to start developing for Jetpack * Packages: Fix alias example in README (#12582) * Packages: Move sync to a classmapped package (#12572) * Move all sync files to the package * Add sync package composer.json * Composer require the new sync package * Update composer.lock after adding sync package dependency * Remove some sync file requiring in sync package * Remove some sync file requiring in the rest of Jetpack * Hook Jetpack actions properly * Fix a rebase conflict * Fix update post terms test to not compare against the DB * Packages: Move JITM tests to package and fix deps (#12583) * Add phpunit devdep and composer phpunit script * Add JITM tests config * Move tests and add bootstrap * Remove legacy jitm suite * Rely on @dev connection package * Remove version * Update minimum stability and prefer stable * Fix tests * Update composer.lock * Fix whitespace Co-Authored-By: Miguel Lezama <[email protected]> * Prepend an empty line Co-Authored-By: Miguel Lezama <[email protected]> * Connection Package: add Jetpack_Data methods (#12580) Jetpack_Data -> Connection package * removes php_bug_66229_check method - it's no longer used in the code base. * Moving is_usable_domain to Connection package. * Moves `get_access_token` to Connection package. * Create package for Jetpack Tracking (#12596) Created package for Jetpack Tracking * Update/package logo add gray (#12610) * Update the logo package to include a gray version. Add parameter to render method to specify the type * Remove svg files. Update method to return an SVG string that can be stylized with CSS. Update tests. * Fixed issue with logo in Jetpack connection banner in WP Admin * Update test so it strictly tests two instances of the CSS class * Optimize performance. Use const since the string is immutable. Use nowdoc to compose the string. * Update logo tests in new file * Constants_Manager -> Constants * inc/lib/admin-pages/class.jetpack-react-page.php (#12627) * Add jetpack signature class to connection package (#12620) * Connection package: Add class.jetpack-signature and class.jetpack-error to connection package * DNA: Don't require composer autoloader (#12624) * Jitm package, don't use global Jetpack class (#12629)
* Add Custom Autoloader (#12447) * Try Custom Autoloader * spelling fix Co-Authored-By: Marin Atanasov <[email protected]> * minor space fix Co-Authored-By: Marin Atanasov <[email protected]> * minor space fix. Co-Authored-By: Marin Atanasov <[email protected]> * Updated to make it even simpler * test plugin * a Toy plugin :) 🚂 * Minor update * Minor update * Fixes typo * delete file * Minor updates * Added limitaionts section to readme * ooops * Fix readme * Turn the jetpack-autoloader into a package. * fixes to the jetpack a custom plugin * typo Co-Authored-By: Marin Atanasov <[email protected]> * remove scripts to "a" no longer needed thanks to @enejb magic * Update packages/autoloader/README.md fixes more wording in the readme Co-Authored-By: Miguel Lezama <[email protected]> * Update the version numbers of packages insead of branches * forgot about the plugin * update "a" composer * Update the a composer lock file. * Revert "Update the a composer lock file." This reverts commit 90f2cb8dbc50e15caf19fa0b88e1ee201f8f21c5. * typo fix Co-Authored-By: Miguel Lezama <[email protected]> * Rebased against master, testes that a plugin works as expected * Remove not needed code * Minor readme fix * Remoce Space * Add filter to prevent the autoloader from loading a particular version * add b toy plugin depending on Jetpack Logo 1.0.1 Co-Authored-By: Marin Atanasov <[email protected]> * minor space fix Co-Authored-By: Miguel Lezama <[email protected]> * Update a comment * Fix phpcs fixes * Make the remove class_map from the global name space, fix phpcs issues * Add the autoload_packages to be ignored. * Add debug info * Remove versions from composer.json of packages * Add missing vendor to namespace * Fix typo * Fix typo and add punctuation * Fix a typo * Update .gitignore Co-Authored-By: Jeremy Herve <[email protected]> * Update all the composer files * Take into account the @dev and always use the dev-* version * Bug Fix load the latest version! * Update the logic when enqueing the classes * Update to use Namespaces * Add tests to make sure that the enqueing works as expected * Fix suggestions from Marin * Remove generateClassMap method * Fix the tests, rename the fucntion name to be more accurate * More fixes to the tests. * FuN * Making it all work again * Update the lock file * Minor * Remove unused plugins (#12529) * Removed unnecessary gitignore lines. * Separate the connection library into its own package. (#12399) * Added an interface as a guide for the new package methods. * Add package structure * Initialized the composer library, added gitignore. * Removed phpunit from connection dependencies. * Added first real code to the connection manager class, as well as tests for it. * Renamed the test folder to tests. * Made the option name be a class constant. * Added 10up's WP_Mock as a dependency, refactored the injection to use filters instead of setters. * Changed the internal method accessibility to protected. * Initialized an empty package repo for the options manager. * Added the options package as a dependency to the master repo. * Added a package structure placeholder for the options manager. * Added the first test for the delete option method. * Added the update method and a test for it. * Added a test for the grouped option deletion. * Added the group updater method and a test for it. * Added the grouped option getter and a test for it. * Added a test for the noncompact option getter. * Added tests for network option manipulation. * Removed autoloader requirement in favour of the existing one. * Added the connection manager secret generator to actual Jetpack class. * Removed individual gitignore files in favor of a parent-level file, props @tyxla! * Moved packages source code into src folders. * Removed the V7 part of the namespace. * Remove v7 from namespace in the Manager Interface * Remove V7 from namespaces * Add Automattic to the namespace * Rename jetpack-[name] packages to [name] * Update composer lock * Adding a package for Jetpack Constants * Attempting to fix WPCOM tests. * Excluding packages folder from linting for PHP 5.6 and earlier. * adjust syntax in connection tests * removing new unit tests. i'm not sure why they are failing. we can re-add them later. * reverting last commit, and fixing tests in `packages/options` * ah, one more * remove an un-needed linting hack (#12543) * Composer: avoid duplicate repositories key (#12546) * Composer: avoid duplicate repositories key Rely on wildcard instead. See #12483 * Revert changes in composer.lock * Revert changes in composer.lock * Revert changes in composer.lock * Packages: Make logo package tests independent (#12514) * Move package tests to package directory * Add some dev deps to logo package * Ignore vendor of all packages * Add a logo package simple bootstrap * Add a logo package phpunit config * Cleanup package tests from Jetpack phpunit config * Remove WP prefix from class name * Make sure composer is installed * Try: add SCOPE to travis matrix * Try: Disable older PHP versions * Replace WP_Mock with PHPMock * Enable php 7.0 in Travis again * Make phpunit version more permissive * Fix setUp signature * Play with phpunit versions * Try enabling CI for feature branch * Try enabling CI for feature branch * Try enabling CI for feature branch * Revert latest changes * Try adding the branch to the whitelist * Enable PHP 5.6 again * Use php-mock instead of php-mock-phpunit * Run composer phpunit for all packages * Make mocking method protected * Add parent teardown * Remove whitelisted branch * Run only for packages with tests * remove trailing slash 🤔 * nope * not sure what I am doing * add debug statements * run only if we have `php` tests @zinigor @tyxla we need to normalise de connection one * Jetpack Options Package: just class map existing options class (#12562) * instead of a new implementation of jetpack options, let's class map it * Packages: Fix connection tests and allow them to run in CI (#12560) * Use php-mock instead of wp_mock * Add phpunit script * Migrate tests from wp_mock to phpmock * Make tests run in CI * Run travis only for packages that have the php test dir * Revert "Jetpack Options Package: just class map existing options class (#12562)" (#12571) This reverts commit 0e3ac7a. * Packages: Finish the constants package (#12558) * PSR-4 constants * Actually add namespacing to the constants class * Update composer.lock * Fix phpcs errors and add some docs * Add a package README * Move constant tests to the package * Update Jetpack to use the constants package * Fix constants usage in options package * Rename README variable Co-Authored-By: Miguel Lezama <[email protected]> * Fix typo Co-Authored-By: Miguel Lezama <[email protected]> * Use plural Co-Authored-By: Miguel Lezama <[email protected]> * Making Jetpack_Options a classmapped package. (#12577) * Making Jetpack_Options a classmapped package. * Update Jetpack to use new JITM package (#12516) * Update Jetpack to use new JITM package * Add instructions on package installation and usage (#12576) * Add instructions on package installation and usage * Move content about installing Composer to the doc regarding development environment. Add a pointer to that section in the packages' readme * Explain how to install Composer on systems other than macOS. Props @aldavigdis * Update docs/development-environment.md Co-Authored-By: Jeremy Herve <[email protected]> * Apply suggestions from code review Co-Authored-By: Jeremy Herve <[email protected]> * Add reference to Composer installation in the section that explains how to start developing for Jetpack * Packages: Fix alias example in README (#12582) * Packages: Move sync to a classmapped package (#12572) * Move all sync files to the package * Add sync package composer.json * Composer require the new sync package * Update composer.lock after adding sync package dependency * Remove some sync file requiring in sync package * Remove some sync file requiring in the rest of Jetpack * Hook Jetpack actions properly * Fix a rebase conflict * Fix update post terms test to not compare against the DB * Packages: Move JITM tests to package and fix deps (#12583) * Add phpunit devdep and composer phpunit script * Add JITM tests config * Move tests and add bootstrap * Remove legacy jitm suite * Rely on @dev connection package * Remove version * Update minimum stability and prefer stable * Fix tests * Update composer.lock * Fix whitespace Co-Authored-By: Miguel Lezama <[email protected]> * Prepend an empty line Co-Authored-By: Miguel Lezama <[email protected]> * Connection Package: add Jetpack_Data methods (#12580) Jetpack_Data -> Connection package * removes php_bug_66229_check method - it's no longer used in the code base. * Moving is_usable_domain to Connection package. * Moves `get_access_token` to Connection package. * Create package for Jetpack Tracking (#12596) Created package for Jetpack Tracking * Update/package logo add gray (#12610) * Update the logo package to include a gray version. Add parameter to render method to specify the type * Remove svg files. Update method to return an SVG string that can be stylized with CSS. Update tests. * Fixed issue with logo in Jetpack connection banner in WP Admin * Update test so it strictly tests two instances of the CSS class * Optimize performance. Use const since the string is immutable. Use nowdoc to compose the string. * Update logo tests in new file * Constants_Manager -> Constants * inc/lib/admin-pages/class.jetpack-react-page.php (#12627) * Add jetpack signature class to connection package (#12620) * Connection package: Add class.jetpack-signature and class.jetpack-error to connection package * DNA: Don't require composer autoloader (#12624) * Jitm package, don't use global Jetpack class (#12629)
This is a work in progress PR created to be able to review, exchange opinions and iterate. Currently it adds a package that would serve as a Connection related library.
Please keep in mind several things as you go through the code:
Manager_Interfacehas been added as an enforcement measure, I am planning to remove it once all the methods are implemented. It was meant to help to understand what methods will need to be public, and what methods will need to be accessible inside the class.Testing instructions:
packages/jetpack-connectioncomposer installcomposer run test