Skip to content

Commit

Permalink
[feat] add test for 'ago' method
Browse files Browse the repository at this point in the history
  • Loading branch information
alissn committed Jul 31, 2024
1 parent 1b56dc8 commit e0a8ea4
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/JalalianTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,4 +426,36 @@ public function testdiff()
//greater year, greater month, greater day
$this->assertEquals($jDate->diff(new Jalalian(1405, 9, 30)), [4, 3, 4]);
}

public function testNegativeAgo()
{
$jDate = Jalalian::now();

$postfix = 'پیش';

$seconds = rand(1, 59);
$this->assertEquals($jDate->subSeconds($seconds)->ago(), sprintf('%s %s %s', $seconds, 'ثانیه', $postfix));

$minutes = rand(1, 59);
$this->assertEquals($jDate->subMinutes($minutes)->ago(), sprintf('%s %s %s', $minutes, 'دقیقه', $postfix));

$hour = rand(1, 23);
$this->assertEquals($jDate->subHours($hour)->ago(), sprintf('%s %s %s', $hour, 'ساعت', $postfix));
}

public function testPositiveAgo()
{
$jDate = Jalalian::now();

$postfix = 'دیگر';

$seconds = rand(1, 59);
$this->assertEquals($jDate->addSeconds($seconds)->ago(), sprintf('%s %s %s', $seconds, 'ثانیه', $postfix));

$minutes = rand(1, 59);
$this->assertEquals($jDate->addMinutes($minutes)->ago(), sprintf('%s %s %s', $minutes, 'دقیقه', $postfix));

$hour = rand(1, 23);
$this->assertEquals($jDate->addHours($hour)->ago(), sprintf('%s %s %s', $hour, 'ساعت', $postfix));
}
}

0 comments on commit e0a8ea4

Please sign in to comment.