generated from pestphp/pest-plugin-template
-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: adds more tests on native functions
- Loading branch information
1 parent
e3f51ae
commit 8662a78
Showing
3 changed files
with
61 additions
and
2 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,58 @@ | ||
<?php | ||
|
||
use PHPUnit\Framework\ExpectationFailedException; | ||
|
||
test('native functions', function () { | ||
expect('Tests')->toUse('sleep'); | ||
expect('Tests')->not->toUse('die'); | ||
|
||
expect('die')->not->toBeUsed(); | ||
expect('die')->toBeUsedInNothing(); | ||
|
||
expect('sleep')->toBeUsedIn('Tests') | ||
->and('die')->not->toBeUsedIn('Tests'); | ||
|
||
expect('die')->toOnlyBeUsedIn('Tests'); | ||
}); | ||
|
||
test('failure 1', function () { | ||
expect('Tests')->toUse('die'); | ||
})->throws( | ||
ExpectationFailedException::class, | ||
"Expecting 'Tests' to use 'die'." | ||
); | ||
|
||
test('failure 2', function () { | ||
expect('Tests')->not->toUse('sleep'); | ||
})->throws( | ||
ExpectationFailedException::class, | ||
"Expecting 'Tests' not to use 'sleep'." | ||
); | ||
|
||
test('failure 3', function () { | ||
expect('sleep')->not->toBeUsed(); | ||
})->throws( | ||
\Pest\Arch\Exceptions\ArchExpectationFailedException::class, | ||
'Expecting \'sleep\' not to be used on \'Tests\Fixtures\Misc\HasSleepFunction\'.' | ||
); | ||
|
||
test('failure 4', function () { | ||
expect('sleep')->toBeUsedInNothing(); | ||
})->throws( | ||
\Pest\Arch\Exceptions\ArchExpectationFailedException::class, | ||
'Expecting \'sleep\' not to be used on \'Tests\Fixtures\Misc\HasSleepFunction\'.' | ||
); | ||
|
||
test('failure 5', function () { | ||
expect('die')->toBeUsedIn('Tests\Fixtures\Misc\HasSleepFunction'); | ||
})->throws( | ||
ExpectationFailedException::class, | ||
'Expecting \'Tests\Fixtures\Misc\HasSleepFunction\' to use \'die\'.', | ||
); | ||
|
||
test('failure 6', function () { | ||
expect('sleep')->not->toBeUsedIn('Tests\Fixtures\Misc\HasSleepFunction'); | ||
})->throws( | ||
ExpectationFailedException::class, | ||
'Expecting \'sleep\' not to be used in \'Tests\Fixtures\Misc\HasSleepFunction\'.', | ||
); |
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