Passed
Push — main ( d1171c...271724 )
by PRATIK
03:52 queued 11s
created

nepaliDateCheckTest::check_toFormattedBSDate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 4
c 1
b 0
f 1
dl 0
loc 6
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Pratiksh\Nepalidate\Tests\Feature;
4
5
use Carbon\Carbon;
6
use Orchestra\Testbench\TestCase;
7
use Pratiksh\Nepalidate\Services\NepaliDate as PratikshNepaliDate;
8
9
class nepaliDateCheckTest extends TestCase
10
{
11
    /** @test */
12
    public function check_toBS()
13
    {
14
        $nepalidate = new PratikshNepaliDate();
15
        $date = Carbon::create('2021-08-05');
0 ignored issues
show
Bug introduced by
'2021-08-05' of type string is incompatible with the type integer|null expected by parameter $year of Carbon\Carbon::create(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

15
        $date = Carbon::create(/** @scrutinizer ignore-type */ '2021-08-05');
Loading history...
16
        $toBSDate = $nepalidate->create($date)->toBS();
0 ignored issues
show
Bug introduced by
It seems like $date 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 ignore-type  annotation

16
        $toBSDate = $nepalidate->create(/** @scrutinizer ignore-type */ $date)->toBS();
Loading history...
17
        $this->assertEquals('2078-4-21', $toBSDate);
18
    }
19
    /** @test */
20
    public function check_toFormattedBSDate()
21
    {
22
        $nepalidate = new PratikshNepaliDate();
23
        $date = Carbon::create('2021-08-05');
0 ignored issues
show
Bug introduced by
'2021-08-05' of type string is incompatible with the type integer|null expected by parameter $year of Carbon\Carbon::create(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

23
        $date = Carbon::create(/** @scrutinizer ignore-type */ '2021-08-05');
Loading history...
24
        $toBSDate = $nepalidate->create($date)->toFormattedBSDate();
0 ignored issues
show
Bug introduced by
It seems like $date 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 ignore-type  annotation

24
        $toBSDate = $nepalidate->create(/** @scrutinizer ignore-type */ $date)->toFormattedBSDate();
Loading history...
25
        $this->assertEquals('21 Shrawan 2078, Thurday', $toBSDate);
26
    }
27
    /** @test */
28
    public function check_toFormattedNepaliDate()
29
    {
30
        $nepalidate = new PratikshNepaliDate();
31
        $date = Carbon::create('2021-08-05');
0 ignored issues
show
Bug introduced by
'2021-08-05' of type string is incompatible with the type integer|null expected by parameter $year of Carbon\Carbon::create(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

31
        $date = Carbon::create(/** @scrutinizer ignore-type */ '2021-08-05');
Loading history...
32
        $toBSDate = $nepalidate->create($date)->toFormattedNepaliDate();
0 ignored issues
show
Bug introduced by
It seems like $date 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 ignore-type  annotation

32
        $toBSDate = $nepalidate->create(/** @scrutinizer ignore-type */ $date)->toFormattedNepaliDate();
Loading history...
33
        $this->assertEquals('२१ साउन २०७८, बिहिवार', $toBSDate);
34
    }
35
}
36