-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
71 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php declare(strict_types=1); | ||
|
||
use Bugo\Optimus\Enums\Frequency; | ||
|
||
it('returns Hourly for timestamps within the last 24 hours', function () { | ||
$timestamp = time() - (23 * 3600); // 23 hours ago | ||
expect(Frequency::fromTimestamp($timestamp))->toBe(Frequency::Hourly); | ||
}); | ||
|
||
it('returns Daily for timestamps within the last 7 days', function () { | ||
$timestamp = time() - (6 * 86400); // 6 days ago | ||
expect(Frequency::fromTimestamp($timestamp))->toBe(Frequency::Daily); | ||
}); | ||
|
||
it('returns Weekly for timestamps within the last month', function () { | ||
$timestamp = time() - (14 * 86400); // 2 weeks ago | ||
expect(Frequency::fromTimestamp($timestamp))->toBe(Frequency::Weekly); | ||
}); | ||
|
||
it('returns Monthly for timestamps within the last year', function () { | ||
$timestamp = time() - (30 * 86400 * 6); // 6 months ago | ||
expect(Frequency::fromTimestamp($timestamp))->toBe(Frequency::Monthly); | ||
}); | ||
|
||
it('returns Yearly for timestamps older than a year', function () { | ||
$timestamp = time() - (400 * 86400); // More than a year ago | ||
expect(Frequency::fromTimestamp($timestamp))->toBe(Frequency::Yearly); | ||
}); | ||
|
||
it('handles exact boundary cases correctly', function () { | ||
expect(Frequency::fromTimestamp(time() - 86400))->toBe(Frequency::Daily); // Exactly 24 hours | ||
expect(Frequency::fromTimestamp(time() - 604800))->toBe(Frequency::Weekly); // Exactly 7 days | ||
expect(Frequency::fromTimestamp(time() - 2628000))->toBe(Frequency::Monthly); // Exactly 1 month | ||
expect(Frequency::fromTimestamp(time() - 31536000))->toBe(Frequency::Yearly); // Exactly 1 year | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php declare(strict_types=1); | ||
|
||
use Bugo\Optimus\Enums\Priority; | ||
|
||
it('returns Prime for timestamps within 30 days', function () { | ||
$timestamp = time() - (29 * 86400); | ||
expect(Priority::fromTimestamp($timestamp))->toBe(Priority::Prime); | ||
}); | ||
|
||
it('returns Elevated for timestamps within 31-60 days', function () { | ||
$timestamp = time() - (45 * 86400); | ||
expect(Priority::fromTimestamp($timestamp))->toBe(Priority::Elevated); | ||
}); | ||
|
||
it('returns Base for timestamps within 61-90 days', function () { | ||
$timestamp = time() - (75 * 86400); | ||
expect(Priority::fromTimestamp($timestamp))->toBe(Priority::Base); | ||
}); | ||
|
||
it('returns Minimal for timestamps older than 90 days', function () { | ||
$timestamp = time() - (120 * 86400); | ||
expect(Priority::fromTimestamp($timestamp))->toBe(Priority::Minimal); | ||
}); | ||
|
||
it('handles exact boundary cases correctly', function () { | ||
expect(Priority::fromTimestamp(time() - (30 * 86400)))->toBe(Priority::Prime); | ||
expect(Priority::fromTimestamp(time() - (60 * 86400)))->toBe(Priority::Elevated); | ||
expect(Priority::fromTimestamp(time() - (90 * 86400)))->toBe(Priority::Base); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters