pratiksh404 /
nepalidate
| 1 | <?php |
||||
| 2 | |||||
| 3 | use Carbon\Carbon; |
||||
| 4 | use Pratiksh\Nepalidate\Services\NepaliDate; |
||||
| 5 | |||||
| 6 | test('it can convert AD to BS date string', function () { |
||||
| 7 | $ad = Carbon::create(2024, 4, 13); // Known BS new year date |
||||
| 8 | $date = NepaliDate::create($ad); |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 9 | |||||
| 10 | expect($date)->toBeInstanceOf(NepaliDate::class); |
||||
| 11 | expect($date->toBS())->toBe('2081-01-01'); |
||||
| 12 | }); |
||||
| 13 | |||||
| 14 | test('it can return BS as an array', function () { |
||||
| 15 | $ad = Carbon::create(2024, 4, 13); |
||||
| 16 | $date = NepaliDate::fromAD($ad); |
||||
|
0 ignored issues
–
show
It seems like
$ad can also be of type false; however, parameter $date of Pratiksh\Nepalidate\Services\NepaliDate::fromAD() does only seem to accept Carbon\Carbon, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 17 | $bsArray = $date->toBSArray(); |
||||
| 18 | |||||
| 19 | expect($bsArray)->toHaveKeys(['year', 'month', 'day', 'dayOfWeek']); |
||||
| 20 | expect($bsArray['year'])->toBe(2081); |
||||
| 21 | expect((int) $bsArray['month'])->toBe(1); |
||||
| 22 | expect((int) $bsArray['day'])->toBe(1); |
||||
| 23 | }); |
||||
| 24 | |||||
| 25 | test('it can return formatted English BS date', function () { |
||||
| 26 | $date = NepaliDate::create(Carbon::create(2024, 4, 13)); |
||||
|
0 ignored issues
–
show
It seems like
Carbon\Carbon::create(2024, 4, 13) can also be of type false; however, parameter $date of Pratiksh\Nepalidate\Services\NepaliDate::create() does only seem to accept Carbon\Carbon, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 27 | expect($date->toFormattedEnglishBSDate())->toBe('1 Baisakh 2081, Saturday'); |
||||
| 28 | }); |
||||
| 29 |