generated from spatie/package-skeleton-laravel
-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix when creating array types from values (#707)
* fixed type creaction from value * Fix styling --------- Co-authored-by: romalytvynenko <[email protected]>
- Loading branch information
1 parent
ef9c972
commit de05558
Showing
2 changed files
with
46 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,30 @@ | ||
<?php | ||
|
||
namespace Dedoc\Scramble\Tests\Support\Type; | ||
|
||
use Dedoc\Scramble\Support\Type\TypeHelper; | ||
|
||
test('create type from value', function ($value, string $expectedType) { | ||
$type = TypeHelper::createTypeFromValue($value); | ||
|
||
expect($type->toString())->toBe($expectedType); | ||
})->with([ | ||
[1, 'int(1)'], | ||
['foo', 'string(foo)'], | ||
[[1, 2, 3], 'list{int(1), int(2), int(3)}'], | ||
]); | ||
|
||
test('create type from enum value', function () { | ||
$type = TypeHelper::createTypeFromValue([ | ||
Foo_TypeHelperTest::Foo, | ||
Foo_TypeHelperTest::Bar, | ||
]); | ||
|
||
expect($type->toString())->toBe('list{Dedoc\Scramble\Tests\Support\Type\Foo_TypeHelperTest::Foo, Dedoc\Scramble\Tests\Support\Type\Foo_TypeHelperTest::Bar}'); | ||
}); | ||
|
||
enum Foo_TypeHelperTest: string | ||
{ | ||
case Foo = 'f'; | ||
case Bar = 'b'; | ||
} |