From 355d0ae7b545617689e639559c548e015caba9a3 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 6 Apr 2021 14:02:27 +1000 Subject: [PATCH] Testing Permissions --- app/Models/Account.php | 4 +++- tests/Feature/Ninja/PlanTest.php | 14 +++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/Models/Account.php b/app/Models/Account.php index f9afffc06537..71cca3cfc168 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -239,12 +239,13 @@ class Account extends BaseModel } $trial_active = false; + if ($trial_plan && $include_trial) { $trial_started = $this->trial_started; $trial_expires = $this->trial_started->addSeconds($this->trial_duration); // $trial_expires->modify('+2 weeks'); - if($trial_expires->lessThan(now())){ + if($trial_expires->greaterThan(now())){ $trial_active = true; } @@ -270,6 +271,7 @@ class Account extends BaseModel return null; } + // Should we show plan details or trial details? if (($plan && ! $trial_plan) || ! $include_trial) { $use_plan = true; diff --git a/tests/Feature/Ninja/PlanTest.php b/tests/Feature/Ninja/PlanTest.php index 1ce48c321a4e..4ec042b83ecf 100644 --- a/tests/Feature/Ninja/PlanTest.php +++ b/tests/Feature/Ninja/PlanTest.php @@ -42,13 +42,25 @@ class PlanTest extends TestCase public function testTrialPlans() { + config(['ninja.production' => true]); + + $this->assertFalse($this->account->hasFeature(Account::FEATURE_USERS)); $this->account->trial_plan = 'enterprise'; $this->account->trial_started = now(); $this->account->trial_duration = 60*60*24*31; $this->account->save(); - $this->assertTrue($this->account->hasFeature(Account::FEATURE_USERS)); + nlog($this->account->getPlanDetails()); + + $this->assertFalse($this->account->hasFeature(Account::FEATURE_USERS)); + + $this->account->trial_plan = 'pro'; + $this->account->save(); + + $this->assertFalse($this->account->hasFeature(Account::FEATURE_USERS)); + $this->assertTrue($this->account->hasFeature(Account::FEATURE_CUSTOM_URL)); + }