mardi 30 mai 2017

Carbon tests failing

So i have an Laravel Application in which we check if time has passed by comparing current time in user timezone against time expired datetime stored in database of course in same timezone. So this is my code.

Test code

$staff = Staff::find(1);
$carbon = Carbon::now($staff->user->timezone);
$carbon->subHour(1);
$staff->status_exp = $carbon->toDateTimeString();
$processor = new Processor($staff);
$status = $processor->isExpired();
$this->assertTrue($status);

Application Code. Class has property name staff which is used below.

 public function isExpired()
    {
        $now = Carbon::now($this->staff->user->timezone);
        if($now->greaterThan(Carbon::parse($this->staff->status_exp)))
        {
            return true;
        }
        return false;
    }



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2qxspj5
via IFTTT

Aucun commentaire:

Enregistrer un commentaire