-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
blank and filled now support stringable (#617)
* blank and filled now support stringable * chore: Add blank and filled functions for stringable support * feat: Add tests for blank and filled functions with stringable support * chore: Update Functions.php to support Stringable interface --------- Co-authored-by: Deeka Wong <[email protected]>
- Loading branch information
1 parent
efc00e2
commit 853ceec
Showing
2 changed files
with
39 additions
and
0 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 |
---|---|---|
|
@@ -9,9 +9,12 @@ | |
* @contact [email protected] | ||
*/ | ||
use Hyperf\Contract\ApplicationInterface; | ||
use Hyperf\Stringable\Stringable; | ||
|
||
use function FriendsOfHyperf\Helpers\blank; | ||
use function FriendsOfHyperf\Helpers\class_namespace; | ||
use function FriendsOfHyperf\Helpers\Command\call; | ||
use function FriendsOfHyperf\Helpers\filled; | ||
use function FriendsOfHyperf\Helpers\object_get; | ||
use function FriendsOfHyperf\Helpers\preg_replace_array; | ||
|
||
|
@@ -61,3 +64,35 @@ | |
|
||
expect(call('foo:bar', ['argument' => 'value']))->toBe(0); | ||
}); | ||
|
||
test('test filled', function ($expect, $value) { | ||
expect(filled($value))->toBe($expect); | ||
})->with([ | ||
[false, null], | ||
[false, ''], | ||
[false, ' '], | ||
[false, new Stringable('')], | ||
[false, new Stringable(' ')], | ||
[true, 10], | ||
[true, true], | ||
[true, false], | ||
[true, 0], | ||
[true, 0.0], | ||
[true, new Stringable(' FooBar ')], | ||
]); | ||
|
||
test('test blank', function ($expect, $value) { | ||
expect(blank($value))->toBe($expect); | ||
})->with([ | ||
[true, null], | ||
[true, ''], | ||
[true, ' '], | ||
[true, new Stringable('')], | ||
[true, new Stringable(' ')], | ||
[false, 10], | ||
[false, true], | ||
[false, false], | ||
[false, 0], | ||
[false, 0.0], | ||
[false, new Stringable(' FooBar ')], | ||
]); |