2021-03-09 15:25:50 +01:00
|
|
|
<?php
|
2021-03-09 23:23:13 +01:00
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
|
|
|
*
|
2022-06-21 11:57:17 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2021-03-09 23:23:13 +01:00
|
|
|
*/
|
2021-03-09 15:25:50 +01:00
|
|
|
|
|
|
|
namespace Tests\Feature;
|
|
|
|
|
2024-01-14 02:34:40 +01:00
|
|
|
use Tests\TestCase;
|
2024-04-02 03:06:20 +02:00
|
|
|
use App\Models\User;
|
|
|
|
use App\Models\Client;
|
|
|
|
use App\Models\Company;
|
2024-01-14 02:34:40 +01:00
|
|
|
use App\Models\Invoice;
|
2021-03-09 15:25:50 +01:00
|
|
|
use App\Models\Product;
|
2024-01-14 02:34:40 +01:00
|
|
|
use Tests\MockAccountData;
|
|
|
|
use Illuminate\Support\Str;
|
2024-04-02 03:06:20 +02:00
|
|
|
use App\Models\CompanyToken;
|
2021-04-01 11:56:50 +02:00
|
|
|
use App\Models\Subscription;
|
2021-03-09 15:25:50 +01:00
|
|
|
use App\Utils\Traits\MakesHash;
|
2024-04-02 03:06:20 +02:00
|
|
|
use App\Models\RecurringInvoice;
|
|
|
|
use App\DataMapper\CompanySettings;
|
|
|
|
use App\Factory\CompanyUserFactory;
|
2021-03-09 15:25:50 +01:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
use Illuminate\Support\Facades\Session;
|
2021-04-14 08:48:32 +02:00
|
|
|
use Illuminate\Validation\ValidationException;
|
2024-01-14 02:34:40 +01:00
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
2021-03-09 15:25:50 +01:00
|
|
|
|
2021-03-09 23:23:13 +01:00
|
|
|
/**
|
|
|
|
* @test
|
2021-03-25 11:55:59 +01:00
|
|
|
* @covers App\Http\Controllers\SubscriptionController
|
2021-03-09 23:23:13 +01:00
|
|
|
*/
|
2021-03-25 11:55:59 +01:00
|
|
|
class SubscriptionApiTest extends TestCase
|
2021-03-09 15:25:50 +01:00
|
|
|
{
|
|
|
|
use MakesHash;
|
|
|
|
use DatabaseTransactions;
|
|
|
|
use MockAccountData;
|
|
|
|
|
2024-01-14 02:34:40 +01:00
|
|
|
protected $faker;
|
|
|
|
|
2022-06-21 12:00:57 +02:00
|
|
|
protected function setUp(): void
|
2021-03-09 15:25:50 +01:00
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$this->makeTestData();
|
|
|
|
|
2021-04-14 08:48:32 +02:00
|
|
|
$this->withoutExceptionHandling();
|
|
|
|
|
2021-03-09 15:25:50 +01:00
|
|
|
Session::start();
|
|
|
|
|
|
|
|
$this->faker = \Faker\Factory::create();
|
|
|
|
|
|
|
|
Model::reguard();
|
|
|
|
}
|
|
|
|
|
2024-04-02 03:06:20 +02:00
|
|
|
public function testSubscriptionCronLocalization()
|
|
|
|
{
|
|
|
|
|
|
|
|
$settings = CompanySettings::defaults();
|
|
|
|
$settings->timezone_id = '50'; //europe/vienna
|
|
|
|
|
|
|
|
$c2 = Company::factory()->create([
|
|
|
|
'account_id' => $this->company->account_id,
|
|
|
|
'settings' => $settings
|
|
|
|
]);
|
|
|
|
|
|
|
|
$cu = CompanyUserFactory::create($this->user->id, $c2->id, $this->account->id);
|
|
|
|
$cu->is_owner = true;
|
|
|
|
$cu->is_admin = true;
|
|
|
|
$cu->is_locked = true;
|
|
|
|
$cu->permissions = '["view_client"]';
|
|
|
|
$cu->save();
|
|
|
|
|
|
|
|
$different_company_token = \Illuminate\Support\Str::random(64);
|
|
|
|
|
|
|
|
$company_token = new CompanyToken();
|
|
|
|
$company_token->user_id = $this->user->id;
|
|
|
|
$company_token->company_id = $c2->id;
|
|
|
|
$company_token->account_id = $c2->account_id;
|
|
|
|
$company_token->name = 'test token';
|
|
|
|
$company_token->token = $different_company_token;
|
|
|
|
$company_token->is_system = true;
|
|
|
|
$company_token->save();
|
|
|
|
|
|
|
|
|
|
|
|
$s = Subscription::factory()->create([
|
|
|
|
'company_id' => $c2->id,
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
]);
|
|
|
|
|
|
|
|
$client2 = Client::factory()->create([
|
|
|
|
'company_id' => $c2->id,
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
]);
|
|
|
|
|
|
|
|
$i = Invoice::factory()->create([
|
|
|
|
'company_id' => $c2->id,
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
'subscription_id' => $s->id,
|
|
|
|
'due_date' => now()->startOfDay(),
|
|
|
|
'client_id' => $client2->id,
|
|
|
|
'status_id' => Invoice::STATUS_SENT
|
|
|
|
]);
|
|
|
|
|
|
|
|
$settings = CompanySettings::defaults();
|
|
|
|
$settings->timezone_id = '110'; //sydney/australia
|
|
|
|
|
|
|
|
$c = Company::factory()->create([
|
|
|
|
'account_id' => $this->company->account_id,
|
|
|
|
'settings' => $settings,
|
|
|
|
]);
|
|
|
|
|
|
|
|
$cu = CompanyUserFactory::create($this->user->id, $c->id, $this->account->id);
|
|
|
|
$cu->is_owner = true;
|
|
|
|
$cu->is_admin = true;
|
|
|
|
$cu->is_locked = true;
|
|
|
|
$cu->permissions = '["view_client"]';
|
|
|
|
$cu->save();
|
|
|
|
|
|
|
|
$different_company_token = \Illuminate\Support\Str::random(64);
|
|
|
|
|
|
|
|
$company_token = new CompanyToken();
|
|
|
|
$company_token->user_id = $this->user->id;
|
|
|
|
$company_token->company_id = $c->id;
|
|
|
|
$company_token->account_id = $c->account_id;
|
|
|
|
$company_token->name = 'test token';
|
|
|
|
$company_token->token = $different_company_token;
|
|
|
|
$company_token->is_system = true;
|
|
|
|
$company_token->save();
|
|
|
|
|
|
|
|
$s1 = Subscription::factory()->create([
|
|
|
|
'company_id' => $c->id,
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
$client = Client::factory()->create([
|
|
|
|
'company_id' => $c2->id,
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
]);
|
|
|
|
|
|
|
|
$i = Invoice::factory()->create([
|
|
|
|
'company_id' => $c->id,
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
'subscription_id' => $s1->id,
|
|
|
|
'due_date' => now()->startOfDay(),
|
|
|
|
'client_id' => $client->id,
|
|
|
|
'status_id' => Invoice::STATUS_SENT
|
|
|
|
]);
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
$company = Company::find($c->id); //sydney
|
|
|
|
|
|
|
|
$timezone_now = now()->setTimezone($company->timezone()->name);
|
|
|
|
|
|
|
|
$this->assertEquals('Australia/Sydney', $timezone_now->timezoneName);
|
|
|
|
|
|
|
|
$this->travelTo($timezone_now->copy()->startOfDay()->subHour());
|
|
|
|
|
|
|
|
$i = false;
|
|
|
|
|
|
|
|
//Capture companies within the window of 00:00 and 00:30
|
|
|
|
if($timezone_now->gte($timezone_now->copy()->startOfDay()) && $timezone_now->lt($timezone_now->copy()->startOfDay()->addMinutes(30))) {
|
|
|
|
|
|
|
|
$i = Invoice::query()
|
|
|
|
->where('company_id', $company->id)
|
|
|
|
->whereNull('deleted_at')
|
|
|
|
->where('is_deleted', 0)
|
|
|
|
->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL])
|
|
|
|
->where('is_proforma', 0)
|
|
|
|
->whereNotNull('subscription_id')
|
|
|
|
->where('balance', '>', 0)
|
|
|
|
->whereDate('due_date', '<=', now()->setTimezone($company->timezone()->name)->addDay()->startOfDay())
|
|
|
|
->get();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->assertFalse($i);
|
|
|
|
|
|
|
|
$this->travelTo($timezone_now->copy()->startOfDay());
|
|
|
|
|
|
|
|
if(now()->gte($timezone_now->copy()->startOfDay()) && now()->lt($timezone_now->copy()->startOfDay()->addMinutes(30))) {
|
|
|
|
|
|
|
|
$i = Invoice::query()
|
|
|
|
->where('company_id', $company->id)
|
|
|
|
->whereNull('deleted_at')
|
|
|
|
->where('is_deleted', 0)
|
|
|
|
->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL])
|
|
|
|
->where('is_proforma', 0)
|
|
|
|
->whereNotNull('subscription_id')
|
|
|
|
->whereDate('due_date', '<=', now()->setTimezone($company->timezone()->name)->addDay()->startOfDay())
|
|
|
|
->get();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->assertEquals(1, $i->count());
|
|
|
|
|
|
|
|
$i = false;
|
|
|
|
|
|
|
|
$this->travelTo($timezone_now->copy()->startOfDay()->addHours(2));
|
|
|
|
|
|
|
|
if($timezone_now->gte($timezone_now->copy()->startOfDay()) && $timezone_now->lt($timezone_now->copy()->startOfDay()->addMinutes(30))) {
|
|
|
|
|
|
|
|
$i = Invoice::query()
|
|
|
|
->where('company_id', $company->id)
|
|
|
|
->whereNull('deleted_at')
|
|
|
|
->where('is_deleted', 0)
|
|
|
|
->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL])
|
|
|
|
->where('is_proforma', 0)
|
|
|
|
->whereNotNull('subscription_id')
|
|
|
|
->where('balance', '>', 0)
|
|
|
|
->whereDate('due_date', '<=', now()->setTimezone($company->timezone()->name)->addDay()->startOfDay())
|
|
|
|
->get();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->assertFalse($i);
|
|
|
|
|
2024-04-04 05:17:34 +02:00
|
|
|
$count = Invoice::whereNotNull('subscription_id')->whereIn('company_id', [$c2->id, $c->id])->count();
|
2024-04-02 03:06:20 +02:00
|
|
|
|
|
|
|
$this->assertEquals(2, $count);
|
|
|
|
|
|
|
|
$this->travelBack();
|
|
|
|
//////////////////////////////////////////// vienna //////////////////////////////////////////////////
|
|
|
|
|
|
|
|
$company = Company::find($c2->id); //vienna
|
|
|
|
|
|
|
|
$timezone_now = now()->setTimezone($company->timezone()->name);
|
|
|
|
|
|
|
|
$this->assertEquals('Europe/Vienna', $timezone_now->timezoneName);
|
|
|
|
|
2024-04-14 00:16:58 +02:00
|
|
|
$this->travelTo($timezone_now->startOfDay()->subHours(2));
|
2024-04-02 03:06:20 +02:00
|
|
|
|
|
|
|
$i = false;
|
|
|
|
|
|
|
|
//Capture companies within the window of 00:00 and 00:30
|
|
|
|
if($timezone_now->gte($timezone_now->copy()->startOfDay()) && $timezone_now->lt($timezone_now->copy()->startOfDay()->addMinutes(30))) {
|
|
|
|
|
|
|
|
$i = Invoice::query()
|
|
|
|
->where('company_id', $company->id)
|
|
|
|
->whereNull('deleted_at')
|
|
|
|
->where('is_deleted', 0)
|
|
|
|
->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL])
|
|
|
|
->where('is_proforma', 0)
|
|
|
|
->whereNotNull('subscription_id')
|
|
|
|
->where('balance', '>', 0)
|
|
|
|
->whereDate('due_date', '<=', now()->setTimezone($company->timezone()->name)->addDay()->startOfDay())
|
|
|
|
->get();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->assertFalse($i);
|
|
|
|
|
|
|
|
$this->travelTo($timezone_now->copy()->startOfDay());
|
|
|
|
|
|
|
|
if(now()->gte($timezone_now->copy()->startOfDay()) && now()->lt($timezone_now->copy()->startOfDay()->addMinutes(30))) {
|
|
|
|
|
|
|
|
$i = Invoice::query()
|
|
|
|
->where('company_id', $company->id)
|
|
|
|
->whereNull('deleted_at')
|
|
|
|
->where('is_deleted', 0)
|
|
|
|
->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL])
|
|
|
|
->where('is_proforma', 0)
|
|
|
|
->whereNotNull('subscription_id')
|
|
|
|
->whereDate('due_date', '<=', now()->setTimezone($company->timezone()->name)->addDay()->startOfDay())
|
|
|
|
->get();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->assertEquals(1, $i->count());
|
|
|
|
|
|
|
|
$i = false;
|
|
|
|
|
|
|
|
$this->travelTo($timezone_now->copy()->startOfDay()->addHours(2));
|
|
|
|
|
|
|
|
if($timezone_now->gte($timezone_now->copy()->startOfDay()) && $timezone_now->lt($timezone_now->copy()->startOfDay()->addMinutes(30))) {
|
|
|
|
|
|
|
|
$i = Invoice::query()
|
|
|
|
->where('company_id', $company->id)
|
|
|
|
->whereNull('deleted_at')
|
|
|
|
->where('is_deleted', 0)
|
|
|
|
->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL])
|
|
|
|
->where('is_proforma', 0)
|
|
|
|
->whereNotNull('subscription_id')
|
|
|
|
->where('balance', '>', 0)
|
|
|
|
->whereDate('due_date', '<=', now()->setTimezone($company->timezone()->name)->addDay()->startOfDay())
|
|
|
|
->get();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->assertFalse($i);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-01-14 02:34:40 +01:00
|
|
|
public function testAssignInvoice()
|
|
|
|
{
|
|
|
|
$i = Invoice::factory()
|
|
|
|
->create([
|
|
|
|
'company_id' => $this->company->id,
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
'client_id' => $this->client->id,
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
$s = Subscription::factory()
|
|
|
|
->create([
|
|
|
|
'company_id' => $this->company->id,
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
$data = [
|
|
|
|
'ids' => [$s->hashed_id],
|
|
|
|
'entity' => 'invoice',
|
|
|
|
'entity_id' => $i->hashed_id,
|
|
|
|
'action' => 'assign_invoice'
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
$response = $this->withHeaders([
|
|
|
|
'X-API-SECRET' => config('ninja.api_secret'),
|
|
|
|
'X-API-TOKEN' => $this->token,
|
|
|
|
])->postJson('/api/v1/subscriptions/bulk', $data);
|
|
|
|
|
|
|
|
$response->assertStatus(200);
|
|
|
|
|
|
|
|
$i = $i->fresh();
|
|
|
|
|
|
|
|
$this->assertEquals($s->id, $i->subscription_id);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testAssignRecurringInvoice()
|
|
|
|
{
|
|
|
|
$i = RecurringInvoice::factory()
|
|
|
|
->create([
|
|
|
|
'company_id' => $this->company->id,
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
'client_id' => $this->client->id,
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
$s = Subscription::factory()
|
|
|
|
->create([
|
|
|
|
'company_id' => $this->company->id,
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
$data = [
|
|
|
|
'ids' => [$s->hashed_id],
|
|
|
|
'entity' => 'recurring_invoice',
|
|
|
|
'entity_id' => $i->hashed_id,
|
|
|
|
'action' => 'assign_invoice'
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
$response = $this->withHeaders([
|
|
|
|
'X-API-SECRET' => config('ninja.api_secret'),
|
|
|
|
'X-API-TOKEN' => $this->token,
|
|
|
|
])->postJson('/api/v1/subscriptions/bulk', $data);
|
|
|
|
|
|
|
|
$response->assertStatus(200);
|
|
|
|
|
|
|
|
$i = $i->fresh();
|
|
|
|
|
|
|
|
$this->assertEquals($s->id, $i->subscription_id);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-01-19 01:52:07 +01:00
|
|
|
public function testSubscriptionFilter()
|
|
|
|
{
|
|
|
|
$response = $this->withHeaders([
|
|
|
|
'X-API-SECRET' => config('ninja.api_secret'),
|
|
|
|
'X-API-TOKEN' => $this->token,
|
|
|
|
])->get('/api/v1/subscriptions?filter=xx')
|
|
|
|
->assertStatus(200);
|
|
|
|
}
|
|
|
|
|
2021-03-25 11:55:59 +01:00
|
|
|
public function testSubscriptionsGet()
|
2021-03-09 15:25:50 +01:00
|
|
|
{
|
|
|
|
$product = Product::factory()->create([
|
|
|
|
'company_id' => $this->company->id,
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
]);
|
|
|
|
|
2021-03-25 11:55:59 +01:00
|
|
|
$billing_subscription = Subscription::factory()->create([
|
2021-03-25 20:42:25 +01:00
|
|
|
'product_ids' => $product->id,
|
2021-03-09 15:25:50 +01:00
|
|
|
'company_id' => $this->company->id,
|
2022-06-21 11:57:17 +02:00
|
|
|
'name' => Str::random(5),
|
2021-03-09 15:25:50 +01:00
|
|
|
]);
|
|
|
|
|
|
|
|
$response = $this->withHeaders([
|
|
|
|
'X-API-SECRET' => config('ninja.api_secret'),
|
|
|
|
'X-API-TOKEN' => $this->token,
|
2022-06-21 11:57:17 +02:00
|
|
|
])->get('/api/v1/subscriptions/'.$this->encodePrimaryKey($billing_subscription->id));
|
|
|
|
|
2021-03-25 11:55:59 +01:00
|
|
|
// nlog($response);
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2021-03-09 15:25:50 +01:00
|
|
|
$response->assertStatus(200);
|
|
|
|
}
|
|
|
|
|
2021-03-25 11:55:59 +01:00
|
|
|
public function testSubscriptionsPost()
|
2021-03-09 15:25:50 +01:00
|
|
|
{
|
|
|
|
$product = Product::factory()->create([
|
|
|
|
'company_id' => $this->company->id,
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
]);
|
2024-04-04 05:17:34 +02:00
|
|
|
|
2021-03-09 15:25:50 +01:00
|
|
|
|
|
|
|
$response = $this->withHeaders([
|
|
|
|
'X-API-SECRET' => config('ninja.api_secret'),
|
|
|
|
'X-API-TOKEN' => $this->token,
|
2024-04-04 05:17:34 +02:00
|
|
|
])->post('/api/v1/subscriptions', ['steps' => "cart,auth.login-or-register",'product_ids' => $product->hashed_id, 'allow_cancellation' => true, 'name' => Str::random(5)]);
|
2021-03-09 15:25:50 +01:00
|
|
|
|
2021-03-27 04:22:19 +01:00
|
|
|
// nlog($response);
|
2021-03-09 15:25:50 +01:00
|
|
|
$response->assertStatus(200);
|
|
|
|
}
|
|
|
|
|
2021-03-25 11:55:59 +01:00
|
|
|
public function testSubscriptionPut()
|
2021-03-09 15:25:50 +01:00
|
|
|
{
|
|
|
|
$product = Product::factory()->create([
|
|
|
|
'company_id' => $this->company->id,
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
]);
|
|
|
|
|
|
|
|
$response1 = $this
|
2022-06-21 11:57:17 +02:00
|
|
|
->withHeaders(['X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token])
|
2024-04-04 05:17:34 +02:00
|
|
|
->post('/api/v1/subscriptions', ['steps' => "cart,auth.login-or-register",'product_ids' => $product->hashed_id, 'name' => Str::random(5)])
|
2021-03-09 15:25:50 +01:00
|
|
|
->assertStatus(200)
|
|
|
|
->json();
|
|
|
|
|
2021-04-14 08:48:32 +02:00
|
|
|
// try {
|
2022-06-21 11:57:17 +02:00
|
|
|
$response2 = $this
|
|
|
|
->withHeaders(['X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token])
|
2024-04-04 05:17:34 +02:00
|
|
|
->put('/api/v1/subscriptions/'.$response1['data']['id'], ['steps' => "cart,auth.login-or-register",'allow_cancellation' => true])
|
2021-03-09 15:25:50 +01:00
|
|
|
->assertStatus(200)
|
|
|
|
->json();
|
2022-06-21 11:57:17 +02:00
|
|
|
// }catch(ValidationException $e) {
|
|
|
|
// nlog($e->validator->getMessageBag());
|
2021-04-14 08:48:32 +02:00
|
|
|
// }
|
2021-03-09 15:25:50 +01:00
|
|
|
|
|
|
|
$this->assertNotEquals($response1['data']['allow_cancellation'], $response2['data']['allow_cancellation']);
|
|
|
|
}
|
|
|
|
|
2021-03-25 11:55:59 +01:00
|
|
|
public function testSubscriptionDeleted()
|
2021-03-09 15:25:50 +01:00
|
|
|
{
|
|
|
|
$product = Product::factory()->create([
|
|
|
|
'company_id' => $this->company->id,
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
]);
|
|
|
|
|
2021-03-25 11:55:59 +01:00
|
|
|
$billing_subscription = Subscription::factory()->create([
|
2021-03-25 20:42:25 +01:00
|
|
|
'product_ids' => $product->id,
|
2021-03-09 15:25:50 +01:00
|
|
|
'company_id' => $this->company->id,
|
2022-06-21 11:57:17 +02:00
|
|
|
'name' => Str::random(5),
|
2021-03-09 15:25:50 +01:00
|
|
|
]);
|
|
|
|
|
|
|
|
$response = $this
|
|
|
|
->withHeaders(['X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token])
|
2022-06-21 11:57:17 +02:00
|
|
|
->delete('/api/v1/subscriptions/'.$this->encodePrimaryKey($billing_subscription->id))
|
2021-03-09 15:25:50 +01:00
|
|
|
->assertStatus(200)
|
|
|
|
->json();
|
|
|
|
}
|
|
|
|
}
|