mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-05 18:23:48 +00:00
added it_resume_subscription test
This commit is contained in:
@@ -139,7 +139,7 @@ class SubscriptionController extends Controller
|
||||
*/
|
||||
public function resume()
|
||||
{
|
||||
$user = Auth::user();
|
||||
$user = User::find(Auth::id());
|
||||
|
||||
// Check if is demo
|
||||
if (is_demo($user->id)) {
|
||||
|
||||
@@ -16,10 +16,51 @@ class SubscriptionTest extends TestCase
|
||||
{
|
||||
use DatabaseMigrations;
|
||||
|
||||
private $user;
|
||||
|
||||
private $plan;
|
||||
|
||||
private $billing;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
//$this->subscription = app()->make(StripeService::class);
|
||||
|
||||
// Define test user
|
||||
$this->user = [
|
||||
'email' => 'howdy@hi5ve.digital',
|
||||
'stripe_id' => 'cus_HgbhvNCbSwV8Qg',
|
||||
'card_brand' => 'visa',
|
||||
'card_last_four' => 4242,
|
||||
];
|
||||
|
||||
// Define test plan to subscribe
|
||||
$this->plan = [
|
||||
'data' => [
|
||||
'id' => "business-pack",
|
||||
'type' => "plans",
|
||||
'attributes' => [
|
||||
'name' => "Business Packs",
|
||||
'description' => "When your business start grow up.",
|
||||
'price' => "$44.99",
|
||||
'capacity' => 1000,
|
||||
'capacity_formatted' => "1TB",
|
||||
'currency' => "USD",
|
||||
'tax_rates' => [],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
// Define test billing to subscribe
|
||||
$this->billing = [
|
||||
'billing_address' => '2794 Alfreda Mount Suite 467 East Crystalberg',
|
||||
'billing_city' => 'Christianfort',
|
||||
'billing_country' => 'SK',
|
||||
'billing_name' => 'Heidi Romaguera PhD',
|
||||
'billing_phone_number' => '',
|
||||
'billing_postal_code' => '59445',
|
||||
'billing_state' => 'SK',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,48 +85,21 @@ class SubscriptionTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
*/
|
||||
public function it_upgrade_plan()
|
||||
{
|
||||
$user = User::factory(User::class)
|
||||
->create([
|
||||
'email' => 'howdy@hi5ve.digital',
|
||||
'stripe_id' => 'cus_HgbhvNCbSwV8Qg',
|
||||
'card_brand' => 'visa',
|
||||
'card_last_four' => 4242,
|
||||
]);
|
||||
->create($this->user);
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$this->postJson('/api/user/subscription/upgrade', [
|
||||
'billing' => [
|
||||
'billing_address' => $user->settings->address,
|
||||
'billing_city' => $user->settings->city,
|
||||
'billing_country' => $user->settings->country,
|
||||
'billing_name' => $user->settings->name,
|
||||
'billing_phone_number' => $user->settings->phone_number,
|
||||
'billing_postal_code' => $user->settings->postal_code,
|
||||
'billing_state' => $user->settings->state,
|
||||
],
|
||||
'billing' => $this->billing,
|
||||
'plan' => $this->plan,
|
||||
'payment' => [
|
||||
'type' => 'stripe',
|
||||
],
|
||||
'plan' => [
|
||||
'data' => [
|
||||
'id' => "business-pack",
|
||||
'type' => "plans",
|
||||
'attributes' => [
|
||||
'name' => "Business Packs",
|
||||
'description' => "When your business start grow up.",
|
||||
'price' => "$44.99",
|
||||
'capacity' => 1000,
|
||||
'capacity_formatted' => "1TB",
|
||||
'currency' => "USD",
|
||||
'tax_rates' => [],
|
||||
],
|
||||
],
|
||||
],
|
||||
])->assertStatus(204);
|
||||
|
||||
$this->assertDatabaseHas('subscriptions', [
|
||||
@@ -98,55 +112,57 @@ class SubscriptionTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
*/
|
||||
public function it_cancel_subscription()
|
||||
{
|
||||
$user = User::factory(User::class)
|
||||
->create([
|
||||
'email' => 'howdy@hi5ve.digital',
|
||||
'stripe_id' => 'cus_HgbhvNCbSwV8Qg',
|
||||
'card_brand' => 'visa',
|
||||
'card_last_four' => 4242,
|
||||
]);
|
||||
->create($this->user);
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$this->postJson('/api/user/subscription/upgrade', [
|
||||
'billing' => [
|
||||
'billing_address' => $user->settings->address,
|
||||
'billing_city' => $user->settings->city,
|
||||
'billing_country' => $user->settings->country,
|
||||
'billing_name' => $user->settings->name,
|
||||
'billing_phone_number' => $user->settings->phone_number,
|
||||
'billing_postal_code' => $user->settings->postal_code,
|
||||
'billing_state' => $user->settings->state,
|
||||
],
|
||||
'billing' => $this->billing,
|
||||
'plan' => $this->plan,
|
||||
'payment' => [
|
||||
'type' => 'stripe',
|
||||
],
|
||||
'plan' => [
|
||||
'data' => [
|
||||
'id' => "business-pack",
|
||||
'type' => "plans",
|
||||
'attributes' => [
|
||||
'name' => "Business Packs",
|
||||
'description' => "When your business start grow up.",
|
||||
'price' => "$44.99",
|
||||
'capacity' => 1000,
|
||||
'capacity_formatted' => "1TB",
|
||||
'currency' => "USD",
|
||||
'tax_rates' => [],
|
||||
],
|
||||
],
|
||||
],
|
||||
])->assertStatus(204);
|
||||
|
||||
$this->postJson('/api/user/subscription/cancel')
|
||||
->assertStatus(204);
|
||||
|
||||
$this->assertDatabaseMissing('subscriptions', [
|
||||
'ends_at' => 'canceled'
|
||||
'ends_at' => null
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_resume_subscription()
|
||||
{
|
||||
$user = User::factory(User::class)
|
||||
->create($this->user);
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$this->postJson('/api/user/subscription/upgrade', [
|
||||
'billing' => $this->billing,
|
||||
'plan' => $this->plan,
|
||||
'payment' => [
|
||||
'type' => 'stripe',
|
||||
],
|
||||
])->assertStatus(204);
|
||||
|
||||
$this->postJson('/api/user/subscription/cancel')
|
||||
->assertStatus(204);
|
||||
|
||||
$this->postJson('/api/user/subscription/resume')
|
||||
->assertStatus(204);
|
||||
|
||||
$this->assertDatabaseHas('subscriptions', [
|
||||
'ends_at' => null
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user