From c2990a21d07093b54701f87d66b3a58a396c5cd2 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 14 Apr 2021 16:48:32 +1000 Subject: [PATCH] Fixes for tests --- app/Console/Commands/CreateSingleAccount.php | 4 ++-- .../SubscriptionPlanSwitchController.php | 1 - app/Http/Livewire/SubscriptionPlanSwitch.php | 1 + .../Subscription/UpdateSubscriptionRequest.php | 2 +- tests/Feature/SubscriptionApiTest.php | 12 +++++++++--- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/Console/Commands/CreateSingleAccount.php b/app/Console/Commands/CreateSingleAccount.php index 2a4dab445893..ab850b11aa1d 100644 --- a/app/Console/Commands/CreateSingleAccount.php +++ b/app/Console/Commands/CreateSingleAccount.php @@ -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, ]); diff --git a/app/Http/Controllers/ClientPortal/SubscriptionPlanSwitchController.php b/app/Http/Controllers/ClientPortal/SubscriptionPlanSwitchController.php index 7adf172baa1a..a6cb764d0516 100644 --- a/app/Http/Controllers/ClientPortal/SubscriptionPlanSwitchController.php +++ b/app/Http/Controllers/ClientPortal/SubscriptionPlanSwitchController.php @@ -35,7 +35,6 @@ class SubscriptionPlanSwitchController extends Controller $amount = $recurring_invoice->subscription ->service() ->calculateUpgradePrice($recurring_invoice, $target); - /** * * Null value here is a proxy for diff --git a/app/Http/Livewire/SubscriptionPlanSwitch.php b/app/Http/Livewire/SubscriptionPlanSwitch.php index 078096ab7f61..ba77c857f6a4 100644 --- a/app/Http/Livewire/SubscriptionPlanSwitch.php +++ b/app/Http/Livewire/SubscriptionPlanSwitch.php @@ -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([ diff --git a/app/Http/Requests/Subscription/UpdateSubscriptionRequest.php b/app/Http/Requests/Subscription/UpdateSubscriptionRequest.php index fdf72b188633..99d33048a5f0 100644 --- a/app/Http/Requests/Subscription/UpdateSubscriptionRequest.php +++ b/app/Http/Requests/Subscription/UpdateSubscriptionRequest.php @@ -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); diff --git a/tests/Feature/SubscriptionApiTest.php b/tests/Feature/SubscriptionApiTest.php index 2ef470bbe649..a81bd8c21099 100644 --- a/tests/Feature/SubscriptionApiTest.php +++ b/tests/Feature/SubscriptionApiTest.php @@ -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']); }