-
Notifications
You must be signed in to change notification settings - Fork 4
add decodertest #139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
add decodertest #139
Changes from 2 commits
e936f5f
c974833
3fc6de8
4cc5b40
b69e530
9c1024f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Tests\Unit; | ||
|
|
||
| use PHPUnit\Framework\TestCase; | ||
| use Facile\PhpCodec\Internal\Primitives\StringDecoder; | ||
| use Facile\PhpCodec\Validation\Context; | ||
| use Facile\PhpCodec\Validation\ValidationSuccess; | ||
|
|
||
| final class StringDecoderTest extends TestCase | ||
| { | ||
| public function testValidString(): void | ||
| { | ||
| $decoder = new StringDecoder(); | ||
| $context = new Context($decoder); //cosa controllare | ||
|
|
||
| //il valore da validare passa il controllo? | ||
| $result = $decoder->validate('ciao', $context); | ||
|
||
| //è ciò che mi aspettavo? (Successo) | ||
| $this->assertInstanceOf(ValidationSuccess::class, $result); | ||
| } | ||
|
|
||
| public function testInvalidValues(): void | ||
| { | ||
| $decoder = new StringDecoder(); | ||
| $context = new Context($decoder); | ||
|
|
||
| foreach ([123, 3.14, true] as $input) { | ||
|
||
| $result = $decoder->validate($input, $context); | ||
| $this->assertNotInstanceOf(ValidationSuccess::class, $result); | ||
|
||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test file path should be coherent with the path of StringDecoder