@@ -26,7 +26,7 @@ |
||
26 | 26 | | |
27 | 27 | */ |
28 | 28 | |
29 | -expect()->extend('toBeOne', function () { |
|
29 | +expect()->extend('toBeOne', function() { |
|
30 | 30 | return $this->toBe(1); |
31 | 31 | }); |
32 | 32 |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -test('sum', function () { |
|
3 | +test('sum', function() { |
|
4 | 4 | $result = 1 + 2; |
5 | 5 | |
6 | 6 | expect($result)->toBe(3); |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | use Carbon\Carbon; |
4 | 4 | use Pratiksh\Nepalidate\Services\NepaliDate; |
5 | 5 | |
6 | -test('it can convert AD to BS date string', function () { |
|
6 | +test('it can convert AD to BS date string', function() { |
|
7 | 7 | $ad = Carbon::create(2024, 4, 13); // Known BS new year date |
8 | 8 | $date = NepaliDate::create($ad); |
9 | 9 | |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | expect($date->toBS())->toBe('2081-01-01'); |
12 | 12 | }); |
13 | 13 | |
14 | -test('it can return BS as an array', function () { |
|
14 | +test('it can return BS as an array', function() { |
|
15 | 15 | $ad = Carbon::create(2024, 4, 13); |
16 | 16 | $date = NepaliDate::fromAD($ad); |
17 | 17 | $bsArray = $date->toBSArray(); |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | expect((int) $bsArray['day'])->toBe(1); |
23 | 23 | }); |
24 | 24 | |
25 | -test('it can return formatted English BS date', function () { |
|
25 | +test('it can return formatted English BS date', function() { |
|
26 | 26 | $date = NepaliDate::create(Carbon::create(2024, 4, 13)); |
27 | 27 | expect($date->toFormattedEnglishBSDate())->toBe('1 Baisakh 2081, Saturday'); |
28 | 28 | }); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | // CORRECTED: Adjusted the reference date to fix the one-day offset |
69 | 69 | $initial_english_year = 1943; |
70 | 70 | $initial_english_month = 4; |
71 | - $initial_english_day = 13; // Changed from 14 to 13 |
|
71 | + $initial_english_day = 13; // Changed from 14 to 13 |
|
72 | 72 | $dayOfWeek = $this->dayOfWeek; |
73 | 73 | |
74 | 74 | // Set initial values |
@@ -89,8 +89,7 @@ discard block |
||
89 | 89 | |
90 | 90 | // Handle month transition |
91 | 91 | $days_in_month = $this->is_leap_year($english_year) ? |
92 | - $this->leapMonths[$english_month - 1] : |
|
93 | - $this->normalMonths[$english_month - 1]; |
|
92 | + $this->leapMonths[$english_month - 1] : $this->normalMonths[$english_month - 1]; |
|
94 | 93 | |
95 | 94 | if ($english_day > $days_in_month) { |
96 | 95 | $english_month++; |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | |
5 | 5 | use Pratiksh\Nepalidate\Tests\Unit\Doubles\DateConverterTestDouble; |
6 | 6 | |
7 | -test('date converter has correct bs month in english', function () { |
|
7 | +test('date converter has correct bs month in english', function() { |
|
8 | 8 | $converter = new DateConverterTestDouble(); |
9 | 9 | |
10 | 10 | expect($converter->getBSMonthInEnglish(1))->toBe('Baisakh') |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | ->and($converter->getBSMonthInEnglish(12))->toBe('Chaitra'); |
13 | 13 | }); |
14 | 14 | |
15 | -test('date converter has correct bs month in nepali', function () { |
|
15 | +test('date converter has correct bs month in nepali', function() { |
|
16 | 16 | $converter = new DateConverterTestDouble(); |
17 | 17 | |
18 | 18 | expect($converter->getBSMonthInNepali(1))->toBe('वैशाख') |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | ->and($converter->getBSMonthInNepali(12))->toBe('चैत'); |
21 | 21 | }); |
22 | 22 | |
23 | -test('date converter has correct ad month in nepali', function () { |
|
23 | +test('date converter has correct ad month in nepali', function() { |
|
24 | 24 | $converter = new DateConverterTestDouble(); |
25 | 25 | |
26 | 26 | expect($converter->getADMonthInNepali(1))->toBe('जनवरी') |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | ->and($converter->getADMonthInNepali(12))->toBe('दिसेम्बर'); |
29 | 29 | }); |
30 | 30 | |
31 | -test('date converter has correct day of week in nepali', function () { |
|
31 | +test('date converter has correct day of week in nepali', function() { |
|
32 | 32 | $converter = new DateConverterTestDouble(); |
33 | 33 | |
34 | 34 | expect($converter->getDayOfWeekInNepali(1))->toBe('आइतवार') |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | ->and($converter->getDayOfWeekInNepali(7))->toBe('शनिवार'); |
37 | 37 | }); |
38 | 38 | |
39 | -test('date converter has correct day of week in english', function () { |
|
39 | +test('date converter has correct day of week in english', function() { |
|
40 | 40 | $converter = new DateConverterTestDouble(); |
41 | 41 | |
42 | 42 | expect($converter->getDayOfWeekInEnglish(1))->toBe('Sunday') |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | ->and($converter->getDayOfWeekInEnglish(7))->toBe('Saturday'); |
45 | 45 | }); |
46 | 46 | |
47 | -test('date converter has correct numbers in nepali', function () { |
|
47 | +test('date converter has correct numbers in nepali', function() { |
|
48 | 48 | $converter = new DateConverterTestDouble(); |
49 | 49 | |
50 | 50 | expect($converter->getNumbersInNepali(0))->toBe('०') |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | ->and($converter->getNumbersInNepali(9))->toBe('९'); |
53 | 53 | }); |
54 | 54 | |
55 | -test('date converter formats nepali numbers correctly', function () { |
|
55 | +test('date converter formats nepali numbers correctly', function() { |
|
56 | 56 | $converter = new DateConverterTestDouble(); |
57 | 57 | |
58 | 58 | expect($converter->formattedNepaliNumber('123'))->toBe('१२३') |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | ->and($converter->formattedNepaliNumber('9876543210'))->toBe('९८७६५४३२१०'); |
61 | 61 | }); |
62 | 62 | |
63 | -test('date converter validates english date range correctly', function () { |
|
63 | +test('date converter validates english date range correctly', function() { |
|
64 | 64 | $converter = new DateConverterTestDouble(); |
65 | 65 | |
66 | 66 | // Valid dates should pass should return true |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | expect($converter->isInRangeEng(2000, 6, 32))->toBeFalse(); |
77 | 77 | }); |
78 | 78 | |
79 | -test('date converter validates nepali date range correctly', function () { |
|
79 | +test('date converter validates nepali date range correctly', function() { |
|
80 | 80 | $converter = new DateConverterTestDouble(); |
81 | 81 | |
82 | 82 | // Valid dates |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | expect($converter->isInRangeNep(2080, 6, 33))->toBeFalse(); |
93 | 93 | }); |
94 | 94 | |
95 | -test('date converter correctly identifies leap years', function () { |
|
95 | +test('date converter correctly identifies leap years', function() { |
|
96 | 96 | $converter = new DateConverterTestDouble(); |
97 | 97 | |
98 | 98 | // Leap years |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | expect($converter->isLeapYear(2022))->toBeFalse(); // Not divisible by 4 |
108 | 108 | }); |
109 | 109 | |
110 | -test('date converter calculates total english days correctly', function () { |
|
110 | +test('date converter calculates total english days correctly', function() { |
|
111 | 111 | $converter = new DateConverterTestDouble(); |
112 | 112 | |
113 | 113 | // Starting date used in calculations (1944-01-01 corresponds to day 1) |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | expect($converter->getTotalEnglishDays(2022, 1, 1))->toBe($daysFrom1944To2022 + 1); |
137 | 137 | }); |
138 | 138 | |
139 | -test('date converter calculates total nepali days correctly', function () { |
|
139 | +test('date converter calculates total nepali days correctly', function() { |
|
140 | 140 | $converter = new DateConverterTestDouble(); |
141 | 141 | $calendarData = $converter->getCalendarData(); |
142 | 142 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | expect($converter->getTotalNepaliDays($targetYear, $targetMonth, $targetDay))->toBe($totalDays); |
185 | 185 | }); |
186 | 186 | |
187 | -test('calendar data is correctly structured', function () { |
|
187 | +test('calendar data is correctly structured', function() { |
|
188 | 188 | $converter = new DateConverterTestDouble(); |
189 | 189 | $calendarData = $converter->getCalendarData(); |
190 | 190 |
@@ -3,35 +3,35 @@ |
||
3 | 3 | use Carbon\Carbon; |
4 | 4 | use Pratiksh\Nepalidate\Services\EnglishDate; |
5 | 5 | |
6 | -test('it converts BS date string to AD using create()', function () { |
|
6 | +test('it converts BS date string to AD using create()', function() { |
|
7 | 7 | $date = EnglishDate::create('2081-01-01'); |
8 | 8 | |
9 | 9 | expect($date)->toBeInstanceOf(EnglishDate::class); |
10 | 10 | expect($date->toCarbon()->format('Y-m-d'))->toBe('2024-04-13'); |
11 | 11 | }); |
12 | 12 | |
13 | -test('it converts BS date string to AD using fromBS()', function () { |
|
13 | +test('it converts BS date string to AD using fromBS()', function() { |
|
14 | 14 | $date = EnglishDate::fromBS('2081/01/01'); |
15 | 15 | |
16 | 16 | expect($date)->toBeInstanceOf(EnglishDate::class); |
17 | 17 | expect($date->toCarbon()->format('Y-m-d'))->toBe('2024-04-13'); |
18 | 18 | }); |
19 | 19 | |
20 | -test('it throws exception for invalid date format in create()', function () { |
|
20 | +test('it throws exception for invalid date format in create()', function() { |
|
21 | 21 | $this->expectException(Exception::class); |
22 | 22 | $this->expectExceptionMessage('Invalid date format'); |
23 | 23 | |
24 | 24 | EnglishDate::create('2081-01'); |
25 | 25 | }); |
26 | 26 | |
27 | -test('it throws exception for invalid date format in fromBS()', function () { |
|
27 | +test('it throws exception for invalid date format in fromBS()', function() { |
|
28 | 28 | $this->expectException(Exception::class); |
29 | 29 | $this->expectExceptionMessage('Invalid date format'); |
30 | 30 | |
31 | 31 | EnglishDate::fromBS('2081/01'); |
32 | 32 | }); |
33 | 33 | |
34 | -test('it correctly sets AD Carbon date after conversion', function () { |
|
34 | +test('it correctly sets AD Carbon date after conversion', function() { |
|
35 | 35 | $bs = '2081-01-01'; |
36 | 36 | $englishDate = EnglishDate::create($bs); |
37 | 37 | $carbon = $englishDate->toCarbon(); |
@@ -4,55 +4,55 @@ |
||
4 | 4 | use Pratiksh\Nepalidate\Services\EnglishDate; |
5 | 5 | use Pratiksh\Nepalidate\Services\NepaliDate; |
6 | 6 | |
7 | -if (! function_exists('toFormattedBSDate')) { |
|
7 | +if (!function_exists('toFormattedBSDate')) { |
|
8 | 8 | function toFormattedBSDate(Carbon $date) |
9 | 9 | { |
10 | 10 | return NepaliDate::create($date)->toFormattedEnglishBSDate(); |
11 | 11 | } |
12 | 12 | } |
13 | 13 | |
14 | -if (! function_exists('toFormattedNepaliDate')) { |
|
14 | +if (!function_exists('toFormattedNepaliDate')) { |
|
15 | 15 | function toFormattedNepaliDate(Carbon $date) |
16 | 16 | { |
17 | 17 | return NepaliDate::create($date)->toFormattedNepaliBSDate(); |
18 | 18 | } |
19 | 19 | } |
20 | 20 | |
21 | -if (! function_exists('toAD')) { |
|
21 | +if (!function_exists('toAD')) { |
|
22 | 22 | function toAD(string $date) |
23 | 23 | { |
24 | 24 | return EnglishDate::create($date)->toCarbon(); |
25 | 25 | } |
26 | 26 | } |
27 | 27 | |
28 | -if (! function_exists('toBS')) { |
|
28 | +if (!function_exists('toBS')) { |
|
29 | 29 | function toBS(Carbon $date) |
30 | 30 | { |
31 | 31 | return NepaliDate::create($date)->toBS(); |
32 | 32 | } |
33 | 33 | } |
34 | 34 | |
35 | -if (! function_exists('toFormattedEnglishBSDate')) { |
|
35 | +if (!function_exists('toFormattedEnglishBSDate')) { |
|
36 | 36 | function toFormattedEnglishBSDate(Carbon $date) |
37 | 37 | { |
38 | 38 | return NepaliDate::create($date)->toFormattedEnglishBSDate(); |
39 | 39 | } |
40 | 40 | } |
41 | 41 | |
42 | -if (! function_exists('toFormattedNepaliBSDate')) { |
|
42 | +if (!function_exists('toFormattedNepaliBSDate')) { |
|
43 | 43 | function toFormattedNepaliBSDate(Carbon $date) |
44 | 44 | { |
45 | 45 | return NepaliDate::create($date)->toFormattedNepaliBSDate(); |
46 | 46 | } |
47 | 47 | } |
48 | 48 | |
49 | -if (! function_exists('toDetailBS')) { |
|
49 | +if (!function_exists('toDetailBS')) { |
|
50 | 50 | function toDetailBS(Carbon $date) |
51 | 51 | { |
52 | 52 | $bs_array = NepaliDate::create($date)->toBSArray(); |
53 | 53 | $to_detail_bs = null; |
54 | 54 | |
55 | - if (! empty($bs_array) && is_array($bs_array)) { |
|
55 | + if (!empty($bs_array) && is_array($bs_array)) { |
|
56 | 56 | $json = json_encode($bs_array); |
57 | 57 | if ($json !== false) { |
58 | 58 | $to_detail_bs = json_decode($json); |