diff --git a/composer.json b/composer.json index 2df02cd..0822ba2 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "type": "library", "require-dev": { "phpunit/phpunit": "^9", - "giorgiosironi/eris": "^0.14.0", + "giorgiosironi/eris": "dev-master", "phpat/phpat": "^0.10", "facile-it/facile-coding-standard": "0.5.2", "vimeo/psalm": "4.30.0", diff --git a/tests/unit/DecodersTest.php b/tests/unit/DecodersTest.php index ec8502d..c5c4be3 100644 --- a/tests/unit/DecodersTest.php +++ b/tests/unit/DecodersTest.php @@ -33,6 +33,57 @@ public function testMap(): void self::assertSame($i, $a->getValue()); }); } + + public function testStringDecoder(): void + { + /** @psalm-var string $input */ + $input = 'hello'; + + self::asserSuccessSameTo( + $input, + Decoders::string()->decode($input) + ); + } + + public function testNullDecoder(): void + { + self::asserSuccessSameTo( + null, + Decoders::null()->decode(null) + ); + } + + public function testMixedDecoder(): void + { + $d = Decoders::mixed(); + + $this + ->forAll( + Generators::oneOf( + Generators::int(), + Generators::string(), + Generators::bool(), + Generators::constant(null), + Generators::tuple([ + 'a' => Generators::int(), + 'b' => Generators::string(), + ]), + Generators::date() + ) + ) + ->then( + /** + * @psalm-param mixed $any + * + * @psalm-return void + * + * @param mixed $any + */ + function ($any) use ($d): void { + self::asserSuccessSameTo($any, $d->decode($any)); + } + ); + } } namespace Tests\Facile\PhpCodec\DecodersTest;