Ninja Feature Tests

This commit is contained in:
David Bomba 2021-04-06 13:05:40 +10:00
parent 2e72df7f09
commit 6d1d950c4e
2 changed files with 65 additions and 5 deletions

View File

@ -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;

View File

@ -0,0 +1,55 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Tests\Feature\Ninja;
use App\Models\Account;
use App\Utils\Traits\MakesHash;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\Session;
use Tests\MockAccountData;
use Tests\TestCase;
/**
* @test
*/
class PlanTest extends TestCase
{
use MakesHash;
use DatabaseTransactions;
use MockAccountData;
public function setUp() :void
{
parent::setUp();
$this->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));
}
}