Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
51 changes: 51 additions & 0 deletions tests/unit/DecodersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down