-
Notifications
You must be signed in to change notification settings - Fork 93
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
Fix: pass client to objects in an array #409
Conversation
lib/recurly/base.php
Outdated
@@ -399,6 +399,9 @@ protected static function __parseXmlToObject($node, &$object) | |||
// has element children, drop in and continue parsing | |||
$new_obj = Recurly_Resource::__createNodeObject($node); |
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 it'd be better to just pass client into __createNodeObject
as a parameter since most of the time we assign it afterwards. Then we'd avoid needing to check if it's an instance of Recurly_Base.
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.
Makes sense. I updated the pull request.
5d46c0a
to
f1c229a
Compare
lib/recurly/base.php
Outdated
@@ -366,7 +364,7 @@ protected static function __parseXmlToObject($node, &$object) | |||
continue; | |||
} | |||
|
|||
$new_obj = Recurly_Resource::__createNodeObject($node); | |||
$new_obj = Recurly_Resource::__createNodeObject($node, $object->_client); |
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.
One reason the tests are failing right now is because in this context, $object
can be an array (see line 360) which wouldn't have a _client
property.
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.
Thank you! I addressed the issue and the tests are now passing.
…use the same client
f1c229a
to
cc26311
Compare
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 your contribution!
Hello,
I encountered an issue where I use a mock client of recurly during test runs where the client does not get passed down to all sub objects.
For instance if I fetch an invoice like this:
if this gets called for an invoice that contains
credit_payments
then all the\Recurly_Stub
object on the individual\Recurly_CreditPayment
do not have theMockClient
set as_client
but instead have the default\RecurlyClient
set.