mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 22:14:36 -04:00
Fixes for tests
This commit is contained in:
parent
4c4f4961a7
commit
c2990a21d0
@ -229,8 +229,8 @@ class CreateSingleAccount extends Command
|
|||||||
'company_id' => $company->id,
|
'company_id' => $company->id,
|
||||||
'product_key' => 'enterprise_plan',
|
'product_key' => 'enterprise_plan',
|
||||||
'notes' => 'The Enterprise Plan',
|
'notes' => 'The Enterprise Plan',
|
||||||
'cost' => 10,
|
'cost' => 14,
|
||||||
'price' => 10,
|
'price' => 14,
|
||||||
'quantity' => 1,
|
'quantity' => 1,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -35,7 +35,6 @@ class SubscriptionPlanSwitchController extends Controller
|
|||||||
$amount = $recurring_invoice->subscription
|
$amount = $recurring_invoice->subscription
|
||||||
->service()
|
->service()
|
||||||
->calculateUpgradePrice($recurring_invoice, $target);
|
->calculateUpgradePrice($recurring_invoice, $target);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Null value here is a proxy for
|
* Null value here is a proxy for
|
||||||
|
@ -82,6 +82,7 @@ class SubscriptionPlanSwitch extends Component
|
|||||||
|
|
||||||
public function handleBeforePaymentEvents(): void
|
public function handleBeforePaymentEvents(): void
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->state['show_loading_bar'] = true;
|
$this->state['show_loading_bar'] = true;
|
||||||
|
|
||||||
$this->state['invoice'] = $this->target->service()->createChangePlanInvoice([
|
$this->state['invoice'] = $this->target->service()->createChangePlanInvoice([
|
||||||
|
@ -56,7 +56,7 @@ class UpdateSubscriptionRequest extends Request
|
|||||||
'allow_plan_changes' => ['sometimes'],
|
'allow_plan_changes' => ['sometimes'],
|
||||||
'refund_period' => ['sometimes'],
|
'refund_period' => ['sometimes'],
|
||||||
'webhook_configuration' => ['array'],
|
'webhook_configuration' => ['array'],
|
||||||
'name' => ['required', Rule::unique('subscriptions')->where('company_id', auth()->user()->company()->id)->ignore($this->subscription->id)]
|
'name' => ['sometimes', Rule::unique('subscriptions')->where('company_id', auth()->user()->company()->id)->ignore($this->subscription->id)]
|
||||||
];
|
];
|
||||||
|
|
||||||
return $this->globalRules($rules);
|
return $this->globalRules($rules);
|
||||||
|
@ -21,6 +21,7 @@ use Illuminate\Foundation\Testing\RefreshDatabase;
|
|||||||
use Illuminate\Foundation\Testing\WithFaker;
|
use Illuminate\Foundation\Testing\WithFaker;
|
||||||
use Illuminate\Support\Facades\Session;
|
use Illuminate\Support\Facades\Session;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
use Tests\MockAccountData;
|
use Tests\MockAccountData;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
@ -40,6 +41,8 @@ class SubscriptionApiTest extends TestCase
|
|||||||
|
|
||||||
$this->makeTestData();
|
$this->makeTestData();
|
||||||
|
|
||||||
|
$this->withoutExceptionHandling();
|
||||||
|
|
||||||
Session::start();
|
Session::start();
|
||||||
|
|
||||||
$this->faker = \Faker\Factory::create();
|
$this->faker = \Faker\Factory::create();
|
||||||
@ -92,20 +95,23 @@ class SubscriptionApiTest extends TestCase
|
|||||||
$product = Product::factory()->create([
|
$product = Product::factory()->create([
|
||||||
'company_id' => $this->company->id,
|
'company_id' => $this->company->id,
|
||||||
'user_id' => $this->user->id,
|
'user_id' => $this->user->id,
|
||||||
'frequency_id' => RecurringInvoice::FREQUENCY_MONTHLY,
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response1 = $this
|
$response1 = $this
|
||||||
->withHeaders(['X-API-SECRET' => config('ninja.api_secret'),'X-API-TOKEN' => $this->token])
|
->withHeaders(['X-API-SECRET' => config('ninja.api_secret'),'X-API-TOKEN' => $this->token])
|
||||||
->post('/api/v1/subscriptions', ['product_ids' => $product->id, 'name' => Str::random(5)])
|
->post('/api/v1/subscriptions', ['product_ids' => $product->id, 'name' => Str::random(5)])
|
||||||
->assertStatus(200)
|
->assertStatus(200)
|
||||||
->json();
|
->json();
|
||||||
|
|
||||||
$response2 = $this
|
// try {
|
||||||
|
$response2 = $this
|
||||||
->withHeaders(['X-API-SECRET' => config('ninja.api_secret'),'X-API-TOKEN' => $this->token])
|
->withHeaders(['X-API-SECRET' => config('ninja.api_secret'),'X-API-TOKEN' => $this->token])
|
||||||
->put('/api/v1/subscriptions/' . $response1['data']['id'], ['allow_cancellation' => true])
|
->put('/api/v1/subscriptions/' . $response1['data']['id'], ['allow_cancellation' => true])
|
||||||
->assertStatus(200)
|
->assertStatus(200)
|
||||||
->json();
|
->json();
|
||||||
|
// }catch(ValidationException $e) {
|
||||||
|
// nlog($e->validator->getMessageBag());
|
||||||
|
// }
|
||||||
|
|
||||||
$this->assertNotEquals($response1['data']['allow_cancellation'], $response2['data']['allow_cancellation']);
|
$this->assertNotEquals($response1['data']['allow_cancellation'], $response2['data']['allow_cancellation']);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user