diff --git a/.gitignore b/.gitignore index 56f0897..73341db 100755 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ composer.lock /.vscode .phpunit.result.cache dump.rdb +.phpunit.cache/test-results diff --git a/composer.json b/composer.json index 9a038dc..569e71a 100755 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ "jaybizzle/crawler-detect": "^1.2", "spatie/laravel-referer": "^1.6", "torann/geoip": "^1.0|^3.0", - "nesbot/carbon": "^2.0" + "nesbot/carbon": "^2.0|^3.0" }, "require-dev": { "doctrine/dbal": "^2.6|^3.0", diff --git a/src/Traits/Periods.php b/src/Traits/Periods.php index 5acf0f4..306f84b 100755 --- a/src/Traits/Periods.php +++ b/src/Traits/Periods.php @@ -39,7 +39,7 @@ protected function newExpiration($period) throw new Exception("Wrong period: `{$period}`! please update config/visits.php file."); } - return $periodCarbon->diffInSeconds() + 1; + return intval(abs($periodCarbon->diffInSeconds())) + 1; } /** diff --git a/tests/Feature/PeriodsTestCase.php b/tests/Feature/PeriodsTestCase.php index 90316d8..0dc5774 100755 --- a/tests/Feature/PeriodsTestCase.php +++ b/tests/Feature/PeriodsTestCase.php @@ -92,10 +92,10 @@ public function day_test() //time until redis delete periods - $this->assertEquals(1, now()->addSeconds(visits($post)->period('day')->timeLeft())->diffInDays($time)); + $this->assertEquals(1, intval(abs(now()->addSeconds(visits($post)->period('day')->timeLeft())->diffInDays($time)))); //time until redis delete periods - $this->assertEquals(1, now()->addSeconds(visits('Awssat\Visits\Tests\Post')->period('day')->timeLeft())->diffInDays($time)); + $this->assertEquals(1, intval(abs(now()->addSeconds(visits('Awssat\Visits\Tests\Post')->period('day')->timeLeft())->diffInDays($time)))); } /** @test */