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