-
-
Notifications
You must be signed in to change notification settings - Fork 360
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for strict types expectation
Introduced new test cases to ensure strict type declaration handling. Files with and without strict types are tested, including scenarios with comments preceding the declaration. Updated the regex in `Expectation.php` to accommodate comments and whitespaces before the `declare(strict_types=1)` statement.
- Loading branch information
Showing
5 changed files
with
49 additions
and
1 deletion.
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,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Pest\Arch\Exceptions\ArchExpectationFailedException; | ||
use Tests\Fixtures\Arch\ToUseStrictTypes\HasNoStrictType; | ||
use Tests\Fixtures\Arch\ToUseStrictTypes\HasStrictType; | ||
use Tests\Fixtures\Arch\ToUseStrictTypes\HasStrictTypeWithCommentsAbove; | ||
|
||
test('pass', function () { | ||
expect(HasStrictType::class)->toUseStrictTypes() | ||
->and(HasStrictTypeWithCommentsAbove::class)->toUseStrictTypes(); | ||
}); | ||
|
||
test('failures', function () { | ||
expect(HasNoStrictType::class)->toUseStrictTypes(); | ||
})->throws(ArchExpectationFailedException::class); | ||
|
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,8 @@ | ||
<?php | ||
|
||
namespace Tests\Fixtures\Arch\ToUseStrictTypes; | ||
|
||
class HasNoStrictType | ||
{ | ||
|
||
} |
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,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Fixtures\Arch\ToUseStrictTypes; | ||
|
||
class HasStrictType | ||
{ | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
tests/Fixtures/Arch/ToUseStrictTypes/HasStrictTypeWithCommentsAbove.php
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,12 @@ | ||
<?php /** @noinspection PhpUnused */ | ||
|
||
// some other comment | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Fixtures\Arch\ToUseStrictTypes; | ||
|
||
class HasStrictTypeWithCommentsAbove | ||
{ | ||
|
||
} |