Testing Permissions

This commit is contained in:
David Bomba 2021-04-06 14:02:27 +10:00
parent 6d1d950c4e
commit 355d0ae7b5
2 changed files with 16 additions and 2 deletions

View File

@ -239,12 +239,13 @@ class Account extends BaseModel
} }
$trial_active = false; $trial_active = false;
if ($trial_plan && $include_trial) { if ($trial_plan && $include_trial) {
$trial_started = $this->trial_started; $trial_started = $this->trial_started;
$trial_expires = $this->trial_started->addSeconds($this->trial_duration); $trial_expires = $this->trial_started->addSeconds($this->trial_duration);
// $trial_expires->modify('+2 weeks'); // $trial_expires->modify('+2 weeks');
if($trial_expires->lessThan(now())){ if($trial_expires->greaterThan(now())){
$trial_active = true; $trial_active = true;
} }
@ -270,6 +271,7 @@ class Account extends BaseModel
return null; return null;
} }
// Should we show plan details or trial details? // Should we show plan details or trial details?
if (($plan && ! $trial_plan) || ! $include_trial) { if (($plan && ! $trial_plan) || ! $include_trial) {
$use_plan = true; $use_plan = true;

View File

@ -42,13 +42,25 @@ class PlanTest extends TestCase
public function testTrialPlans() public function testTrialPlans()
{ {
config(['ninja.production' => true]);
$this->assertFalse($this->account->hasFeature(Account::FEATURE_USERS));
$this->account->trial_plan = 'enterprise'; $this->account->trial_plan = 'enterprise';
$this->account->trial_started = now(); $this->account->trial_started = now();
$this->account->trial_duration = 60*60*24*31; $this->account->trial_duration = 60*60*24*31;
$this->account->save(); $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));
} }