From 6d1d950c4ea788498ddd30fdcdb0865b3ee62a08 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 6 Apr 2021 13:05:40 +1000 Subject: [PATCH] Ninja Feature Tests --- app/Models/Account.php | 15 ++++++--- tests/Feature/Ninja/PlanTest.php | 55 ++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 5 deletions(-) create mode 100644 tests/Feature/Ninja/PlanTest.php diff --git a/app/Models/Account.php b/app/Models/Account.php index 737abe457853..f9afffc06537 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -53,6 +53,7 @@ class Account extends BaseModel 'deleted_at', 'promo_expires', 'discount_expires', + 'trial_started', ]; const PLAN_FREE = 'free'; @@ -239,13 +240,17 @@ class Account extends BaseModel $trial_active = false; if ($trial_plan && $include_trial) { - $trial_started = DateTime::createFromFormat('Y-m-d', $this->trial_started); - $trial_expires = clone $trial_started; - $trial_expires->modify('+2 weeks'); + $trial_started = $this->trial_started; + $trial_expires = $this->trial_started->addSeconds($this->trial_duration); + // $trial_expires->modify('+2 weeks'); - if ($trial_expires >= date_create()) { + if($trial_expires->lessThan(now())){ $trial_active = true; - } + } + + // if ($trial_expires >= date_create()) { + // $trial_active = true; + // } } $plan_active = false; diff --git a/tests/Feature/Ninja/PlanTest.php b/tests/Feature/Ninja/PlanTest.php new file mode 100644 index 000000000000..1ce48c321a4e --- /dev/null +++ b/tests/Feature/Ninja/PlanTest.php @@ -0,0 +1,55 @@ +makeTestData(); + + Session::start(); + + $this->faker = \Faker\Factory::create(); + + Model::reguard(); + } + + public function testTrialPlans() + { + + $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)); + } + + +}