HEX
Server: nginx/1.27.1
System: Linux in-4 5.15.0-131-generic #141-Ubuntu SMP Fri Jan 10 21:18:28 UTC 2025 x86_64
User: ilikadirect (1186)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system,proc_open,popen,parse_ini_file,show_source
Upload Files
File: /storage/v6964/avoxlive/public_html/application/libraries/stripe-php/tests/SubscriptionTest.php
<?php

namespace Stripe;

class SubscriptionTest extends TestCase
{

    public function testCreateUpdateCancel()
    {
        $planID = 'gold-' . self::randomString();
        self::retrieveOrCreatePlan($planID);

        $customer = self::createTestCustomer();

        $sub = $customer->subscriptions->create(array('plan' => $planID));

        $this->assertSame($sub->status, 'active');
        $this->assertSame($sub->plan->id, $planID);

        $sub->quantity = 2;
        $sub->save();

        $sub = $customer->subscriptions->retrieve($sub->id);
        $this->assertSame($sub->status, 'active');
        $this->assertSame($sub->plan->id, $planID);
        $this->assertSame($sub->quantity, 2);

        $sub->cancel(array('at_period_end' => true));

        $sub = $customer->subscriptions->retrieve($sub->id);
        $this->assertSame($sub->status, 'active');
        // @codingStandardsIgnoreStart
        $this->assertTrue($sub->cancel_at_period_end);
        // @codingStandardsIgnoreEnd
    }

    public function testDeleteDiscount()
    {
        $planID = 'gold-' . self::randomString();
        self::retrieveOrCreatePlan($planID);

        $couponID = '25off-' . self::randomString();
        self::retrieveOrCreateCoupon($couponID);

        $customer = self::createTestCustomer();

        $sub = $customer->subscriptions->create(
            array(
                'plan' => $planID,
                'coupon' => $couponID
            )
        );

        $this->assertSame($sub->status, 'active');
        $this->assertSame($sub->plan->id, $planID);
        $this->assertSame($sub->discount->coupon->id, $couponID);

        $sub->deleteDiscount();
        $sub = $customer->subscriptions->retrieve($sub->id);
        $this->assertNull($sub->discount);
    }
}