Skip to content

Commit

Permalink
Carbon: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
esyede committed Dec 2, 2023
1 parent 4428c46 commit f16f877
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion system/carbon.php
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ public function diffForHumans(Carbon $other = null, $absolute = false)
$delta = floor($delta / $value);
}

$delta = ($delta <= 0) ? 1 : $delta;
$delta = ($delta < 1) ? 1 : $delta;
$str = $delta . ' ' . Lang::line('date.' . $unit . (($delta <= 1) ? '' : 's'))->get();

if ($absolute) {
Expand Down
6 changes: 3 additions & 3 deletions tests/cases/carbon.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ public function testDayOfWeek()
*
* @group system
*/
public function testDiffInYearsPositive()
public function testDiff()
{
$d = Carbon::createFromDate(2000, 1, 1);
$this->assertSame(1, $d->diffInYears($d->copy()->addYear()));
Expand Down Expand Up @@ -570,7 +570,7 @@ public function testDiffInYearsPositive()
$this->assertSame('2 months from now', $d->diffForHumans());
Carbon::setTestNow();
$d = Carbon::now()->addMonths(11);
$this->assertSame('11 months from now', $d->diffForHumans());
$this->assertSame('1 year from now', $d->diffForHumans());
$d = Carbon::now()->addYear();
$this->assertSame('1 year from now', $d->diffForHumans());
$d = Carbon::now()->addYears(2);
Expand Down Expand Up @@ -618,7 +618,7 @@ public function testDiffInYearsPositive()
$this->assertSame('2 months before', Carbon::now()->diffForHumans($d));
Carbon::setTestNow();
$d = Carbon::now()->addMonths(11);
$this->assertSame('11 months before', Carbon::now()->diffForHumans($d));
$this->assertSame('1 year before', Carbon::now()->diffForHumans($d));
$d = Carbon::now()->addYear();
$this->assertSame('1 year before', Carbon::now()->diffForHumans($d));
$d = Carbon::now()->addYears(2);
Expand Down

0 comments on commit f16f877

Please sign in to comment.