function Braintree_TransactionTest::testSnapshotPlanIdAddOnsAndDiscountsFromSubscription in Commerce Braintree 7
File
- braintree_php/
tests/ integration/ TransactionTest.php, line 1275
Class
Code
function testSnapshotPlanIdAddOnsAndDiscountsFromSubscription() {
$creditCard = Braintree_SubscriptionTestHelper::createCreditCard();
$plan = Braintree_SubscriptionTestHelper::triallessPlan();
$result = Braintree_Subscription::create(array(
'paymentMethodToken' => $creditCard->token,
'planId' => $plan['id'],
'addOns' => array(
'add' => array(
array(
'amount' => '11.00',
'inheritedFromId' => 'increase_10',
'quantity' => 2,
'numberOfBillingCycles' => 5,
),
array(
'amount' => '21.00',
'inheritedFromId' => 'increase_20',
'quantity' => 3,
'numberOfBillingCycles' => 6,
),
),
),
'discounts' => array(
'add' => array(
array(
'amount' => '7.50',
'inheritedFromId' => 'discount_7',
'quantity' => 2,
'neverExpires' => true,
),
),
),
));
$transaction = $result->subscription->transactions[0];
$this
->assertEquals($transaction->planId, $plan['id']);
$addOns = $transaction->addOns;
Braintree_SubscriptionTestHelper::sortModificationsById($addOns);
$this
->assertEquals($addOns[0]->amount, "11.00");
$this
->assertEquals($addOns[0]->id, "increase_10");
$this
->assertEquals($addOns[0]->quantity, 2);
$this
->assertEquals($addOns[0]->numberOfBillingCycles, 5);
$this
->assertFalse($addOns[0]->neverExpires);
$this
->assertEquals($addOns[1]->amount, "21.00");
$this
->assertEquals($addOns[1]->id, "increase_20");
$this
->assertEquals($addOns[1]->quantity, 3);
$this
->assertEquals($addOns[1]->numberOfBillingCycles, 6);
$this
->assertFalse($addOns[1]->neverExpires);
$discounts = $transaction->discounts;
$this
->assertEquals($discounts[0]->amount, "7.50");
$this
->assertEquals($discounts[0]->id, "discount_7");
$this
->assertEquals($discounts[0]->quantity, 2);
$this
->assertEquals($discounts[0]->numberOfBillingCycles, null);
$this
->assertTrue($discounts[0]->neverExpires);
}