Skip to content

Commit

Permalink
Add test for scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
driesvints committed Dec 22, 2020
1 parent 1fb4deb commit fed057d
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/Feature/SubscriptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -752,4 +752,40 @@ public function test_subscriptions_with_options_can_be_created()

$this->assertEquals($backdateStartDate, $stripeSubscription->start_date);
}

/** @link https://github.com/laravel/cashier-stripe/issues/1041 */
public function test_new_subscription_after_previous_cancellation_means_customer_is_subscribed()
{
$user = $this->createCustomer('subscriptions_with_options_can_be_created');

$subscription = $user->subscriptions()->create([
'name' => 'default',
'stripe_id' => 'sub_xxx',
'stripe_status' => 'active',
'stripe_plan' => 'price_xxx',
'quantity' => 1,
'trial_ends_at' => null,
'ends_at' => null,
]);

$this->assertTrue($user->refresh()->subscribed());

$subscription->markAsCancelled();

$this->assertFalse($user->refresh()->subscribed());

$subscription->markAsCancelled();

$user->subscriptions()->create([
'name' => 'default',
'stripe_id' => 'sub_xxx',
'stripe_status' => 'active',
'stripe_plan' => 'price_xxx',
'quantity' => 1,
'trial_ends_at' => null,
'ends_at' => null,
]);

$this->assertTrue($user->refresh()->subscribed());
}
}

0 comments on commit fed057d

Please sign in to comment.