diff --git a/Tests/Recurly/Subscription_Test.php b/Tests/Recurly/Subscription_Test.php index c6047c4a..882b637f 100644 --- a/Tests/Recurly/Subscription_Test.php +++ b/Tests/Recurly/Subscription_Test.php @@ -264,6 +264,19 @@ public function testUpdateSubscriptionWithAddOns() { ); } + public function testUpdateSubscriptionWithAddOnsQuantityBasedPricing() { + $this->client->addResponse('GET', '/subscriptions/012345678901234567890123456789ab', 'subscriptions/show-200-QBP.xml'); + $subscription = Recurly_Subscription::get('012345678901234567890123456789ab', $this->client); + + $subscription->collection_method = "automatic"; + $subscription->subscription_add_ons[0]->tiers[0]->ending_quantity = 50; + + $this->assertEquals( + "\nmarketing_emails1evenlytiered1235080999999999automatic\n", + $subscription->xml() + ); + } + public function testGetSubscriptionRedemptions() { $this->client->addResponse('GET', '/subscriptions/012345678901234567890123456789ab', 'subscriptions/show-200.xml'); $this->client->addResponse('GET', 'https://api.recurly.com/v2/subscriptions/012345678901234567890123456789ab/redemptions', 'subscriptions/redemptions-200.xml'); diff --git a/Tests/fixtures/subscriptions/show-200-QBP.xml b/Tests/fixtures/subscriptions/show-200-QBP.xml new file mode 100644 index 00000000..b1a6c7a2 --- /dev/null +++ b/Tests/fixtures/subscriptions/show-200-QBP.xml @@ -0,0 +1,68 @@ +HTTP/1.1 200 OK +Content-Type: application/xml; charset=utf-8 + + + + + + + silver + Silver Plan + + 012345678901234567890123456789ab + active + 10 + manual + 1000 + 1 + 1000 + 2011-04-30T07:00:00Z + + + 2011-04-01T07:00:00Z + 2011-05-01T06:59:59Z + + + 0 + usst + Some Terms and Conditions + Some Customer Notes + Some VAT Notes + false + plan_free_trial + + 1> + 2020-01-01T01:00:00Z + + + fixed + marketing_emails + Marketing Emails + 1 + evenly + tiered + + + 60 + 123 + + + 999999999 + 80 + + + + + + + shasta + ate my tacos + + + license-number + 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz + + + + + diff --git a/lib/recurly/tier.php b/lib/recurly/tier.php index f4f1a2a8..d6a5939d 100644 --- a/lib/recurly/tier.php +++ b/lib/recurly/tier.php @@ -32,4 +32,9 @@ protected function getWriteableAttributes() 'unit_amount_in_cents', 'ending_quantity' ); } + + // Includes tier attributes in request body for subscription add-ons + protected function getChangedAttributes($nested = false) { + return $this->_values; + } }